adminizer 4.6.0 → 4.7.0-build.221

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.
Files changed (335) hide show
  1. package/Readme.md +12 -0
  2. package/assets/RelationDialogStack-CnHFOYyR.css +1 -0
  3. package/assets/RelationDialogStack-DI2bZxQX.js +20 -0
  4. package/assets/add-4213XScp.js +1 -0
  5. package/assets/add-group--F1XxfJ1.js +1 -0
  6. package/assets/add-group-form-DKRXC2n-.js +1 -0
  7. package/assets/add-user-b9HfMq7z.js +1 -0
  8. package/assets/add-user-form-UXAToWQd.js +1 -0
  9. package/assets/app-Clx8f5hd.css +1 -0
  10. package/assets/app-layout-C02ja4OI.js +1 -0
  11. package/assets/app-shell-D8wtkECO.js +1 -0
  12. package/assets/app-sidebar-BR5_zwxj.js +1 -0
  13. package/assets/app-sidebar-header-BZbIBQjq.js +1 -0
  14. package/assets/app.js +59 -7990
  15. package/assets/breadcrumbs-CODaqVkB.js +1 -0
  16. package/assets/catalog-6ZZjWdFs.js +6 -0
  17. package/assets/dashboard-CftAdKiH.js +3 -0
  18. package/assets/date-picker-DSOkNiNo.js +1 -0
  19. package/assets/del-modal-Cd4M7af8.js +1 -0
  20. package/assets/dynamic-controls-BsrJhPDY.js +1 -0
  21. package/assets/geo-json-CzR5JBXL.js +1 -0
  22. package/assets/handsontable-BI98OF5R.js +336 -0
  23. package/assets/history-DLHSU7Ak.js +1 -0
  24. package/assets/home-NcQ7nnU0.js +2 -0
  25. package/assets/icon-C2JNaLxH.js +1 -0
  26. package/assets/init-user-D2HSyXup.js +1 -0
  27. package/assets/input-error-CH2caTtO.js +1 -0
  28. package/assets/jsoneditor-DVNQmA6G.js +3869 -0
  29. package/assets/list-CFU0-TgN.js +4 -0
  30. package/assets/login-DFSLEO17.js +1 -0
  31. package/assets/manifest.json +246 -273
  32. package/assets/material-icon-Bx9pGQiQ.js +1 -0
  33. package/assets/media-manager-WcKe1EvD.js +6 -0
  34. package/assets/module-CT7PC6pc.js +1 -0
  35. package/assets/monaco-Bl4zdWCn.js +11 -0
  36. package/assets/nav-footer-BiSQkPt4.js +1 -0
  37. package/assets/nav-main-rTH0PfDw.js +1 -0
  38. package/assets/nav-user-Bj6cWs0a.js +1 -0
  39. package/assets/notification-Bi-PX87D.js +20 -0
  40. package/assets/pagination-render-AKJvTIRA.js +1 -0
  41. package/assets/register-BTP4uxsK.js +1 -0
  42. package/assets/ru-eW0WKkga.js +1 -0
  43. package/assets/theme-switcher-Dm8EOGzx.js +1 -0
  44. package/assets/toast-editor-DOg_gvSp.js +668 -0
  45. package/assets/user-filters-list-YUfR4XMI.js +1 -0
  46. package/assets/user-info-BgSbT02v.js +1 -0
  47. package/assets/user-menu-content-TQTXHIv6.js +1 -0
  48. package/assets/{vanilla-picker-l5rcX3cq.js → vanilla-picker-B3LgXoKV.js} +1 -7
  49. package/assets/welcome-vLwTu1R6.js +1 -0
  50. package/controllers/add.d.ts +1 -1
  51. package/controllers/add.js +20 -26
  52. package/controllers/addGroup.d.ts +1 -1
  53. package/controllers/addGroup.js +7 -15
  54. package/controllers/addUser.d.ts +1 -1
  55. package/controllers/addUser.js +10 -16
  56. package/controllers/catalog/Catalog.d.ts +1 -1
  57. package/controllers/catalog/Catalog.js +1 -10
  58. package/controllers/catalog/FrontendCatalogAdapter.d.ts +3 -3
  59. package/controllers/catalog/FrontendCatalogAdapter.js +0 -6
  60. package/controllers/catalog/FrontentCatalogAdapter.d.ts +3 -3
  61. package/controllers/catalog/FrontentCatalogAdapter.js +0 -4
  62. package/controllers/ckeditorUpload.js +2 -18
  63. package/controllers/dashboard.d.ts +1 -1
  64. package/controllers/dashboard.js +2 -5
  65. package/controllers/edit.js +24 -37
  66. package/controllers/editGroup.d.ts +1 -1
  67. package/controllers/editGroup.js +10 -21
  68. package/controllers/editUser.d.ts +1 -1
  69. package/controllers/editUser.js +11 -23
  70. package/controllers/exportData.d.ts +6 -0
  71. package/controllers/exportData.js +315 -0
  72. package/controllers/feed.d.ts +6 -0
  73. package/controllers/feed.js +73 -0
  74. package/controllers/feedback/feedbackController.d.ts +1 -1
  75. package/controllers/feedback/feedbackController.js +5 -7
  76. package/controllers/filter-fields/columns.d.ts +11 -0
  77. package/controllers/filter-fields/columns.js +106 -0
  78. package/controllers/filter-fields/filterFields.d.ts +10 -0
  79. package/controllers/filter-fields/filterFields.js +141 -0
  80. package/controllers/filter-fields/getAllUserFilters.d.ts +6 -0
  81. package/controllers/filter-fields/getAllUserFilters.js +115 -0
  82. package/controllers/filter-fields/groups.d.ts +5 -0
  83. package/controllers/filter-fields/groups.js +26 -0
  84. package/controllers/filter-fields/savedFilters.d.ts +25 -0
  85. package/controllers/filter-fields/savedFilters.js +317 -0
  86. package/controllers/getAllWidgets.d.ts +1 -1
  87. package/controllers/getAllWidgets.js +1 -9
  88. package/controllers/history-actions/HistoryController.js +6 -31
  89. package/controllers/initUser.js +6 -5
  90. package/controllers/inlineUpdate.d.ts +7 -0
  91. package/controllers/inlineUpdate.js +148 -0
  92. package/controllers/list.d.ts +1 -1
  93. package/controllers/list.js +383 -70
  94. package/controllers/listUserFilters.d.ts +5 -0
  95. package/controllers/listUserFilters.js +26 -0
  96. package/controllers/login.js +2 -2
  97. package/controllers/media-manager/mediaManagerApi.js +0 -9
  98. package/controllers/navigation/edit.js +3 -9
  99. package/controllers/notifications/NotificationController.d.ts +1 -1
  100. package/controllers/notifications/NotificationController.js +12 -36
  101. package/controllers/register.js +10 -9
  102. package/controllers/remove.js +10 -19
  103. package/controllers/timezones.d.ts +1 -1
  104. package/controllers/timezones.js +0 -6
  105. package/controllers/userApiKey.d.ts +7 -0
  106. package/controllers/userApiKey.js +36 -0
  107. package/controllers/view.js +14 -26
  108. package/controllers/welcome.d.ts +1 -1
  109. package/controllers/welcome.js +0 -4
  110. package/controllers/widgets/Action.d.ts +1 -1
  111. package/controllers/widgets/Action.js +1 -9
  112. package/controllers/widgets/Custom.d.ts +1 -1
  113. package/controllers/widgets/Custom.js +1 -9
  114. package/controllers/widgets/Info.d.ts +1 -1
  115. package/controllers/widgets/Info.js +1 -9
  116. package/controllers/widgets/filterInfo.d.ts +1 -0
  117. package/controllers/widgets/filterInfo.js +44 -0
  118. package/controllers/widgets/switch.d.ts +1 -1
  119. package/controllers/widgets/switch.js +1 -9
  120. package/controllers/widgetsDB.d.ts +1 -1
  121. package/controllers/widgetsDB.js +2 -8
  122. package/helpers/accessRightsHelper.d.ts +1 -1
  123. package/helpers/accessRightsHelper.js +5 -4
  124. package/helpers/apiKeyHelper.d.ts +5 -0
  125. package/helpers/apiKeyHelper.js +8 -0
  126. package/helpers/configHelper.js +12 -15
  127. package/helpers/controllerHelper.d.ts +14 -21
  128. package/helpers/controllerHelper.js +50 -83
  129. package/helpers/fieldsHelper.js +3 -3
  130. package/helpers/filterDatetimeHelper.d.ts +5 -0
  131. package/helpers/filterDatetimeHelper.js +84 -0
  132. package/helpers/inertiaActionsHelper.d.ts +2 -2
  133. package/helpers/inertiaActionsHelper.js +5 -4
  134. package/helpers/inertiaAddHelper.d.ts +3 -414
  135. package/helpers/inertiaAddHelper.js +39 -15
  136. package/helpers/inertiaGroupHelper.d.ts +2 -2
  137. package/helpers/inertiaGroupHelper.js +3 -3
  138. package/helpers/inertiaListHelper.d.ts +7 -3
  139. package/helpers/inertiaListHelper.js +26 -12
  140. package/helpers/inertiaMenuHelper.d.ts +1 -0
  141. package/helpers/inertiaMenuHelper.js +15 -3
  142. package/helpers/inertiaUserHelper.d.ts +3 -2
  143. package/helpers/inertiaUserHelper.js +7 -3
  144. package/helpers/menuHelper.d.ts +5 -2
  145. package/helpers/menuHelper.js +64 -12
  146. package/helpers/viteHelper.js +1 -2
  147. package/index.d.ts +6 -2
  148. package/index.js +6 -2
  149. package/interfaces/adminpanelConfig.d.ts +126 -39
  150. package/interfaces/internalModelAccess.d.ts +37 -0
  151. package/interfaces/internalModelAccess.js +1 -0
  152. package/interfaces/listQueryBuilder.d.ts +22 -0
  153. package/interfaces/listQueryBuilder.js +1 -0
  154. package/interfaces/queryCriteria.d.ts +54 -0
  155. package/interfaces/queryCriteria.js +1 -0
  156. package/interfaces/types.d.ts +1 -13
  157. package/lib/Adminizer.d.ts +4 -2
  158. package/lib/Adminizer.js +29 -10
  159. package/lib/DataAccessor.d.ts +8 -5
  160. package/lib/DataAccessor.js +89 -42
  161. package/lib/I18n.d.ts +5 -1
  162. package/lib/I18n.js +45 -19
  163. package/lib/MiddlewareManager.d.ts +8 -0
  164. package/lib/MiddlewareManager.js +53 -0
  165. package/lib/ai-assistant/OpenAiModelService.d.ts +3 -3
  166. package/lib/ai-assistant/OpenAiModelService.js +23 -24
  167. package/lib/catalog/Navigation.d.ts +1 -0
  168. package/lib/catalog/Navigation.js +12 -11
  169. package/lib/controls/jsoneditor/JsonEditor.d.ts +1 -2
  170. package/lib/controls/markdown/ToastUiEditor.d.ts +1 -2
  171. package/lib/feedback/FeedbackHandler.js +2 -2
  172. package/lib/filters/ConditionValidator.d.ts +107 -0
  173. package/lib/filters/ConditionValidator.js +483 -0
  174. package/lib/filters/CustomFilterHandler.d.ts +122 -0
  175. package/lib/filters/CustomFilterHandler.js +131 -0
  176. package/lib/filters/FilterCustomFieldHandler.d.ts +2 -0
  177. package/lib/filters/FilterCustomFieldHandler.js +2 -0
  178. package/lib/filters/FilterService.d.ts +82 -0
  179. package/lib/filters/FilterService.js +323 -0
  180. package/lib/filters/index.d.ts +6 -0
  181. package/lib/filters/index.js +4 -0
  182. package/lib/history-actions/AbstractHistoryAdapter.d.ts +5 -4
  183. package/lib/history-actions/AbstractHistoryAdapter.js +45 -30
  184. package/lib/history-actions/DefaultHistoryAdapter.d.ts +2 -0
  185. package/lib/history-actions/DefaultHistoryAdapter.js +12 -6
  186. package/lib/history-actions/HistoryHandler.js +1 -1
  187. package/lib/list-query-builder/ListQueryBuilder.d.ts +117 -0
  188. package/lib/list-query-builder/ListQueryBuilder.js +707 -0
  189. package/lib/media-manager/AbstractMediaManager.d.ts +9 -8
  190. package/lib/media-manager/DefaultMediaManager.d.ts +2 -0
  191. package/lib/media-manager/DefaultMediaManager.js +27 -15
  192. package/lib/media-manager/Items.d.ts +4 -1
  193. package/lib/media-manager/Items.js +62 -59
  194. package/lib/media-manager/MediaManagerHandler.js +1 -1
  195. package/lib/media-manager/helpers/MediaManagerHelper.d.ts +5 -1
  196. package/lib/media-manager/helpers/MediaManagerHelper.js +38 -4
  197. package/lib/model/AbstractModel.d.ts +33 -25
  198. package/lib/model/AbstractModel.js +54 -2
  199. package/lib/model/InternalModelAccessFactory.d.ts +18 -0
  200. package/lib/model/InternalModelAccessFactory.js +82 -0
  201. package/lib/model/ModelHandler.d.ts +6 -0
  202. package/lib/model/ModelHandler.js +14 -0
  203. package/lib/model/adapter/sequelize.d.ts +32 -10
  204. package/lib/model/adapter/sequelize.js +409 -62
  205. package/lib/model/adapter/typeorm.d.ts +62 -0
  206. package/lib/model/adapter/typeorm.js +777 -0
  207. package/lib/model/internalModelAccessToken.d.ts +1 -0
  208. package/lib/model/internalModelAccessToken.js +1 -0
  209. package/lib/model/internalModelRepository.d.ts +3 -0
  210. package/lib/model/internalModelRepository.js +4 -0
  211. package/lib/notifications/AbstractNotificationService.d.ts +3 -0
  212. package/lib/notifications/AbstractNotificationService.js +42 -36
  213. package/lib/notifications/GeneralNotificationService.js +37 -40
  214. package/lib/notifications/SystemNotificationService.js +33 -36
  215. package/lib/requestProcessor.js +0 -3
  216. package/lib/ui-i18n/getUiTranslations.d.ts +1 -0
  217. package/lib/ui-i18n/getUiTranslations.js +3 -0
  218. package/lib/ui-i18n/uiTranslationKeys.d.ts +6 -0
  219. package/lib/ui-i18n/uiTranslationKeys.js +268 -0
  220. package/lib/widgets/widgetHandler.d.ts +7 -2
  221. package/lib/widgets/widgetHandler.js +98 -18
  222. package/models/FilterAP.d.ts +116 -0
  223. package/models/FilterAP.js +68 -0
  224. package/models/FilterColumnAP.d.ts +32 -0
  225. package/models/FilterColumnAP.js +21 -0
  226. package/models/GroupAP.d.ts +1 -1
  227. package/models/HistoryActionsAP.d.ts +3 -3
  228. package/models/MediaManagerMetaAP.d.ts +1 -1
  229. package/models/NavigationAP.d.ts +1 -1
  230. package/models/UserAP.d.ts +6 -1
  231. package/models/UserAP.js +4 -0
  232. package/package.json +39 -32
  233. package/policies/authPolicies.d.ts +12 -0
  234. package/policies/authPolicies.js +104 -0
  235. package/policies/permissionResolvers.d.ts +12 -0
  236. package/policies/permissionResolvers.js +52 -0
  237. package/services/FeedService.d.ts +70 -0
  238. package/services/FeedService.js +334 -0
  239. package/system/Router.d.ts +1 -0
  240. package/system/Router.js +136 -59
  241. package/system/bindAccessRights.js +11 -30
  242. package/system/bindAuthorization.js +18 -18
  243. package/system/bindCors.js +16 -1
  244. package/system/bindCustomFilterHandlers.d.ts +2 -0
  245. package/system/bindCustomFilterHandlers.js +4 -0
  246. package/system/bindInertia.js +18 -61
  247. package/system/bindReqFunctions.js +10 -2
  248. package/system/bindTranslations.js +7 -3
  249. package/system/buildInternalModelAccess.d.ts +4 -0
  250. package/system/buildInternalModelAccess.js +59 -0
  251. package/system/defaults.js +18 -14
  252. package/system/routePolicies.d.ts +2 -0
  253. package/system/routePolicies.js +29 -0
  254. package/translations/en.json +151 -39
  255. package/translations/ru.json +211 -64
  256. package/ui/components/handsontable.js +13 -27
  257. package/ui/components/ui/dialog-stack.js +1 -3
  258. package/ui/components/ui/popover.js +1 -1
  259. package/ui/components/ui/sidebar.js +1 -1
  260. package/assets/RelationDialogStack-D9UVEF9s.js +0 -407
  261. package/assets/RelationDialogStack-DV8OITPR.css +0 -4
  262. package/assets/add-BlvzWQKF.js +0 -1
  263. package/assets/add-group-1Uoq9NWe.js +0 -1
  264. package/assets/add-group-form-B01gwDGu.js +0 -1
  265. package/assets/add-user-BQCAsaRy.js +0 -1
  266. package/assets/add-user-form-Cgwc9JkI.js +0 -1
  267. package/assets/app-DaOMy1nl.css +0 -72
  268. package/assets/app-layout-CAm60qoE.js +0 -1
  269. package/assets/app-shell-QWCtn9ye.js +0 -1
  270. package/assets/app-sidebar-CfaYbnSy.js +0 -1
  271. package/assets/app-sidebar-header-BsPFDhZ8.js +0 -1
  272. package/assets/breadcrumbs-CZZirDj8.js +0 -1
  273. package/assets/catalog-k5myk7fk.js +0 -6
  274. package/assets/dashboard-BkL9ybBw.js +0 -3
  275. package/assets/date-picker-B5AZ_7Q9.js +0 -1
  276. package/assets/del-modal-BoyXZloG.js +0 -1
  277. package/assets/dynamic-controls-k61T9W2P.js +0 -1
  278. package/assets/form-1WGY0YgG.js +0 -1
  279. package/assets/form-DJapG3qF.js +0 -1
  280. package/assets/geo-json-DsMUHo0l.js +0 -4
  281. package/assets/handsontable-PxYdjN8c.js +0 -298
  282. package/assets/history-CluyR-yJ.js +0 -1
  283. package/assets/home-Dug9zBzM.js +0 -2
  284. package/assets/icon-DfDLMG5f.js +0 -1
  285. package/assets/init-user-CF80MEnT.js +0 -1
  286. package/assets/input-error-DuuqFgZa.js +0 -1
  287. package/assets/jsoneditor-De1FvcYu.js +0 -3882
  288. package/assets/list-CuexshNt.js +0 -1
  289. package/assets/list-table-BsEWjTKY.js +0 -22
  290. package/assets/login-eDemYzN-.js +0 -1
  291. package/assets/material-icon-DMT8KdmE.js +0 -1
  292. package/assets/media-manager-DfYa_mT_.js +0 -14
  293. package/assets/module-Cd4Tm6uq.js +0 -1
  294. package/assets/monaco-BhBYtg3d.js +0 -11
  295. package/assets/nav-footer-D3olYxtz.js +0 -1
  296. package/assets/nav-main-BctqyzeV.js +0 -1
  297. package/assets/nav-user-Bn1Lt-BZ.js +0 -1
  298. package/assets/notification-D64qvni-.js +0 -27
  299. package/assets/pagination-render-DxD78ahJ.js +0 -1
  300. package/assets/register-349PwYbe.js +0 -1
  301. package/assets/theme-switcher-DfExsHW2.js +0 -1
  302. package/assets/toast-editor-ESK5iWPx.js +0 -845
  303. package/assets/user-info-DtBK5Kh8.js +0 -1
  304. package/assets/user-menu-content-0XYOCMaA.js +0 -1
  305. package/assets/welcome-PDp-gUei.js +0 -1
  306. package/controllers/form.d.ts +0 -1
  307. package/controllers/form.js +0 -86
  308. package/helpers/formHelper.d.ts +0 -6
  309. package/helpers/formHelper.js +0 -38
  310. package/helpers/inertiaFromHelper.d.ts +0 -11
  311. package/helpers/inertiaFromHelper.js +0 -98
  312. package/helpers/runtimeMode.d.ts +0 -1
  313. package/helpers/runtimeMode.js +0 -3
  314. package/lib/PolicyManager.d.ts +0 -8
  315. package/lib/PolicyManager.js +0 -53
  316. package/lib/datatable/NodeTable.d.ts +0 -49
  317. package/lib/datatable/NodeTable.js +0 -207
  318. package/lib/model/adapter/waterline.d.ts +0 -32
  319. package/lib/model/adapter/waterline.js +0 -180
  320. package/migrations/index.d.ts +0 -3
  321. package/migrations/index.js +0 -4
  322. package/migrations/knex/20250106000001_adminizer_init.d.ts +0 -8
  323. package/migrations/knex/20250106000001_adminizer_init.js +0 -164
  324. package/migrations/umzug/0001.d.ts +0 -7
  325. package/migrations/umzug/0001.js +0 -121
  326. package/migrations/umzugExports.d.ts +0 -2
  327. package/migrations/umzugExports.js +0 -9
  328. package/system/bindForms.d.ts +0 -2
  329. package/system/bindForms.js +0 -20
  330. /package/{policies → middlewares}/addMessages.d.ts +0 -0
  331. /package/{policies → middlewares}/addMessages.js +0 -0
  332. /package/{policies → middlewares}/checkAuth.d.ts +0 -0
  333. /package/{policies → middlewares}/checkAuth.js +0 -0
  334. /package/{policies → middlewares}/setLocale.d.ts +0 -0
  335. /package/{policies → middlewares}/setLocale.js +0 -0
@@ -0,0 +1,4 @@
1
+ import{c8 as n,aw as U,r as M,b6 as Gn,bB as Ms,bF as $n,bG as it,bE as _n,bC as Ps,bD as In,af as ct,am as dt,N as Gt,ah as gt,ak as ks,al as Bn,ag as Vs,bX as ee,cf as ce,cd as En,y as qe,c as As,A as Ds,d as zs,ck as Qt,cc as Zt,ci as Ls,ap as Bt,aB as ke,bU as Re,aq as qt,B as mt,aZ as qn,bc as en,c1 as ue,bW as Le,b7 as Ve,ba as Ae,bb as De,b8 as ze,b9 as ve,a$ as Ee,b1 as Me,c3 as jt,b0 as Pe,s as Nt,O as Rt,R as bt,T as Ft,P as $t,Q as _t,S as It,a2 as Hs,a8 as Ts,a3 as Os,a4 as Mn,a7 as Et,a9 as Mt,a5 as Pt,a_ as Gs,b5 as Bs,bR as qs,E as Us,F as Ks,z as Ws,D as Xs,a6 as Pn,bL as kn,bA as Ys,az as Ue,bx as Js,b3 as Vn,ad as Qs,ai as Ut,aj as be,j as Un,aY as Zs,an as er,bM as tr}from"./app.js";import{A as nr}from"./app-layout-C02ja4OI.js";import{aZ as v}from"./handsontable-BI98OF5R.js";import{Icon as de}from"./icon-C2JNaLxH.js";import sr from"./pagination-render-AKJvTIRA.js";import Ce from"./material-icon-Bx9pGQiQ.js";import{D as Kn}from"./del-modal-Cd4M7af8.js";import{r as kt}from"./ru-eW0WKkga.js";import"./jsoneditor-DVNQmA6G.js";import"./monaco-Bl4zdWCn.js";import"./app-shell-D8wtkECO.js";import"./app-sidebar-BR5_zwxj.js";import"./nav-main-rTH0PfDw.js";import"./app-sidebar-header-BZbIBQjq.js";import"./breadcrumbs-CODaqVkB.js";import"./nav-user-Bj6cWs0a.js";import"./user-info-BgSbT02v.js";import"./user-menu-content-TQTXHIv6.js";import"./theme-switcher-Dm8EOGzx.js";import"./RelationDialogStack-DI2bZxQX.js";import"./dynamic-controls-BsrJhPDY.js";import"./input-error-CH2caTtO.js";function we(e,r){return typeof e=="function"?e(r):e}function te(e,r){return t=>{r.setState(s=>({...s,[e]:we(t,s[e])}))}}function ft(e){return e instanceof Function}function rr(e){return Array.isArray(e)&&e.every(r=>typeof r=="number")}function ir(e,r){const t=[],s=i=>{i.forEach(a=>{t.push(a);const u=r(a);u!=null&&u.length&&s(u)})};return s(e),t}function P(e,r,t){let s=[],i;return a=>{let u;t.key&&t.debug&&(u=Date.now());const c=e(a);if(!(c.length!==s.length||c.some((o,C)=>s[C]!==o)))return i;s=c;let d;if(t.key&&t.debug&&(d=Date.now()),i=r(...c),t==null||t.onChange==null||t.onChange(i),t.key&&t.debug&&t!=null&&t.debug()){const o=Math.round((Date.now()-u)*100)/100,C=Math.round((Date.now()-d)*100)/100,w=C/16,h=(y,x)=>{for(y=String(y);y.length<x;)y=" "+y;return y};console.info(`%c⏱ ${h(C,5)} /${h(o,5)} ms`,`
2
+ font-size: .6rem;
3
+ font-weight: bold;
4
+ color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,t?.key)}return i}}function k(e,r,t,s){return{debug:()=>{var i;return(i=e?.debugAll)!=null?i:e[r]},key:!1,onChange:s}}function lr(e,r,t,s){const i=()=>{var u;return(u=a.getValue())!=null?u:e.options.renderFallbackValue},a={id:`${r.id}_${t.id}`,row:r,column:t,getValue:()=>r.getValue(s),renderValue:i,getContext:P(()=>[e,t,r,a],(u,c,m,d)=>({table:u,column:c,row:m,cell:d,getValue:d.getValue,renderValue:d.renderValue}),k(e.options,"debugCells"))};return e._features.forEach(u=>{u.createCell==null||u.createCell(a,t,r,e)},{}),a}function or(e,r,t,s){var i,a;const c={...e._getDefaultColumnDef(),...r},m=c.accessorKey;let d=(i=(a=c.id)!=null?a:m?typeof String.prototype.replaceAll=="function"?m.replaceAll(".","_"):m.replace(/\./g,"_"):void 0)!=null?i:typeof c.header=="string"?c.header:void 0,o;if(c.accessorFn?o=c.accessorFn:m&&(m.includes(".")?o=w=>{let h=w;for(const x of m.split(".")){var y;h=(y=h)==null?void 0:y[x]}return h}:o=w=>w[c.accessorKey]),!d)throw new Error;let C={id:`${String(d)}`,accessorFn:o,parent:s,depth:t,columnDef:c,columns:[],getFlatColumns:P(()=>[!0],()=>{var w;return[C,...(w=C.columns)==null?void 0:w.flatMap(h=>h.getFlatColumns())]},k(e.options,"debugColumns")),getLeafColumns:P(()=>[e._getOrderColumnsFn()],w=>{var h;if((h=C.columns)!=null&&h.length){let y=C.columns.flatMap(x=>x.getLeafColumns());return w(y)}return[C]},k(e.options,"debugColumns"))};for(const w of e._features)w.createColumn==null||w.createColumn(C,e);return C}const Z="debugHeaders";function An(e,r,t){var s;let a={id:(s=t.id)!=null?s:r.id,column:r,index:t.index,isPlaceholder:!!t.isPlaceholder,placeholderId:t.placeholderId,depth:t.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const u=[],c=m=>{m.subHeaders&&m.subHeaders.length&&m.subHeaders.map(c),u.push(m)};return c(a),u},getContext:()=>({table:e,header:a,column:r})};return e._features.forEach(u=>{u.createHeader==null||u.createHeader(a,e)}),a}const ar={createTable:e=>{e.getHeaderGroups=P(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(r,t,s,i)=>{var a,u;const c=(a=s?.map(C=>t.find(w=>w.id===C)).filter(Boolean))!=null?a:[],m=(u=i?.map(C=>t.find(w=>w.id===C)).filter(Boolean))!=null?u:[],d=t.filter(C=>!(s!=null&&s.includes(C.id))&&!(i!=null&&i.includes(C.id)));return lt(r,[...c,...d,...m],e)},k(e.options,Z)),e.getCenterHeaderGroups=P(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(r,t,s,i)=>(t=t.filter(a=>!(s!=null&&s.includes(a.id))&&!(i!=null&&i.includes(a.id))),lt(r,t,e,"center")),k(e.options,Z)),e.getLeftHeaderGroups=P(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(r,t,s)=>{var i;const a=(i=s?.map(u=>t.find(c=>c.id===u)).filter(Boolean))!=null?i:[];return lt(r,a,e,"left")},k(e.options,Z)),e.getRightHeaderGroups=P(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(r,t,s)=>{var i;const a=(i=s?.map(u=>t.find(c=>c.id===u)).filter(Boolean))!=null?i:[];return lt(r,a,e,"right")},k(e.options,Z)),e.getFooterGroups=P(()=>[e.getHeaderGroups()],r=>[...r].reverse(),k(e.options,Z)),e.getLeftFooterGroups=P(()=>[e.getLeftHeaderGroups()],r=>[...r].reverse(),k(e.options,Z)),e.getCenterFooterGroups=P(()=>[e.getCenterHeaderGroups()],r=>[...r].reverse(),k(e.options,Z)),e.getRightFooterGroups=P(()=>[e.getRightHeaderGroups()],r=>[...r].reverse(),k(e.options,Z)),e.getFlatHeaders=P(()=>[e.getHeaderGroups()],r=>r.map(t=>t.headers).flat(),k(e.options,Z)),e.getLeftFlatHeaders=P(()=>[e.getLeftHeaderGroups()],r=>r.map(t=>t.headers).flat(),k(e.options,Z)),e.getCenterFlatHeaders=P(()=>[e.getCenterHeaderGroups()],r=>r.map(t=>t.headers).flat(),k(e.options,Z)),e.getRightFlatHeaders=P(()=>[e.getRightHeaderGroups()],r=>r.map(t=>t.headers).flat(),k(e.options,Z)),e.getCenterLeafHeaders=P(()=>[e.getCenterFlatHeaders()],r=>r.filter(t=>{var s;return!((s=t.subHeaders)!=null&&s.length)}),k(e.options,Z)),e.getLeftLeafHeaders=P(()=>[e.getLeftFlatHeaders()],r=>r.filter(t=>{var s;return!((s=t.subHeaders)!=null&&s.length)}),k(e.options,Z)),e.getRightLeafHeaders=P(()=>[e.getRightFlatHeaders()],r=>r.filter(t=>{var s;return!((s=t.subHeaders)!=null&&s.length)}),k(e.options,Z)),e.getLeafHeaders=P(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(r,t,s)=>{var i,a,u,c,m,d;return[...(i=(a=r[0])==null?void 0:a.headers)!=null?i:[],...(u=(c=t[0])==null?void 0:c.headers)!=null?u:[],...(m=(d=s[0])==null?void 0:d.headers)!=null?m:[]].map(o=>o.getLeafHeaders()).flat()},k(e.options,Z))}};function lt(e,r,t,s){var i,a;let u=0;const c=function(w,h){h===void 0&&(h=1),u=Math.max(u,h),w.filter(y=>y.getIsVisible()).forEach(y=>{var x;(x=y.columns)!=null&&x.length&&c(y.columns,h+1)},0)};c(e);let m=[];const d=(w,h)=>{const y={depth:h,id:[s,`${h}`].filter(Boolean).join("_"),headers:[]},x=[];w.forEach(N=>{const p=[...x].reverse()[0],R=N.column.depth===y.depth;let j,_=!1;if(R&&N.column.parent?j=N.column.parent:(j=N.column,_=!0),p&&p?.column===j)p.subHeaders.push(N);else{const $=An(t,j,{id:[s,h,j.id,N?.id].filter(Boolean).join("_"),isPlaceholder:_,placeholderId:_?`${x.filter(b=>b.column===j).length}`:void 0,depth:h,index:x.length});$.subHeaders.push(N),x.push($)}y.headers.push(N),N.headerGroup=y}),m.push(y),h>0&&d(x,h-1)},o=r.map((w,h)=>An(t,w,{depth:u,index:h}));d(o,u-1),m.reverse();const C=w=>w.filter(y=>y.column.getIsVisible()).map(y=>{let x=0,N=0,p=[0];y.subHeaders&&y.subHeaders.length?(p=[],C(y.subHeaders).forEach(j=>{let{colSpan:_,rowSpan:$}=j;x+=_,p.push($)})):x=1;const R=Math.min(...p);return N=N+R,y.colSpan=x,y.rowSpan=N,{colSpan:x,rowSpan:N}});return C((i=(a=m[0])==null?void 0:a.headers)!=null?i:[]),m}const ur=(e,r,t,s,i,a,u)=>{let c={id:r,index:s,original:t,depth:i,parentId:u,_valuesCache:{},_uniqueValuesCache:{},getValue:m=>{if(c._valuesCache.hasOwnProperty(m))return c._valuesCache[m];const d=e.getColumn(m);if(d!=null&&d.accessorFn)return c._valuesCache[m]=d.accessorFn(c.original,s),c._valuesCache[m]},getUniqueValues:m=>{if(c._uniqueValuesCache.hasOwnProperty(m))return c._uniqueValuesCache[m];const d=e.getColumn(m);if(d!=null&&d.accessorFn)return d.columnDef.getUniqueValues?(c._uniqueValuesCache[m]=d.columnDef.getUniqueValues(c.original,s),c._uniqueValuesCache[m]):(c._uniqueValuesCache[m]=[c.getValue(m)],c._uniqueValuesCache[m])},renderValue:m=>{var d;return(d=c.getValue(m))!=null?d:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>ir(c.subRows,m=>m.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let m=[],d=c;for(;;){const o=d.getParentRow();if(!o)break;m.push(o),d=o}return m.reverse()},getAllCells:P(()=>[e.getAllLeafColumns()],m=>m.map(d=>lr(e,c,d,d.id)),k(e.options,"debugRows")),_getAllCellsByColumnId:P(()=>[c.getAllCells()],m=>m.reduce((d,o)=>(d[o.column.id]=o,d),{}),k(e.options,"debugRows"))};for(let m=0;m<e._features.length;m++){const d=e._features[m];d==null||d.createRow==null||d.createRow(c,e)}return c},cr={createColumn:(e,r)=>{e._getFacetedRowModel=r.options.getFacetedRowModel&&r.options.getFacetedRowModel(r,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():r.getPreFilteredRowModel(),e._getFacetedUniqueValues=r.options.getFacetedUniqueValues&&r.options.getFacetedUniqueValues(r,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=r.options.getFacetedMinMaxValues&&r.options.getFacetedMinMaxValues(r,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},Wn=(e,r,t)=>{var s,i;const a=t==null||(s=t.toString())==null?void 0:s.toLowerCase();return!!(!((i=e.getValue(r))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};Wn.autoRemove=e=>oe(e);const Xn=(e,r,t)=>{var s;return!!(!((s=e.getValue(r))==null||(s=s.toString())==null)&&s.includes(t))};Xn.autoRemove=e=>oe(e);const Yn=(e,r,t)=>{var s;return((s=e.getValue(r))==null||(s=s.toString())==null?void 0:s.toLowerCase())===t?.toLowerCase()};Yn.autoRemove=e=>oe(e);const Jn=(e,r,t)=>{var s;return(s=e.getValue(r))==null?void 0:s.includes(t)};Jn.autoRemove=e=>oe(e);const Qn=(e,r,t)=>!t.some(s=>{var i;return!((i=e.getValue(r))!=null&&i.includes(s))});Qn.autoRemove=e=>oe(e)||!(e!=null&&e.length);const Zn=(e,r,t)=>t.some(s=>{var i;return(i=e.getValue(r))==null?void 0:i.includes(s)});Zn.autoRemove=e=>oe(e)||!(e!=null&&e.length);const es=(e,r,t)=>e.getValue(r)===t;es.autoRemove=e=>oe(e);const ts=(e,r,t)=>e.getValue(r)==t;ts.autoRemove=e=>oe(e);const tn=(e,r,t)=>{let[s,i]=t;const a=e.getValue(r);return a>=s&&a<=i};tn.resolveFilterValue=e=>{let[r,t]=e,s=typeof r!="number"?parseFloat(r):r,i=typeof t!="number"?parseFloat(t):t,a=r===null||Number.isNaN(s)?-1/0:s,u=t===null||Number.isNaN(i)?1/0:i;if(a>u){const c=a;a=u,u=c}return[a,u]};tn.autoRemove=e=>oe(e)||oe(e[0])&&oe(e[1]);const fe={includesString:Wn,includesStringSensitive:Xn,equalsString:Yn,arrIncludes:Jn,arrIncludesAll:Qn,arrIncludesSome:Zn,equals:es,weakEquals:ts,inNumberRange:tn};function oe(e){return e==null||e===""}const dr={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:te("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,r)=>{e.getAutoFilterFn=()=>{const t=r.getCoreRowModel().flatRows[0],s=t?.getValue(e.id);return typeof s=="string"?fe.includesString:typeof s=="number"?fe.inNumberRange:typeof s=="boolean"||s!==null&&typeof s=="object"?fe.equals:Array.isArray(s)?fe.arrIncludes:fe.weakEquals},e.getFilterFn=()=>{var t,s;return ft(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(t=(s=r.options.filterFns)==null?void 0:s[e.columnDef.filterFn])!=null?t:fe[e.columnDef.filterFn]},e.getCanFilter=()=>{var t,s,i;return((t=e.columnDef.enableColumnFilter)!=null?t:!0)&&((s=r.options.enableColumnFilters)!=null?s:!0)&&((i=r.options.enableFilters)!=null?i:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var t;return(t=r.getState().columnFilters)==null||(t=t.find(s=>s.id===e.id))==null?void 0:t.value},e.getFilterIndex=()=>{var t,s;return(t=(s=r.getState().columnFilters)==null?void 0:s.findIndex(i=>i.id===e.id))!=null?t:-1},e.setFilterValue=t=>{r.setColumnFilters(s=>{const i=e.getFilterFn(),a=s?.find(o=>o.id===e.id),u=we(t,a?a.value:void 0);if(Dn(i,u,e)){var c;return(c=s?.filter(o=>o.id!==e.id))!=null?c:[]}const m={id:e.id,value:u};if(a){var d;return(d=s?.map(o=>o.id===e.id?m:o))!=null?d:[]}return s!=null&&s.length?[...s,m]:[m]})}},createRow:(e,r)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=r=>{const t=e.getAllLeafColumns(),s=i=>{var a;return(a=we(r,i))==null?void 0:a.filter(u=>{const c=t.find(m=>m.id===u.id);if(c){const m=c.getFilterFn();if(Dn(m,u.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(s)},e.resetColumnFilters=r=>{var t,s;e.setColumnFilters(r?[]:(t=(s=e.initialState)==null?void 0:s.columnFilters)!=null?t:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function Dn(e,r,t){return(e&&e.autoRemove?e.autoRemove(r,t):!1)||typeof r>"u"||typeof r=="string"&&!r}const gr=(e,r,t)=>t.reduce((s,i)=>{const a=i.getValue(e);return s+(typeof a=="number"?a:0)},0),mr=(e,r,t)=>{let s;return t.forEach(i=>{const a=i.getValue(e);a!=null&&(s>a||s===void 0&&a>=a)&&(s=a)}),s},fr=(e,r,t)=>{let s;return t.forEach(i=>{const a=i.getValue(e);a!=null&&(s<a||s===void 0&&a>=a)&&(s=a)}),s},pr=(e,r,t)=>{let s,i;return t.forEach(a=>{const u=a.getValue(e);u!=null&&(s===void 0?u>=u&&(s=i=u):(s>u&&(s=u),i<u&&(i=u)))}),[s,i]},hr=(e,r)=>{let t=0,s=0;if(r.forEach(i=>{let a=i.getValue(e);a!=null&&(a=+a)>=a&&(++t,s+=a)}),t)return s/t},xr=(e,r)=>{if(!r.length)return;const t=r.map(a=>a.getValue(e));if(!rr(t))return;if(t.length===1)return t[0];const s=Math.floor(t.length/2),i=t.sort((a,u)=>a-u);return t.length%2!==0?i[s]:(i[s-1]+i[s])/2},vr=(e,r)=>Array.from(new Set(r.map(t=>t.getValue(e))).values()),wr=(e,r)=>new Set(r.map(t=>t.getValue(e))).size,Cr=(e,r)=>r.length,Vt={sum:gr,min:mr,max:fr,extent:pr,mean:hr,median:xr,unique:vr,uniqueCount:wr,count:Cr},Sr={getDefaultColumnDef:()=>({aggregatedCell:e=>{var r,t;return(r=(t=e.getValue())==null||t.toString==null?void 0:t.toString())!=null?r:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:te("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,r)=>{e.toggleGrouping=()=>{r.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(s=>s!==e.id):[...t??[],e.id])},e.getCanGroup=()=>{var t,s;return((t=e.columnDef.enableGrouping)!=null?t:!0)&&((s=r.options.enableGrouping)!=null?s:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var t;return(t=r.getState().grouping)==null?void 0:t.includes(e.id)},e.getGroupedIndex=()=>{var t;return(t=r.getState().grouping)==null?void 0:t.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const t=r.getCoreRowModel().flatRows[0],s=t?.getValue(e.id);if(typeof s=="number")return Vt.sum;if(Object.prototype.toString.call(s)==="[object Date]")return Vt.extent},e.getAggregationFn=()=>{var t,s;if(!e)throw new Error;return ft(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(t=(s=r.options.aggregationFns)==null?void 0:s[e.columnDef.aggregationFn])!=null?t:Vt[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=r=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(r),e.resetGrouping=r=>{var t,s;e.setGrouping(r?[]:(t=(s=e.initialState)==null?void 0:s.grouping)!=null?t:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,r)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=t=>{if(e._groupingValuesCache.hasOwnProperty(t))return e._groupingValuesCache[t];const s=r.getColumn(t);return s!=null&&s.columnDef.getGroupingValue?(e._groupingValuesCache[t]=s.columnDef.getGroupingValue(e.original),e._groupingValuesCache[t]):e.getValue(t)},e._groupingValuesCache={}},createCell:(e,r,t,s)=>{e.getIsGrouped=()=>r.getIsGrouped()&&r.id===t.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&r.getIsGrouped(),e.getIsAggregated=()=>{var i;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((i=t.subRows)!=null&&i.length)}}};function yr(e,r,t){if(!(r!=null&&r.length)||!t)return e;const s=e.filter(a=>!r.includes(a.id));return t==="remove"?s:[...r.map(a=>e.find(u=>u.id===a)).filter(Boolean),...s]}const jr={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:te("columnOrder",e)}),createColumn:(e,r)=>{e.getIndex=P(t=>[Ke(r,t)],t=>t.findIndex(s=>s.id===e.id),k(r.options,"debugColumns")),e.getIsFirstColumn=t=>{var s;return((s=Ke(r,t)[0])==null?void 0:s.id)===e.id},e.getIsLastColumn=t=>{var s;const i=Ke(r,t);return((s=i[i.length-1])==null?void 0:s.id)===e.id}},createTable:e=>{e.setColumnOrder=r=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(r),e.resetColumnOrder=r=>{var t;e.setColumnOrder(r?[]:(t=e.initialState.columnOrder)!=null?t:[])},e._getOrderColumnsFn=P(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(r,t,s)=>i=>{let a=[];if(!(r!=null&&r.length))a=i;else{const u=[...r],c=[...i];for(;c.length&&u.length;){const m=u.shift(),d=c.findIndex(o=>o.id===m);d>-1&&a.push(c.splice(d,1)[0])}a=[...a,...c]}return yr(a,t,s)},k(e.options,"debugTable"))}},At=()=>({left:[],right:[]}),Nr={getInitialState:e=>({columnPinning:At(),...e}),getDefaultOptions:e=>({onColumnPinningChange:te("columnPinning",e)}),createColumn:(e,r)=>{e.pin=t=>{const s=e.getLeafColumns().map(i=>i.id).filter(Boolean);r.setColumnPinning(i=>{var a,u;if(t==="right"){var c,m;return{left:((c=i?.left)!=null?c:[]).filter(C=>!(s!=null&&s.includes(C))),right:[...((m=i?.right)!=null?m:[]).filter(C=>!(s!=null&&s.includes(C))),...s]}}if(t==="left"){var d,o;return{left:[...((d=i?.left)!=null?d:[]).filter(C=>!(s!=null&&s.includes(C))),...s],right:((o=i?.right)!=null?o:[]).filter(C=>!(s!=null&&s.includes(C)))}}return{left:((a=i?.left)!=null?a:[]).filter(C=>!(s!=null&&s.includes(C))),right:((u=i?.right)!=null?u:[]).filter(C=>!(s!=null&&s.includes(C)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var i,a,u;return((i=s.columnDef.enablePinning)!=null?i:!0)&&((a=(u=r.options.enableColumnPinning)!=null?u:r.options.enablePinning)!=null?a:!0)}),e.getIsPinned=()=>{const t=e.getLeafColumns().map(c=>c.id),{left:s,right:i}=r.getState().columnPinning,a=t.some(c=>s?.includes(c)),u=t.some(c=>i?.includes(c));return a?"left":u?"right":!1},e.getPinnedIndex=()=>{var t,s;const i=e.getIsPinned();return i?(t=(s=r.getState().columnPinning)==null||(s=s[i])==null?void 0:s.indexOf(e.id))!=null?t:-1:0}},createRow:(e,r)=>{e.getCenterVisibleCells=P(()=>[e._getAllVisibleCells(),r.getState().columnPinning.left,r.getState().columnPinning.right],(t,s,i)=>{const a=[...s??[],...i??[]];return t.filter(u=>!a.includes(u.column.id))},k(r.options,"debugRows")),e.getLeftVisibleCells=P(()=>[e._getAllVisibleCells(),r.getState().columnPinning.left],(t,s)=>(s??[]).map(a=>t.find(u=>u.column.id===a)).filter(Boolean).map(a=>({...a,position:"left"})),k(r.options,"debugRows")),e.getRightVisibleCells=P(()=>[e._getAllVisibleCells(),r.getState().columnPinning.right],(t,s)=>(s??[]).map(a=>t.find(u=>u.column.id===a)).filter(Boolean).map(a=>({...a,position:"right"})),k(r.options,"debugRows"))},createTable:e=>{e.setColumnPinning=r=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(r),e.resetColumnPinning=r=>{var t,s;return e.setColumnPinning(r?At():(t=(s=e.initialState)==null?void 0:s.columnPinning)!=null?t:At())},e.getIsSomeColumnsPinned=r=>{var t;const s=e.getState().columnPinning;if(!r){var i,a;return!!((i=s.left)!=null&&i.length||(a=s.right)!=null&&a.length)}return!!((t=s[r])!=null&&t.length)},e.getLeftLeafColumns=P(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(r,t)=>(t??[]).map(s=>r.find(i=>i.id===s)).filter(Boolean),k(e.options,"debugColumns")),e.getRightLeafColumns=P(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(r,t)=>(t??[]).map(s=>r.find(i=>i.id===s)).filter(Boolean),k(e.options,"debugColumns")),e.getCenterLeafColumns=P(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(r,t,s)=>{const i=[...t??[],...s??[]];return r.filter(a=>!i.includes(a.id))},k(e.options,"debugColumns"))}};function Rr(e){return e||(typeof document<"u"?document:null)}const ot={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Dt=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),br={getDefaultColumnDef:()=>ot,getInitialState:e=>({columnSizing:{},columnSizingInfo:Dt(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:te("columnSizing",e),onColumnSizingInfoChange:te("columnSizingInfo",e)}),createColumn:(e,r)=>{e.getSize=()=>{var t,s,i;const a=r.getState().columnSizing[e.id];return Math.min(Math.max((t=e.columnDef.minSize)!=null?t:ot.minSize,(s=a??e.columnDef.size)!=null?s:ot.size),(i=e.columnDef.maxSize)!=null?i:ot.maxSize)},e.getStart=P(t=>[t,Ke(r,t),r.getState().columnSizing],(t,s)=>s.slice(0,e.getIndex(t)).reduce((i,a)=>i+a.getSize(),0),k(r.options,"debugColumns")),e.getAfter=P(t=>[t,Ke(r,t),r.getState().columnSizing],(t,s)=>s.slice(e.getIndex(t)+1).reduce((i,a)=>i+a.getSize(),0),k(r.options,"debugColumns")),e.resetSize=()=>{r.setColumnSizing(t=>{let{[e.id]:s,...i}=t;return i})},e.getCanResize=()=>{var t,s;return((t=e.columnDef.enableResizing)!=null?t:!0)&&((s=r.options.enableColumnResizing)!=null?s:!0)},e.getIsResizing=()=>r.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,r)=>{e.getSize=()=>{let t=0;const s=i=>{if(i.subHeaders.length)i.subHeaders.forEach(s);else{var a;t+=(a=i.column.getSize())!=null?a:0}};return s(e),t},e.getStart=()=>{if(e.index>0){const t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=t=>{const s=r.getColumn(e.column.id),i=s?.getCanResize();return a=>{if(!s||!i||(a.persist==null||a.persist(),zt(a)&&a.touches&&a.touches.length>1))return;const u=e.getSize(),c=e?e.getLeafHeaders().map(p=>[p.column.id,p.column.getSize()]):[[s.id,s.getSize()]],m=zt(a)?Math.round(a.touches[0].clientX):a.clientX,d={},o=(p,R)=>{typeof R=="number"&&(r.setColumnSizingInfo(j=>{var _,$;const b=r.options.columnResizeDirection==="rtl"?-1:1,z=(R-((_=j?.startOffset)!=null?_:0))*b,V=Math.max(z/(($=j?.startSize)!=null?$:0),-.999999);return j.columnSizingStart.forEach(A=>{let[W,J]=A;d[W]=Math.round(Math.max(J+J*V,0)*100)/100}),{...j,deltaOffset:z,deltaPercentage:V}}),(r.options.columnResizeMode==="onChange"||p==="end")&&r.setColumnSizing(j=>({...j,...d})))},C=p=>o("move",p),w=p=>{o("end",p),r.setColumnSizingInfo(R=>({...R,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},h=Rr(t),y={moveHandler:p=>C(p.clientX),upHandler:p=>{h?.removeEventListener("mousemove",y.moveHandler),h?.removeEventListener("mouseup",y.upHandler),w(p.clientX)}},x={moveHandler:p=>(p.cancelable&&(p.preventDefault(),p.stopPropagation()),C(p.touches[0].clientX),!1),upHandler:p=>{var R;h?.removeEventListener("touchmove",x.moveHandler),h?.removeEventListener("touchend",x.upHandler),p.cancelable&&(p.preventDefault(),p.stopPropagation()),w((R=p.touches[0])==null?void 0:R.clientX)}},N=Fr()?{passive:!1}:!1;zt(a)?(h?.addEventListener("touchmove",x.moveHandler,N),h?.addEventListener("touchend",x.upHandler,N)):(h?.addEventListener("mousemove",y.moveHandler,N),h?.addEventListener("mouseup",y.upHandler,N)),r.setColumnSizingInfo(p=>({...p,startOffset:m,startSize:u,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:s.id}))}}},createTable:e=>{e.setColumnSizing=r=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(r),e.setColumnSizingInfo=r=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(r),e.resetColumnSizing=r=>{var t;e.setColumnSizing(r?{}:(t=e.initialState.columnSizing)!=null?t:{})},e.resetHeaderSizeInfo=r=>{var t;e.setColumnSizingInfo(r?Dt():(t=e.initialState.columnSizingInfo)!=null?t:Dt())},e.getTotalSize=()=>{var r,t;return(r=(t=e.getHeaderGroups()[0])==null?void 0:t.headers.reduce((s,i)=>s+i.getSize(),0))!=null?r:0},e.getLeftTotalSize=()=>{var r,t;return(r=(t=e.getLeftHeaderGroups()[0])==null?void 0:t.headers.reduce((s,i)=>s+i.getSize(),0))!=null?r:0},e.getCenterTotalSize=()=>{var r,t;return(r=(t=e.getCenterHeaderGroups()[0])==null?void 0:t.headers.reduce((s,i)=>s+i.getSize(),0))!=null?r:0},e.getRightTotalSize=()=>{var r,t;return(r=(t=e.getRightHeaderGroups()[0])==null?void 0:t.headers.reduce((s,i)=>s+i.getSize(),0))!=null?r:0}}};let at=null;function Fr(){if(typeof at=="boolean")return at;let e=!1;try{const r={get passive(){return e=!0,!1}},t=()=>{};window.addEventListener("test",t,r),window.removeEventListener("test",t)}catch{e=!1}return at=e,at}function zt(e){return e.type==="touchstart"}const $r={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:te("columnVisibility",e)}),createColumn:(e,r)=>{e.toggleVisibility=t=>{e.getCanHide()&&r.setColumnVisibility(s=>({...s,[e.id]:t??!e.getIsVisible()}))},e.getIsVisible=()=>{var t,s;const i=e.columns;return(t=i.length?i.some(a=>a.getIsVisible()):(s=r.getState().columnVisibility)==null?void 0:s[e.id])!=null?t:!0},e.getCanHide=()=>{var t,s;return((t=e.columnDef.enableHiding)!=null?t:!0)&&((s=r.options.enableHiding)!=null?s:!0)},e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,r)=>{e._getAllVisibleCells=P(()=>[e.getAllCells(),r.getState().columnVisibility],t=>t.filter(s=>s.column.getIsVisible()),k(r.options,"debugRows")),e.getVisibleCells=P(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(t,s,i)=>[...t,...s,...i],k(r.options,"debugRows"))},createTable:e=>{const r=(t,s)=>P(()=>[s(),s().filter(i=>i.getIsVisible()).map(i=>i.id).join("_")],i=>i.filter(a=>a.getIsVisible==null?void 0:a.getIsVisible()),k(e.options,"debugColumns"));e.getVisibleFlatColumns=r("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=r("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=r("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=r("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=r("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{var s;e.setColumnVisibility(t?{}:(s=e.initialState.columnVisibility)!=null?s:{})},e.toggleAllColumnsVisible=t=>{var s;t=(s=t)!=null?s:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((i,a)=>({...i,[a.id]:t||!(a.getCanHide!=null&&a.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(t=>!(t.getIsVisible!=null&&t.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(t=>t.getIsVisible==null?void 0:t.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{var s;e.toggleAllColumnsVisible((s=t.target)==null?void 0:s.checked)}}};function Ke(e,r){return r?r==="center"?e.getCenterVisibleLeafColumns():r==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const _r={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},Ir={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:te("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:r=>{var t;const s=(t=e.getCoreRowModel().flatRows[0])==null||(t=t._getAllCellsByColumnId()[r.id])==null?void 0:t.getValue();return typeof s=="string"||typeof s=="number"}}),createColumn:(e,r)=>{e.getCanGlobalFilter=()=>{var t,s,i,a;return((t=e.columnDef.enableGlobalFilter)!=null?t:!0)&&((s=r.options.enableGlobalFilter)!=null?s:!0)&&((i=r.options.enableFilters)!=null?i:!0)&&((a=r.options.getColumnCanGlobalFilter==null?void 0:r.options.getColumnCanGlobalFilter(e))!=null?a:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>fe.includesString,e.getGlobalFilterFn=()=>{var r,t;const{globalFilterFn:s}=e.options;return ft(s)?s:s==="auto"?e.getGlobalAutoFilterFn():(r=(t=e.options.filterFns)==null?void 0:t[s])!=null?r:fe[s]},e.setGlobalFilter=r=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(r)},e.resetGlobalFilter=r=>{e.setGlobalFilter(r?void 0:e.initialState.globalFilter)}}},Er={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:te("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let r=!1,t=!1;e._autoResetExpanded=()=>{var s,i;if(!r){e._queue(()=>{r=!0});return}if((s=(i=e.options.autoResetAll)!=null?i:e.options.autoResetExpanded)!=null?s:!e.options.manualExpanding){if(t)return;t=!0,e._queue(()=>{e.resetExpanded(),t=!1})}},e.setExpanded=s=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(s),e.toggleAllRowsExpanded=s=>{s??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=s=>{var i,a;e.setExpanded(s?{}:(i=(a=e.initialState)==null?void 0:a.expanded)!=null?i:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(s=>s.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>s=>{s.persist==null||s.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const s=e.getState().expanded;return s===!0||Object.values(s).some(Boolean)},e.getIsAllRowsExpanded=()=>{const s=e.getState().expanded;return typeof s=="boolean"?s===!0:!(!Object.keys(s).length||e.getRowModel().flatRows.some(i=>!i.getIsExpanded()))},e.getExpandedDepth=()=>{let s=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(a=>{const u=a.split(".");s=Math.max(s,u.length)}),s},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,r)=>{e.toggleExpanded=t=>{r.setExpanded(s=>{var i;const a=s===!0?!0:!!(s!=null&&s[e.id]);let u={};if(s===!0?Object.keys(r.getRowModel().rowsById).forEach(c=>{u[c]=!0}):u=s,t=(i=t)!=null?i:!a,!a&&t)return{...u,[e.id]:!0};if(a&&!t){const{[e.id]:c,...m}=u;return m}return s})},e.getIsExpanded=()=>{var t;const s=r.getState().expanded;return!!((t=r.options.getIsRowExpanded==null?void 0:r.options.getIsRowExpanded(e))!=null?t:s===!0||s?.[e.id])},e.getCanExpand=()=>{var t,s,i;return(t=r.options.getRowCanExpand==null?void 0:r.options.getRowCanExpand(e))!=null?t:((s=r.options.enableExpanding)!=null?s:!0)&&!!((i=e.subRows)!=null&&i.length)},e.getIsAllParentsExpanded=()=>{let t=!0,s=e;for(;t&&s.parentId;)s=r.getRow(s.parentId,!0),t=s.getIsExpanded();return t},e.getToggleExpandedHandler=()=>{const t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},Kt=0,Wt=10,Lt=()=>({pageIndex:Kt,pageSize:Wt}),Mr={getInitialState:e=>({...e,pagination:{...Lt(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:te("pagination",e)}),createTable:e=>{let r=!1,t=!1;e._autoResetPageIndex=()=>{var s,i;if(!r){e._queue(()=>{r=!0});return}if((s=(i=e.options.autoResetAll)!=null?i:e.options.autoResetPageIndex)!=null?s:!e.options.manualPagination){if(t)return;t=!0,e._queue(()=>{e.resetPageIndex(),t=!1})}},e.setPagination=s=>{const i=a=>we(s,a);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(i)},e.resetPagination=s=>{var i;e.setPagination(s?Lt():(i=e.initialState.pagination)!=null?i:Lt())},e.setPageIndex=s=>{e.setPagination(i=>{let a=we(s,i.pageIndex);const u=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return a=Math.max(0,Math.min(a,u)),{...i,pageIndex:a}})},e.resetPageIndex=s=>{var i,a;e.setPageIndex(s?Kt:(i=(a=e.initialState)==null||(a=a.pagination)==null?void 0:a.pageIndex)!=null?i:Kt)},e.resetPageSize=s=>{var i,a;e.setPageSize(s?Wt:(i=(a=e.initialState)==null||(a=a.pagination)==null?void 0:a.pageSize)!=null?i:Wt)},e.setPageSize=s=>{e.setPagination(i=>{const a=Math.max(1,we(s,i.pageSize)),u=i.pageSize*i.pageIndex,c=Math.floor(u/a);return{...i,pageIndex:c,pageSize:a}})},e.setPageCount=s=>e.setPagination(i=>{var a;let u=we(s,(a=e.options.pageCount)!=null?a:-1);return typeof u=="number"&&(u=Math.max(-1,u)),{...i,pageCount:u}}),e.getPageOptions=P(()=>[e.getPageCount()],s=>{let i=[];return s&&s>0&&(i=[...new Array(s)].fill(null).map((a,u)=>u)),i},k(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:s}=e.getState().pagination,i=e.getPageCount();return i===-1?!0:i===0?!1:s<i-1},e.previousPage=()=>e.setPageIndex(s=>s-1),e.nextPage=()=>e.setPageIndex(s=>s+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var s;return(s=e.options.pageCount)!=null?s:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var s;return(s=e.options.rowCount)!=null?s:e.getPrePaginationRowModel().rows.length}}},Ht=()=>({top:[],bottom:[]}),Pr={getInitialState:e=>({rowPinning:Ht(),...e}),getDefaultOptions:e=>({onRowPinningChange:te("rowPinning",e)}),createRow:(e,r)=>{e.pin=(t,s,i)=>{const a=s?e.getLeafRows().map(m=>{let{id:d}=m;return d}):[],u=i?e.getParentRows().map(m=>{let{id:d}=m;return d}):[],c=new Set([...u,e.id,...a]);r.setRowPinning(m=>{var d,o;if(t==="bottom"){var C,w;return{top:((C=m?.top)!=null?C:[]).filter(x=>!(c!=null&&c.has(x))),bottom:[...((w=m?.bottom)!=null?w:[]).filter(x=>!(c!=null&&c.has(x))),...Array.from(c)]}}if(t==="top"){var h,y;return{top:[...((h=m?.top)!=null?h:[]).filter(x=>!(c!=null&&c.has(x))),...Array.from(c)],bottom:((y=m?.bottom)!=null?y:[]).filter(x=>!(c!=null&&c.has(x)))}}return{top:((d=m?.top)!=null?d:[]).filter(x=>!(c!=null&&c.has(x))),bottom:((o=m?.bottom)!=null?o:[]).filter(x=>!(c!=null&&c.has(x)))}})},e.getCanPin=()=>{var t;const{enableRowPinning:s,enablePinning:i}=r.options;return typeof s=="function"?s(e):(t=s??i)!=null?t:!0},e.getIsPinned=()=>{const t=[e.id],{top:s,bottom:i}=r.getState().rowPinning,a=t.some(c=>s?.includes(c)),u=t.some(c=>i?.includes(c));return a?"top":u?"bottom":!1},e.getPinnedIndex=()=>{var t,s;const i=e.getIsPinned();if(!i)return-1;const a=(t=i==="top"?r.getTopRows():r.getBottomRows())==null?void 0:t.map(u=>{let{id:c}=u;return c});return(s=a?.indexOf(e.id))!=null?s:-1}},createTable:e=>{e.setRowPinning=r=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(r),e.resetRowPinning=r=>{var t,s;return e.setRowPinning(r?Ht():(t=(s=e.initialState)==null?void 0:s.rowPinning)!=null?t:Ht())},e.getIsSomeRowsPinned=r=>{var t;const s=e.getState().rowPinning;if(!r){var i,a;return!!((i=s.top)!=null&&i.length||(a=s.bottom)!=null&&a.length)}return!!((t=s[r])!=null&&t.length)},e._getPinnedRows=(r,t,s)=>{var i;return((i=e.options.keepPinnedRows)==null||i?(t??[]).map(u=>{const c=e.getRow(u,!0);return c.getIsAllParentsExpanded()?c:null}):(t??[]).map(u=>r.find(c=>c.id===u))).filter(Boolean).map(u=>({...u,position:s}))},e.getTopRows=P(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(r,t)=>e._getPinnedRows(r,t,"top"),k(e.options,"debugRows")),e.getBottomRows=P(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(r,t)=>e._getPinnedRows(r,t,"bottom"),k(e.options,"debugRows")),e.getCenterRows=P(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(r,t,s)=>{const i=new Set([...t??[],...s??[]]);return r.filter(a=>!i.has(a.id))},k(e.options,"debugRows"))}},kr={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:te("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=r=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(r),e.resetRowSelection=r=>{var t;return e.setRowSelection(r?{}:(t=e.initialState.rowSelection)!=null?t:{})},e.toggleAllRowsSelected=r=>{e.setRowSelection(t=>{r=typeof r<"u"?r:!e.getIsAllRowsSelected();const s={...t},i=e.getPreGroupedRowModel().flatRows;return r?i.forEach(a=>{a.getCanSelect()&&(s[a.id]=!0)}):i.forEach(a=>{delete s[a.id]}),s})},e.toggleAllPageRowsSelected=r=>e.setRowSelection(t=>{const s=typeof r<"u"?r:!e.getIsAllPageRowsSelected(),i={...t};return e.getRowModel().rows.forEach(a=>{Xt(i,a.id,s,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=P(()=>[e.getState().rowSelection,e.getCoreRowModel()],(r,t)=>Object.keys(r).length?Tt(e,t):{rows:[],flatRows:[],rowsById:{}},k(e.options,"debugTable")),e.getFilteredSelectedRowModel=P(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(r,t)=>Object.keys(r).length?Tt(e,t):{rows:[],flatRows:[],rowsById:{}},k(e.options,"debugTable")),e.getGroupedSelectedRowModel=P(()=>[e.getState().rowSelection,e.getSortedRowModel()],(r,t)=>Object.keys(r).length?Tt(e,t):{rows:[],flatRows:[],rowsById:{}},k(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const r=e.getFilteredRowModel().flatRows,{rowSelection:t}=e.getState();let s=!!(r.length&&Object.keys(t).length);return s&&r.some(i=>i.getCanSelect()&&!t[i.id])&&(s=!1),s},e.getIsAllPageRowsSelected=()=>{const r=e.getPaginationRowModel().flatRows.filter(i=>i.getCanSelect()),{rowSelection:t}=e.getState();let s=!!r.length;return s&&r.some(i=>!t[i.id])&&(s=!1),s},e.getIsSomeRowsSelected=()=>{var r;const t=Object.keys((r=e.getState().rowSelection)!=null?r:{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const r=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:r.filter(t=>t.getCanSelect()).some(t=>t.getIsSelected()||t.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>r=>{e.toggleAllRowsSelected(r.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>r=>{e.toggleAllPageRowsSelected(r.target.checked)}},createRow:(e,r)=>{e.toggleSelected=(t,s)=>{const i=e.getIsSelected();r.setRowSelection(a=>{var u;if(t=typeof t<"u"?t:!i,e.getCanSelect()&&i===t)return a;const c={...a};return Xt(c,e.id,t,(u=s?.selectChildren)!=null?u:!0,r),c})},e.getIsSelected=()=>{const{rowSelection:t}=r.getState();return nn(e,t)},e.getIsSomeSelected=()=>{const{rowSelection:t}=r.getState();return Yt(e,t)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=r.getState();return Yt(e,t)==="all"},e.getCanSelect=()=>{var t;return typeof r.options.enableRowSelection=="function"?r.options.enableRowSelection(e):(t=r.options.enableRowSelection)!=null?t:!0},e.getCanSelectSubRows=()=>{var t;return typeof r.options.enableSubRowSelection=="function"?r.options.enableSubRowSelection(e):(t=r.options.enableSubRowSelection)!=null?t:!0},e.getCanMultiSelect=()=>{var t;return typeof r.options.enableMultiRowSelection=="function"?r.options.enableMultiRowSelection(e):(t=r.options.enableMultiRowSelection)!=null?t:!0},e.getToggleSelectedHandler=()=>{const t=e.getCanSelect();return s=>{var i;t&&e.toggleSelected((i=s.target)==null?void 0:i.checked)}}}},Xt=(e,r,t,s,i)=>{var a;const u=i.getRow(r,!0);t?(u.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),u.getCanSelect()&&(e[r]=!0)):delete e[r],s&&(a=u.subRows)!=null&&a.length&&u.getCanSelectSubRows()&&u.subRows.forEach(c=>Xt(e,c.id,t,s,i))};function Tt(e,r){const t=e.getState().rowSelection,s=[],i={},a=function(u,c){return u.map(m=>{var d;const o=nn(m,t);if(o&&(s.push(m),i[m.id]=m),(d=m.subRows)!=null&&d.length&&(m={...m,subRows:a(m.subRows)}),o)return m}).filter(Boolean)};return{rows:a(r.rows),flatRows:s,rowsById:i}}function nn(e,r){var t;return(t=r[e.id])!=null?t:!1}function Yt(e,r,t){var s;if(!((s=e.subRows)!=null&&s.length))return!1;let i=!0,a=!1;return e.subRows.forEach(u=>{if(!(a&&!i)&&(u.getCanSelect()&&(nn(u,r)?a=!0:i=!1),u.subRows&&u.subRows.length)){const c=Yt(u,r);c==="all"?a=!0:(c==="some"&&(a=!0),i=!1)}}),i?"all":a?"some":!1}const Jt=/([0-9]+)/gm,Vr=(e,r,t)=>ns(Se(e.getValue(t)).toLowerCase(),Se(r.getValue(t)).toLowerCase()),Ar=(e,r,t)=>ns(Se(e.getValue(t)),Se(r.getValue(t))),Dr=(e,r,t)=>sn(Se(e.getValue(t)).toLowerCase(),Se(r.getValue(t)).toLowerCase()),zr=(e,r,t)=>sn(Se(e.getValue(t)),Se(r.getValue(t))),Lr=(e,r,t)=>{const s=e.getValue(t),i=r.getValue(t);return s>i?1:s<i?-1:0},Hr=(e,r,t)=>sn(e.getValue(t),r.getValue(t));function sn(e,r){return e===r?0:e>r?1:-1}function Se(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function ns(e,r){const t=e.split(Jt).filter(Boolean),s=r.split(Jt).filter(Boolean);for(;t.length&&s.length;){const i=t.shift(),a=s.shift(),u=parseInt(i,10),c=parseInt(a,10),m=[u,c].sort();if(isNaN(m[0])){if(i>a)return 1;if(a>i)return-1;continue}if(isNaN(m[1]))return isNaN(u)?-1:1;if(u>c)return 1;if(c>u)return-1}return t.length-s.length}const Ge={alphanumeric:Vr,alphanumericCaseSensitive:Ar,text:Dr,textCaseSensitive:zr,datetime:Lr,basic:Hr},Tr={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:te("sorting",e),isMultiSortEvent:r=>r.shiftKey}),createColumn:(e,r)=>{e.getAutoSortingFn=()=>{const t=r.getFilteredRowModel().flatRows.slice(10);let s=!1;for(const i of t){const a=i?.getValue(e.id);if(Object.prototype.toString.call(a)==="[object Date]")return Ge.datetime;if(typeof a=="string"&&(s=!0,a.split(Jt).length>1))return Ge.alphanumeric}return s?Ge.text:Ge.basic},e.getAutoSortDir=()=>{const t=r.getFilteredRowModel().flatRows[0];return typeof t?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var t,s;if(!e)throw new Error;return ft(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(t=(s=r.options.sortingFns)==null?void 0:s[e.columnDef.sortingFn])!=null?t:Ge[e.columnDef.sortingFn]},e.toggleSorting=(t,s)=>{const i=e.getNextSortingOrder(),a=typeof t<"u"&&t!==null;r.setSorting(u=>{const c=u?.find(h=>h.id===e.id),m=u?.findIndex(h=>h.id===e.id);let d=[],o,C=a?t:i==="desc";if(u!=null&&u.length&&e.getCanMultiSort()&&s?c?o="toggle":o="add":u!=null&&u.length&&m!==u.length-1?o="replace":c?o="toggle":o="replace",o==="toggle"&&(a||i||(o="remove")),o==="add"){var w;d=[...u,{id:e.id,desc:C}],d.splice(0,d.length-((w=r.options.maxMultiSortColCount)!=null?w:Number.MAX_SAFE_INTEGER))}else o==="toggle"?d=u.map(h=>h.id===e.id?{...h,desc:C}:h):o==="remove"?d=u.filter(h=>h.id!==e.id):d=[{id:e.id,desc:C}];return d})},e.getFirstSortDir=()=>{var t,s;return((t=(s=e.columnDef.sortDescFirst)!=null?s:r.options.sortDescFirst)!=null?t:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=t=>{var s,i;const a=e.getFirstSortDir(),u=e.getIsSorted();return u?u!==a&&((s=r.options.enableSortingRemoval)==null||s)&&(!(t&&(i=r.options.enableMultiRemove)!=null)||i)?!1:u==="desc"?"asc":"desc":a},e.getCanSort=()=>{var t,s;return((t=e.columnDef.enableSorting)!=null?t:!0)&&((s=r.options.enableSorting)!=null?s:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var t,s;return(t=(s=e.columnDef.enableMultiSort)!=null?s:r.options.enableMultiSort)!=null?t:!!e.accessorFn},e.getIsSorted=()=>{var t;const s=(t=r.getState().sorting)==null?void 0:t.find(i=>i.id===e.id);return s?s.desc?"desc":"asc":!1},e.getSortIndex=()=>{var t,s;return(t=(s=r.getState().sorting)==null?void 0:s.findIndex(i=>i.id===e.id))!=null?t:-1},e.clearSorting=()=>{r.setSorting(t=>t!=null&&t.length?t.filter(s=>s.id!==e.id):[])},e.getToggleSortingHandler=()=>{const t=e.getCanSort();return s=>{t&&(s.persist==null||s.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?r.options.isMultiSortEvent==null?void 0:r.options.isMultiSortEvent(s):!1))}}},createTable:e=>{e.setSorting=r=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(r),e.resetSorting=r=>{var t,s;e.setSorting(r?[]:(t=(s=e.initialState)==null?void 0:s.sorting)!=null?t:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},Or=[ar,$r,jr,Nr,cr,dr,_r,Ir,Tr,Sr,Er,Mr,Pr,kr,br];function Gr(e){var r,t;const s=[...Or,...(r=e._features)!=null?r:[]];let i={_features:s};const a=i._features.reduce((w,h)=>Object.assign(w,h.getDefaultOptions==null?void 0:h.getDefaultOptions(i)),{}),u=w=>i.options.mergeOptions?i.options.mergeOptions(a,w):{...a,...w};let m={...{},...(t=e.initialState)!=null?t:{}};i._features.forEach(w=>{var h;m=(h=w.getInitialState==null?void 0:w.getInitialState(m))!=null?h:m});const d=[];let o=!1;const C={_features:s,options:{...a,...e},initialState:m,_queue:w=>{d.push(w),o||(o=!0,Promise.resolve().then(()=>{for(;d.length;)d.shift()();o=!1}).catch(h=>setTimeout(()=>{throw h})))},reset:()=>{i.setState(i.initialState)},setOptions:w=>{const h=we(w,i.options);i.options=u(h)},getState:()=>i.options.state,setState:w=>{i.options.onStateChange==null||i.options.onStateChange(w)},_getRowId:(w,h,y)=>{var x;return(x=i.options.getRowId==null?void 0:i.options.getRowId(w,h,y))!=null?x:`${y?[y.id,h].join("."):h}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(w,h)=>{let y=(h?i.getPrePaginationRowModel():i.getRowModel()).rowsById[w];if(!y&&(y=i.getCoreRowModel().rowsById[w],!y))throw new Error;return y},_getDefaultColumnDef:P(()=>[i.options.defaultColumn],w=>{var h;return w=(h=w)!=null?h:{},{header:y=>{const x=y.header.column.columnDef;return x.accessorKey?x.accessorKey:x.accessorFn?x.id:null},cell:y=>{var x,N;return(x=(N=y.renderValue())==null||N.toString==null?void 0:N.toString())!=null?x:null},...i._features.reduce((y,x)=>Object.assign(y,x.getDefaultColumnDef==null?void 0:x.getDefaultColumnDef()),{}),...w}},k(e,"debugColumns")),_getColumnDefs:()=>i.options.columns,getAllColumns:P(()=>[i._getColumnDefs()],w=>{const h=function(y,x,N){return N===void 0&&(N=0),y.map(p=>{const R=or(i,p,N,x),j=p;return R.columns=j.columns?h(j.columns,R,N+1):[],R})};return h(w)},k(e,"debugColumns")),getAllFlatColumns:P(()=>[i.getAllColumns()],w=>w.flatMap(h=>h.getFlatColumns()),k(e,"debugColumns")),_getAllFlatColumnsById:P(()=>[i.getAllFlatColumns()],w=>w.reduce((h,y)=>(h[y.id]=y,h),{}),k(e,"debugColumns")),getAllLeafColumns:P(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(w,h)=>{let y=w.flatMap(x=>x.getLeafColumns());return h(y)},k(e,"debugColumns")),getColumn:w=>i._getAllFlatColumnsById()[w]};Object.assign(i,C);for(let w=0;w<i._features.length;w++){const h=i._features[w];h==null||h.createTable==null||h.createTable(i)}return i}function Br(){return e=>P(()=>[e.options.data],r=>{const t={rows:[],flatRows:[],rowsById:{}},s=function(i,a,u){a===void 0&&(a=0);const c=[];for(let d=0;d<i.length;d++){const o=ur(e,e._getRowId(i[d],d,u),i[d],d,a,void 0,u?.id);if(t.flatRows.push(o),t.rowsById[o.id]=o,c.push(o),e.options.getSubRows){var m;o.originalSubRows=e.options.getSubRows(i[d],d),(m=o.originalSubRows)!=null&&m.length&&(o.subRows=s(o.originalSubRows,a+1,o))}}return c};return t.rows=s(r),t},k(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function qr(e){const r=[],t=s=>{var i;r.push(s),(i=s.subRows)!=null&&i.length&&s.getIsExpanded()&&s.subRows.forEach(t)};return e.rows.forEach(t),{rows:r,flatRows:e.flatRows,rowsById:e.rowsById}}function Ur(e){return r=>P(()=>[r.getState().pagination,r.getPrePaginationRowModel(),r.options.paginateExpandedRows?void 0:r.getState().expanded],(t,s)=>{if(!s.rows.length)return s;const{pageSize:i,pageIndex:a}=t;let{rows:u,flatRows:c,rowsById:m}=s;const d=i*a,o=d+i;u=u.slice(d,o);let C;r.options.paginateExpandedRows?C={rows:u,flatRows:c,rowsById:m}:C=qr({rows:u,flatRows:c,rowsById:m}),C.flatRows=[];const w=h=>{C.flatRows.push(h),h.subRows.length&&h.subRows.forEach(w)};return C.rows.forEach(w),C},k(r.options,"debugTable"))}function Kr(){return e=>P(()=>[e.getState().sorting,e.getPreSortedRowModel()],(r,t)=>{if(!t.rows.length||!(r!=null&&r.length))return t;const s=e.getState().sorting,i=[],a=s.filter(m=>{var d;return(d=e.getColumn(m.id))==null?void 0:d.getCanSort()}),u={};a.forEach(m=>{const d=e.getColumn(m.id);d&&(u[m.id]={sortUndefined:d.columnDef.sortUndefined,invertSorting:d.columnDef.invertSorting,sortingFn:d.getSortingFn()})});const c=m=>{const d=m.map(o=>({...o}));return d.sort((o,C)=>{for(let h=0;h<a.length;h+=1){var w;const y=a[h],x=u[y.id],N=x.sortUndefined,p=(w=y?.desc)!=null?w:!1;let R=0;if(N){const j=o.getValue(y.id),_=C.getValue(y.id),$=j===void 0,b=_===void 0;if($||b){if(N==="first")return $?-1:1;if(N==="last")return $?1:-1;R=$&&b?0:$?N:-N}}if(R===0&&(R=x.sortingFn(o,C,y.id)),R!==0)return p&&(R*=-1),x.invertSorting&&(R*=-1),R}return o.index-C.index}),d.forEach(o=>{var C;i.push(o),(C=o.subRows)!=null&&C.length&&(o.subRows=c(o.subRows))}),d};return{rows:c(t.rows),flatRows:i,rowsById:t.rowsById}},k(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Ot(e,r){return e?Wr(e)?v.createElement(e,r):e:null}function Wr(e){return Xr(e)||typeof e=="function"||Yr(e)}function Xr(e){return typeof e=="function"&&(()=>{const r=Object.getPrototypeOf(e);return r.prototype&&r.prototype.isReactComponent})()}function Yr(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Jr(e){const r={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[t]=v.useState(()=>({current:Gr(r)})),[s,i]=v.useState(()=>t.current.initialState);return t.current.setOptions(a=>({...a,...e,state:{...s,...e.state},onStateChange:u=>{i(u),e.onStateChange==null||e.onStateChange(u)}})),t.current}const Qr={visible:!1,top:0,left:0,width:0,tableWidth:0,headerHeight:0,scrollLeft:0,columnWidths:[]};function Zr(e){let r=e?.parentElement??null;for(;r;){const t=window.getComputedStyle(r).overflowY;if((t==="auto"||t==="scroll")&&r.scrollHeight>r.clientHeight)return r;r=r.parentElement}return null}function ei(e,r){return e.visible===r.visible&&e.top===r.top&&e.left===r.left&&e.width===r.width&&e.tableWidth===r.tableWidth&&e.headerHeight===r.headerHeight&&e.scrollLeft===r.scrollLeft&&e.columnWidths.length===r.columnWidths.length&&e.columnWidths.every((t,s)=>t===r.columnWidths[s])}function ti({columns:e,data:r,notFoundContent:t,globalSearch:s=!1,onGlobalSearch:i,searchValue:a,handleSearch:u,searchTxt:c,columnVisibility:m,onColumnVisibilityChange:d,columnVisibilityLabel:o,footer:C}){const w=v.useRef(null),h=v.useRef(null),y=v.useRef(null),[x,N]=v.useState(Qr),p=Jr({data:r,columns:e,state:{columnVisibility:m},onColumnVisibilityChange:d,getCoreRowModel:Br(),getPaginationRowModel:Ur(),getSortedRowModel:Kr(),enableSorting:!1,manualPagination:!0});v.useEffect(()=>{const j=w.current,_=h.current;if(!j||!_)return;const $=j.querySelector('table[data-slot="table"]'),b=Zr(j),z=()=>{if(!$)return;const W=_.getBoundingClientRect(),J=$.getBoundingClientRect(),D=j.getBoundingClientRect(),B=b?.getBoundingClientRect().top??0,X=b?.getBoundingClientRect().bottom??window.innerHeight,G=W.height,H={visible:W.top<B&&J.bottom>B+G&&J.top<X,top:Math.max(B,0),left:D.left,width:D.width,tableWidth:$.getBoundingClientRect().width,headerHeight:G,scrollLeft:j.scrollLeft,columnWidths:Array.from(_.querySelectorAll("th")).map(q=>q.getBoundingClientRect().width)};N(q=>ei(q,H)?q:H)},V=()=>{y.current!==null&&window.cancelAnimationFrame(y.current),y.current=window.requestAnimationFrame(z)};z(),b?.addEventListener("scroll",V,{passive:!0}),j.addEventListener("scroll",V,{passive:!0}),window.addEventListener("scroll",V,{passive:!0}),window.addEventListener("resize",V);const A=new ResizeObserver(V);return A.observe(j),A.observe(_),A.observe($),()=>{y.current!==null&&window.cancelAnimationFrame(y.current),b?.removeEventListener("scroll",V),j.removeEventListener("scroll",V),window.removeEventListener("scroll",V),window.removeEventListener("resize",V),A.disconnect()}},[e,r,m]);const R=({display:j="label",align:_="start",side:$="bottom"}={})=>n.jsxs(ct,{children:[n.jsx(dt,{asChild:!0,children:n.jsxs(M,{variant:"outline",size:j==="icon"?"icon":"sm",title:o,children:[n.jsx(de,{iconNode:Gt,className:j==="icon"?"size-5":"size-4"}),j==="label"&&o]})}),n.jsxs(gt,{align:_,side:$,className:"w-56",children:[n.jsx(ks,{children:o}),n.jsx(Bn,{}),p.getAllLeafColumns().filter(b=>b.getCanHide()).map(b=>n.jsx(Vs,{className:"capitalize",checked:b.getIsVisible(),onCheckedChange:z=>b.toggleVisibility(!!z),children:String(b.columnDef.meta??b.id)},b.id))]})]});return n.jsxs("div",{className:"flex flex-1 flex-col",children:[n.jsxs("div",{className:"flex flex-none flex-col",children:[s&&i&&n.jsxs("div",{className:"flex gap-2 p-2",children:[!C&&R({display:"icon"}),n.jsx(U,{type:"text",value:a,placeholder:c,className:"w-full max-w-[200px] p-2 border rounded",onChange:j=>{i(j.target.value)},onKeyDown:j=>{j.key==="Enter"&&u&&u()}}),n.jsx(M,{variant:"outline",size:"icon",onClick:u,children:n.jsx(de,{iconNode:Gn,className:"size-5"})})]}),!s&&!C&&n.jsx("div",{className:"flex justify-start p-2",children:R()}),n.jsxs("div",{className:"relative min-h-full flex-1 overflow-hidden rounded-md border bg-background",children:[n.jsxs(Ms,{className:"border-separate border-spacing-0",wrapperHeight:"min-h-full flex-1",ref:w,children:[n.jsx($n,{ref:h,className:"bg-background shadow",children:p.getHeaderGroups().map(j=>n.jsx(it,{className:"transition-none hover:bg-transparent",children:j.headers.map((_,$)=>{const b=[$===0?"rounded-tl-md":"",$===j.headers.length-1?"rounded-tr-md":""].filter(Boolean).join(" ");return n.jsx(_n,{className:`bg-background ${b}`,children:_.isPlaceholder?null:Ot(_.column.columnDef.header,_.getContext())},_.id)})},j.id))}),n.jsx(Ps,{children:p.getRowModel().rows?.length?p.getRowModel().rows.map((j,_)=>n.jsx(it,{"data-state":j.getIsSelected()&&"selected",children:j.getVisibleCells().map(($,b)=>{const z=j.getVisibleCells(),V=_===p.getRowModel().rows.length-1,A=[V&&b===0?"rounded-bl-md":"",V&&b===z.length-1?"rounded-br-md":""].filter(Boolean).join(" "),W=A?"bg-background":"";return n.jsx(In,{className:`${$.column.getIndex()===0?"sticky left-0 bg-background":""} ${A} ${W}`,children:Ot($.column.columnDef.cell,$.getContext())},$.id)})},j.id)):n.jsx(it,{children:n.jsx(In,{colSpan:p.getVisibleLeafColumns().length||e.length,className:"h-24 rounded-b-md bg-background text-center",children:t})})})]}),n.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20 h-px bg-border shadow-[0_1px_0_0_var(--border)]",style:{top:h.current?.getBoundingClientRect().height??void 0}})]}),x.visible&&n.jsx("div",{className:"fixed z-50 overflow-hidden bg-background shadow-md transition-none",style:{top:x.top,left:x.left,width:x.width,height:x.headerHeight},children:n.jsx("div",{className:"transition-none",style:{width:x.tableWidth,transform:`translateX(${-x.scrollLeft}px)`},children:n.jsxs("table",{className:"caption-bottom border-separate border-spacing-0 text-sm transition-none",style:{width:x.tableWidth},children:[n.jsx("colgroup",{children:x.columnWidths.map((j,_)=>n.jsx("col",{style:{width:j}},_))}),n.jsx($n,{className:"bg-background",children:p.getHeaderGroups().map(j=>n.jsx(it,{className:"transition-none hover:bg-transparent",children:j.headers.map(_=>n.jsx(_n,{className:"border-b bg-background shadow-[0_2px_0_0_var(--border)] transition-none",children:_.isPlaceholder?null:Ot(_.column.columnDef.header,_.getContext())},_.id))},j.id))})]})})})]}),C?.(R)]})}function ni(e,r,t,s){const i=Math.ceil(e/r),a=(t-1)*r+1,u=Math.min(t*r,e),c=[];c.push({label:"Previous",active:!1});let m=Math.max(1,t-Math.floor(s/2)),d=Math.min(i,m+s-1);d-m+1<s&&(m=Math.max(1,d-s+1));for(let o=m;o<=d;o++)c.push({label:o.toString(),active:o===t});return c.push({label:"Next",active:!1}),{total:e,per_page:r,current_page:t,last_page:i,next_page_url:t<i?!0:null,prev_page_url:t>1?!0:null,from:a,to:u,links:c,showPages:s}}function si({value:e,fieldName:r,recordId:t,modelName:s,fieldType:i,fieldConfig:a,hasDisplayModifier:u,onUpdateRecord:c}){const[m,d]=v.useState(!1),[o,C]=v.useState(e),[w,h]=v.useState(!1),y=v.useRef(null),N=["string","integer","number","range","boolean","float","email"].includes(i?.toLowerCase()||""),p=a.inlineEditable!==!1,j=new Set(["id","createdAt","updatedAt"]).has(r),_=p&&!j&&!u&&N;v.useEffect(()=>{m&&y.current&&(y.current.focus(),i!=="boolean"&&y.current instanceof HTMLInputElement&&y.current.select())},[m,i]),v.useEffect(()=>{m&&C(e)},[m,e]);const $=v.useCallback(()=>{_&&d(!0)},[_]),b=v.useCallback(async()=>{if(!(!_||w)){if(o===e){d(!1);return}h(!0);try{const D=await ee.patch(`/adminizer/model/${s}/inline/${t}`,{field:r,value:o});D.data.success&&(c(t,r,D.data.data.value),ce.success("Field updated successfully"),d(!1))}catch(D){const B=D.response?.data?.error||"Failed to update field";ce.error(B),C(e),d(!1)}finally{h(!1)}}},[_,w,o,e,s,t,r,c]),z=v.useCallback(()=>{C(e),d(!1)},[e]),V=v.useCallback(D=>{D.key==="Enter"?(D.preventDefault(),b()):D.key==="Escape"&&(D.preventDefault(),z())},[b,z]),A=v.useCallback(()=>{setTimeout(()=>{m&&b()},100)},[m,b]);if(!_){const D=En(e?.toString()??"");return n.jsx("div",{className:"text-center max-w-[300px] overflow-hidden text-ellipsis",dangerouslySetInnerHTML:{__html:D}})}if(i==="boolean")return m?n.jsx("div",{className:"flex items-center justify-center gap-2",children:n.jsx(qe,{checked:!!o,onCheckedChange:D=>C(!!D),onKeyDown:V,onBlur:A,disabled:w,autoFocus:!0})}):n.jsx("div",{className:"text-center max-w-[300px] overflow-hidden text-ellipsis cursor-pointer hover:bg-muted/50 rounded transition-colors",onDoubleClick:$,title:"Double-click to edit",children:e?"✓":"✗"});if(m){const D=ri(i),B=ii(a);return n.jsx("div",{className:"flex items-center gap-1",children:n.jsx(U,{ref:y,type:D,value:o??"",onChange:X=>C(X.target.value),onKeyDown:V,onBlur:A,disabled:w,min:B.min,max:B.max,step:D==="number"?"any":void 0,className:"h-8 text-sm",autoFocus:!0})})}const W=e?.toString()??"",J=En(W);return n.jsx("div",{className:"text-center max-w-[300px] overflow-hidden text-ellipsis cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5 transition-colors",onDoubleClick:$,title:"Double-click to edit",dangerouslySetInnerHTML:{__html:J}})}function ri(e){switch(e){case"integer":case"number":case"float":return"number";case"range":return"number";case"email":return"email";default:return"text"}}function ii(e){const r=e.options;if(r&&typeof r=="object")return{min:r.min,max:r.max};const t=e.inlineValidation;return t?{min:t.min,max:t.max}:{}}function li(e,r,t,s,i,a,u){return v.useMemo(()=>Object.entries(e).map(([c,m])=>({accessorKey:c,meta:m.title,header:()=>n.jsxs("div",{className:`flex flex-col gap-1 text-center max-w-[300px] ${m.direction?"text-chart-1":""}`,children:[n.jsxs(M,{variant:"ghost",className:"cursor-pointer hover:text-inherit",onClick:()=>{if(s){const d=m.direction==="asc"?"desc":"asc";s(m.data,d)}},children:[n.jsx("span",{className:"overflow-hidden text-ellipsis",children:m.title}),m.direction?n.jsx(de,{iconNode:m.direction==="asc"?As:Ds,className:"size-3"}):n.jsx(de,{iconNode:zs,className:"size-3"})]}),u&&i&&n.jsx("input",{type:"text",defaultValue:m.searchColumnValue,"data-column-index":c,className:"text-xs p-1 border rounded mb-2 text-foreground",onChange:d=>{i(m.data,d.target.value)},onKeyDown:d=>{d.key==="Enter"&&a&&a()}})]}),cell:({row:d})=>{const o=d.getValue(c),C=d.original?.id,w=m.type,h=m.hasDisplayModifier||!1;return n.jsx(si,{value:o,fieldName:c,recordId:C,modelName:r,fieldType:w,fieldConfig:m,hasDisplayModifier:h,onUpdateRecord:t})}})),[e,r,t,s,u,i])}function oi({header:e,initialCount:r=String(e.defaultPageSize)}){Qt();const t=v.useMemo(()=>e.pageSizeOptions.map(String),[e.pageSizeOptions]),s=v.useCallback(E=>E&&t.includes(E)?E:r,[t,r]),[i,a]=v.useState(!1),[u,c]=v.useState(""),[m,d]=v.useState(!1),[o,C]=v.useState(1),[w,h]=v.useState(r),[y,x]=v.useState("1"),[N,p]=v.useState("desc"),R=v.useRef([]),j=v.useRef(null),[_,$]=v.useState(0);v.useEffect(()=>{const E=new URLSearchParams(window.location.search);c(E.get("globalSearch")||""),d(!!E.get("globalSearch")),C(parseInt(E.get("page")||"1")),h(s(E.get("count"))),x(E.get("column")||"1"),p(E.get("direction")||"desc");const H=E.getAll("searchColumn"),q=E.getAll("searchColumnValue");R.current=H.map((le,pe)=>({key:le,value:q[pe]}))},[s]),v.useEffect(()=>{document.body.removeAttribute("style")},[]),v.useEffect(()=>{j.current&&setTimeout(()=>{if(j.current?.type==="column"&&j.current.columnIndex){const E=document.querySelector(`input[data-column-index="${j.current.columnIndex}"]`);E&&(E.focus(),E.select())}else if(j.current?.type==="global"){const E=document.querySelector(".flex.gap-2.p-2");if(E){const H=E.querySelector("input");H&&(H.focus(),H.select())}}j.current=null},100)},[_]);const b=v.useCallback((E,H=["data","columns","header"])=>{if(document.activeElement instanceof HTMLElement){const q=document.activeElement.getAttribute("data-column-index");q?j.current={type:"column",columnIndex:q}:document.activeElement.tagName==="INPUT"&&document.activeElement.hasAttribute("placeholder")&&(j.current={type:"global"})}a(!0),Zt.visit(`${e.modelResource.uri}?${E}`,{preserveState:!0,only:H,onSuccess:()=>{a(!1),$(q=>q+1)}})},[e.modelResource.uri]),z=v.useCallback((E,H,q,le)=>{const pe=E!==void 0?E:o,ge=H!==void 0?H:N,Xe=q!==void 0?q:y,Ye=le!==void 0?le:u,ye=new URLSearchParams(window.location.search).get("filterId"),he=ye?`&filterId=${ye}`:"",ae=Xe!=="1"||ge!=="desc"?`&column=${Xe}&direction=${ge}`:"",Je=`count=${w}&page=${pe}`,Qe=Ye?`&globalSearch=${Ye}`:"",Q=R.current.map(K=>`&searchColumn=${K.key}&searchColumnValue=${K.value}`).join("");return`${Je}${ae}${Qe}${Q}${he}`},[w,o,y,N,u]),V=v.useCallback(E=>{const H=s(E);h(H),C(1);const le=new URLSearchParams(window.location.search).get("filterId"),pe=le?`&filterId=${le}`:"";b(`count=${H}&page=1${pe}`)},[b,s]),A=v.useCallback(E=>{C(E),b(z(E))},[z,b]),W=v.useCallback((E,H)=>{x(E),p(H),b(z(void 0,H,E))},[z,b]),J=v.useCallback(E=>{c(E),C(1)},[]),D=v.useCallback(()=>{b(z(1))},[z,b]),B=v.useCallback((E,H)=>{C(1);const q=R.current.findIndex(le=>le.key===E);q>=0&&R.current.splice(q,1),H&&R.current.push({key:E,value:H})},[]),X=v.useCallback(()=>{d(!1),c(""),R.current=[],C(1),x("1"),p("desc"),b(`count=${w}&page=1`)},[w,b]),G=v.useCallback(()=>{m?X():d(!0)},[m,X]);return{loading:i,searchValue:u,showSearch:m,currentPage:o,count:w,sortColumn:y,sortDirection:N,queryColumnsRef:R,changeCount:V,handlePageChange:A,handleCustomSort:W,handleGlobalSearch:J,handleSearch:D,handleColumnSearch:B,resetForm:X,toggleSearch:G,setSearchValue:c,setShowSearch:d,setCurrentPage:C,setCount:h,buildQueryString:z}}function We(e){const{t:r}=Ls();return{t:r,loading:!1}}function ai({modelName:e,onApplyFilter:r,onEditFilter:t,onDeleteFilter:s,activeFilterId:i,user:a}){const[u,c]=v.useState([]),[m,d]=v.useState(!1),{t:o}=We();v.useEffect(()=>{C();const p=()=>{C()};return window.addEventListener("adminizer:filterChanged",p),()=>{window.removeEventListener("adminizer:filterChanged",p)}},[e]);const C=async()=>{d(!0);try{const p=await ee.get(`/adminizer/model/${e}/saved-filters`);c(p.data.filters||[])}catch(p){if(console.error("Error loading saved filters:",p),p.response?.status===401){console.error("Session expired, redirecting to login..."),window.location.href="/adminizer/model/userap/login";return}}finally{d(!1)}},w=p=>{r?.(p)},h=async p=>{try{await ee.delete(`/adminizer/model/${e}/filter/${p.id}`),s?.(p.id),C()}catch(R){if(console.error("Error deleting filter:",R),R.response?.status===401){console.error("Session expired, redirecting to login..."),window.location.href="/adminizer/model/userap/login";return}if(R.response?.status===403){alert(o("No permission to delete filter"));return}}},y=async p=>{try{const _=((await ee.get(`/adminizer/model/${e}/saved-filters`)).data?.filters||[]).find($=>String($.id)===String(p.id));t?.(_||p)}catch(R){console.error("Error loading fresh filter for edit:",R),t?.(p)}},x=p=>!!(a?.isAdministrator||p.ownerId&&a?.id&&p.ownerId===a.id||p.owner&&a?.id&&p.owner.id===a.id||p.ownerInfo&&a?.id&&p.ownerInfo.id===a.id),N=p=>!!p&&/^[a-z0-9_]+$/i.test(p);return m?n.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("Loading filters...")}):u.length===0?n.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:[n.jsx(Bt,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:o("No saved filters")}),n.jsx("p",{className:"text-xs mt-1",children:o("Save current filter for quick access")})]}):n.jsx("div",{className:"space-y-2 py-2",children:u.map(p=>{const R=x(p),j=p.ownerId===a?.id||p.owner?.id===a?.id||p.ownerInfo?.id===a?.id;return n.jsxs("div",{className:ue("flex items-center gap-2 p-2 rounded-md border transition-colors","hover:bg-accent/50",i===p.id&&"bg-accent/70 border-accent"),children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 cursor-pointer",onClick:()=>w(p),children:[p.icon&&n.jsx("span",{className:"h-6 w-6 flex items-center justify-center text-muted-foreground",children:N(p.icon)?n.jsx(Ce,{name:p.icon,className:"!text-[18px]"}):n.jsx("span",{className:"text-lg leading-none",children:p.icon})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"font-medium text-sm truncate",children:p.name}),p.visibility==="private"&&n.jsx("span",{title:j?o("Private filter"):`${o("Someone else's private filter (owner:")} ${p.ownerInfo?.fullName||p.ownerInfo?.login||o("unknown)")}`,children:n.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"})}),p.visibility==="groups"&&n.jsx("span",{title:o("For groups"),children:n.jsx(Re,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"})}),p.visibility==="public"&&n.jsx("span",{title:o("Public filter"),children:n.jsx(qt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"})})]}),p.description&&n.jsx("div",{className:"text-xs text-muted-foreground truncate",children:p.description}),!j&&p.visibility==="private"&&p.ownerInfo&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[o("Owner"),": ",p.ownerInfo.fullName||p.ownerInfo.login]})]})]}),p.resultCount!==void 0&&p.resultCount>=0&&n.jsx(mt,{variant:"secondary",className:"text-xs",children:p.resultCount}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:_=>{_.stopPropagation(),w(p)},title:o("Apply filter"),children:n.jsx(qn,{className:"h-3.5 w-3.5"})}),R&&n.jsxs(n.Fragment,{children:[n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:_=>{_.stopPropagation(),y(p)},title:o("Edit"),children:n.jsx(en,{className:"h-3.5 w-3.5"})}),n.jsx(Kn,{btnTitle:"",delModal:{yes:o("Yes"),no:o("No"),text:`${o("Delete filter")} "${p.name}"?`},handleDelete:()=>{h(p)},isLink:!1,variant:"ghost",btnCLass:"h-7 w-7 p-0 text-destructive hover:text-destructive"})]})]})]},p.id)})})}function zn({groups:e,selectedGroupIds:r,onGroupsChange:t,modelName:s}){const[i,a]=v.useState(!1),{t:u}=We(),c=d=>{r.includes(d)?t(r.filter(o=>o!==d)):t([...r,d])},m=()=>e.filter(d=>r.includes(d.id)).map(d=>d.name);return e.length===0?null:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(Re,{className:"h-4 w-4"}),n.jsx("span",{children:u("Access for groups")})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1.5",children:m().map((d,o)=>n.jsxs(mt,{variant:"secondary",className:"text-xs",children:[d,n.jsx("button",{type:"button",className:"ml-1 hover:text-destructive",onClick:()=>{const C=e.find(w=>w.name===d);C&&c(C.id)},children:n.jsx(Le,{className:"h-3 w-3"})})]},o))}),n.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.map(d=>n.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>c(d.id),children:[n.jsx(qe,{checked:r.includes(d.id),onCheckedChange:()=>c(d.id)}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:d.name}),d.description&&n.jsx("div",{className:"text-xs text-muted-foreground",children:d.description})]})]},d.id))})]})}const ie="temporary",ui="manage-group-filter-visibility",ci=(e,r)=>!e||!Array.isArray(e.groups)?!1:e.groups.some(t=>Array.isArray(t?.tokens)&&t.tokens.includes(r)),di=e=>e||(typeof window>"u"?"/":`${window.location.pathname}${window.location.search}`),Ln=e=>{const r=typeof window<"u"?window.location.origin:"http://localhost";return new URL(di(e),r)},gi=e=>{const r=e.split("/"),t=r.findIndex(s=>s==="model");return t!==-1&&t+1<r.length?r[t+1]:""},mi=e=>{if(!(!e||e==="null"||e==="undefined"))return e},fi=e=>{const r=v.useMemo(()=>{const i=Ln(e);return{modelName:gi(i.pathname),activeFilterId:mi(i.searchParams.get("filterId")),pathname:i.pathname,searchParams:i.searchParams}},[e]),t=v.useCallback(i=>{const a=Ln(e);i?a.searchParams.set("filterId",i):a.searchParams.delete("filterId"),Zt.get(a.pathname,Object.fromEntries(a.searchParams),{preserveState:!0,preserveScroll:!0})},[e]),s=v.useCallback(()=>{t(void 0)},[t]);return{modelName:r.modelName,activeFilterId:r.activeFilterId,setActiveFilterId:t,clearActiveFilter:s}},ut=e=>!e||typeof e!="object"?null:{name:String(e.name||""),conditionCount:typeof e.conditionCount=="number"?e.conditionCount:Array.isArray(e.conditions)?e.conditions.length:0,isModified:!!e.isModified},Be=e=>`temporaryFilter_${e}`,Hn=["filter_alt","bookmark","star","push_pin","search","bolt","favorite","local_offer","list_alt","tune"];function pi({onApplyFilters:e}){const r=Qt(),t=r.props?.auth?.user,s=t?.isAdministrator===!0,i=s||ci(t,ui),a=r.props?.activeFilter,{modelName:u,activeFilterId:c,setActiveFilterId:m,clearActiveFilter:d}=fi(r.url),{t:o}=We(),[C,w]=v.useState([]),[h,y]=v.useState([]),[x,N]=v.useState(""),[p,R]=v.useState(null),[j,_]=v.useState("placeholder"),[$,b]=v.useState(!1),[z,V]=v.useState(null),[A,W]=v.useState({name:"",description:"",icon:"bookmark",color:"#3b82f6"}),[J,D]=v.useState(!1),[B,X]=v.useState(!1),[G,E]=v.useState(""),[H,q]=v.useState(void 0),[le,pe]=v.useState(!1),[ge,Xe]=v.useState([]),[Ye,pt]=v.useState(!1),[ye,he]=v.useState([]),[xe,ae]=v.useState([]),[Je,Qe]=v.useState(""),Q=v.useRef(null),[K,He]=v.useState({name:"",description:"",icon:"bookmark",color:"#3b82f6"}),[Ze,ht]=v.useState(!1),[Te,rn]=v.useState(void 0),[me,je]=v.useState("private"),[ne,Ne]=v.useState("private"),[ln,on]=v.useState([]),[an,un]=v.useState([]),[et,rs]=v.useState([]),[Oe,se]=v.useState("edit"),is=async()=>{pt(!0),Qe("");try{const l=p?.id||(c===ie?ie:void 0);let g=`/adminizer/model/${u}/columns`;l&&(g+=`?filterId=${l}`);const f=await ee.get(g),{availableColumns:S,filterColumns:F,hasFilterConfig:I}=f.data;if(I&&F.length>0){const O=new Map(S.map(Y=>[Y.fieldName,Y])),L=[],re=[],_e=[...F].sort((Y,Ie)=>Y.order-Ie.order);for(const Y of _e){const Ie=O.get(Y.fieldName);Ie&&L.push({...Ie,order:Y.order})}for(const[Y,Ie]of O)L.find(Es=>Es.fieldName===Y)||re.push({...Ie,order:L.length+re.length});ae(L),he(re)}else{const O=S.map((L,re)=>({...L,order:re}));ae(O),he([])}}catch(l){console.error("Error loading columns:",l),Qe(l.response?.data?.error||l.message||o("Error loading columns"))}finally{pt(!1)}},cn=()=>{se("columns"),is()},ls=()=>{const l=xe.map((g,f)=>({...g,order:f}));Xe(l),se("edit")},os=l=>{he(g=>g.filter(f=>f.fieldName!==l.fieldName)),ae(g=>[...g,{...l,order:g.length}])},as=l=>{ae(g=>g.filter(f=>f.fieldName!==l.fieldName)),he(g=>[...g,{...l,order:g.length}])},us=()=>{ae(l=>[...l,...ye.map((g,f)=>({...g,order:l.length+f}))]),he([])},cs=()=>{he(l=>[...l,...xe.map((g,f)=>({...g,order:l.length+f}))]),ae([])},ds=l=>{l!==0&&ae(g=>{const f=[...g];return[f[l-1],f[l]]=[f[l],f[l-1]],f.map((S,F)=>({...S,order:F}))})},gs=l=>{l>=xe.length-1||ae(g=>{const f=[...g];return[f[l],f[l+1]]=[f[l+1],f[l]],f.map((S,F)=>({...S,order:F}))})},[dn,gn]=v.useState(!1),[mn,fn]=v.useState(!1),[pn,hn]=v.useState(!1),xn=v.useRef(null),tt=v.useMemo(()=>new Map(h.map(l=>[l.id,l])),[h]),nt=v.useMemo(()=>new Set(C.map(l=>l.fieldId)),[C]);v.useEffect(()=>{const l=xn.current;l&&(l.modelName!==u||l.activeFilterId!==c)&&(!c||l?.modelName!==u)&&(w([]),N(""),R(null),se("edit")),xn.current={modelName:u,activeFilterId:c}},[c,u]),v.useEffect(()=>{if(!u){b(!1),V(null);return}const l=Be(u),g=sessionStorage.getItem(l);if(!g){const f=c===ie&&a?.id===ie?a:null;if(f){const S=ut(f);b(!!S),V(S),N(S?.name||""),S&&sessionStorage.setItem(l,JSON.stringify(S));return}b(!1),V(null),c===ie&&d();return}try{const f=JSON.parse(g),S=ut(f);if(!S)throw new Error("Invalid temporary filter metadata");V(S),N(S.name),b(!0),Array.isArray(f.conditions)&&sessionStorage.setItem(l,JSON.stringify(S))}catch(f){console.error("Error loading temporary filter:",f),sessionStorage.removeItem(l),b(!1),V(null),c===ie&&d()}},[a,c,d,u]),v.useEffect(()=>{(async()=>{try{if(!u){console.error("Could not find modelResource in URL");return}const f=(await ee.get(`/adminizer/model/${u}/filter-fields`)).data;y(f.fields||[])}catch(g){console.error("Error loading filter fields:",g)}})()},[u]),v.useEffect(()=>{(async()=>{if(i)try{const g=await ee.get("/adminizer/groups");rs(g.data.groups||[])}catch(g){console.error("Error loading groups:",g)}})()},[i]),v.useEffect(()=>(window.adminizerFilterPanel={openFilterDialog:()=>ms(),openSaveFilterDialog:()=>handleOpenSaveDialog(),openEditCurrentFilter:l=>fs(l),getModelName:()=>u,getActiveFilterId:()=>c,hasTemporaryFilter:()=>$},()=>{delete window.adminizerFilterPanel}),[u,c,$]);const ms=()=>{se("edit"),Q.current?.open()},fs=async l=>{const g=l||c;if(!(!g||!u)){if(g==="temporary"){Cn();return}se("edit"),Q.current?.open();try{const F=((await ee.get(`/adminizer/model/${u}/saved-filters`)).data?.filters||[]).find(I=>String(I.id)===String(g));if(!F)return;Nn(F)}catch(f){console.error("Error loading filter for edit:",f)}}},vn=()=>c!==ie||a?.id!==ie?null:{name:a.name,conditions:Array.isArray(a.conditions)?a.conditions:[],columns:a.columns},wn=async()=>{if(!u)return null;try{const g=(await ee.get(`/adminizer/model/${u}/filter/temporary`)).data?.filter;return g?{name:g.name,conditions:g.conditions||[],columns:g.columns}:vn()}catch(l){return l.response?.status===404?(sessionStorage.removeItem(Be(u)),b(!1),V(null)):console.error("Error loading temporary filter:",l),vn()}},Cn=async()=>{const l=await wn();if(l){const g=ut(l);se("edit"),R(null),V(g),N(l.name),$e({conditions:l.conditions}),Q.current?.open(),requestAnimationFrame(()=>{Q.current?.next()})}},ps=()=>{m(ie),Q.current?.close(),window.dispatchEvent(new CustomEvent("adminizer:filterChanged"))},hs=async()=>{if(C.length===0){const l=await wn();if(l){$e({conditions:l.conditions});const g=ut(l);V(g),N(l.name)}}W({name:"",description:"",icon:"bookmark",color:"#3b82f6"}),je("private"),on([]),D(!1),E(""),se("save"),Sn(),Q.current?.next()},Sn=async()=>{if(!H)try{const l=await ee.get("/adminizer/api/user-key");q(l.data.apiKey)}catch(l){console.error("Failed to load user API key:",l)}},yn=()=>`${window.location.origin}/adminizer/api/feed`,xs=()=>`${yn()}/${Te||"..."}.json?userKey=${H||"..."}`,vs=()=>`${yn()}/${Te||"..."}.xml?userKey=${H||"..."}`,jn=async(l,g)=>{try{await navigator.clipboard.writeText(l),ce.success(`${g} ${o("copied to clipboard")}`)}catch{ce.error(o("Failed to copy"))}},xt=l=>Array.isArray(l)?l.map(g=>xt(g)):l instanceof Date?l.toISOString():l&&typeof l=="object"?Object.fromEntries(Object.entries(l).map(([g,f])=>[g,xt(f)])):l,Fe=v.useCallback(l=>typeof l=="object"&&l!==null&&!Array.isArray(l)&&!(l instanceof Date),[]),st=v.useCallback(l=>l?.customFilterInputConfig?Object.entries(l.customFilterInputConfig).slice(0,3):[],[]),vt=v.useCallback((l,g)=>{const f=st(l);if(f.length===0)return Fe(g)?"":g??"";const S=Fe(g)?g:f.length===1&&g!==void 0&&g!==null?{[f[0][0]]:g}:{};return Object.fromEntries(f.map(([F])=>[F,S[F]??""]))},[st,Fe]),wt=l=>{const g=xt(l.value);if(l.customHandler&&l.condition==="custom"){const f=tt.get(l.fieldId);return{id:l.id,field:l.fieldId,customHandler:l.customHandler,customHandlerName:f?.customFilterConditionLabel,operator:"custom",value:g}}return{id:l.id,...l.relationField?{relation:l.fieldId,relationField:l.relationField}:{field:l.fieldId},operator:l.condition,value:g}},ws=async()=>{if(!A.name.trim()){E(o("Enter filter name"));return}X(!0),E("");try{const l=C.filter(F=>F.enabled).map(wt),g={name:A.name.trim(),description:A.description?.trim()||void 0,conditions:l,icon:A.icon||"bookmark",color:A.color||"#3b82f6",visibility:me,groupIds:me==="groups"?ln:void 0};ge.length>0&&(g.columns=ge.map((F,I)=>({fieldName:F.fieldName,order:I})));const S=(await ee.post(`/adminizer/model/${u}/filter`,g)).data.filter;sessionStorage.removeItem(Be(u)),b(!1),V(null),w([]),R(null),N(""),se("edit"),Q.current?.prev(),window.dispatchEvent(new CustomEvent("adminizer:filterChanged")),Ct({id:String(S.id),name:S.name||A.name.trim(),conditions:S.conditions||l,icon:S.icon,color:S.color})}catch(l){console.error("Error saving filter:",l),E(l.response?.data?.error||o("Error saving filter"))}finally{X(!1)}},Cs=()=>{sessionStorage.removeItem(Be(u)),b(!1),V(null),N(""),w([]),window.dispatchEvent(new CustomEvent("adminizer:filterChanged")),d(),Q.current?.close()},$e=v.useCallback(l=>{const g=I=>{if(!I)return;const O=h.find(re=>re.isCustomFilter&&re.customFilterHandlerId===I);if(O)return O.id;const L=I.split(".");return L[L.length-1]},f=(I,O)=>{const L=h.find(_e=>_e.id===O);return L?L.isRelation?(L.relationFields||[]).find(_e=>_e.id===I.relationField)?.type:L.type:void 0},S=(I,O)=>{const L=I.value;if(L==null)return"";if(I.customHandler)return L;const re=f(I,O);return re==="date"||re==="datetime"?["month","year","monthBetween","yearBetween"].includes(I.operator)?Array.isArray(L)?L.map(Y=>Y==null?"":String(Y)):String(L):Array.isArray(L)?L.map(Y=>typeof Y=="string"&&!isNaN(Date.parse(Y))?new Date(Y):Y):typeof L=="string"&&!isNaN(Date.parse(L))?new Date(L):L:L},F=l.conditions.map(I=>{const O=I.field||I.relation||g(I.customHandler)||"",L=S(I,O);return{id:I.id||`filter-${Date.now()}-${Math.random()}`,fieldId:O,relationField:I.relationField,customHandler:I.customHandler,enabled:!0,condition:I.operator||(I.customHandler?"custom":"eq"),value:L??""}});w(F)},[h]),Ss=async l=>{if(!u){console.error("[FilterPanel] Model name is not set!"),alert(o("Error")+": "+o("Model not found"));return}try{const g=l.filter(I=>I.enabled).map(wt),f={name:x||o("Temporary filter"),conditions:g};ge.length>0&&(f.columns=ge.map((I,O)=>({fieldName:I.fieldName,order:O}))),(await ee.post(`/adminizer/model/${u}/filter/apply`,f)).data.success&&(sessionStorage.setItem(Be(u),JSON.stringify({name:f.name,conditionCount:f.conditions.length,isModified:!1})),V({name:f.name,conditionCount:f.conditions.length,isModified:!1}),b(!0),N(f.name),w(l),m(ie),Q.current?.close(),window.dispatchEvent(new CustomEvent("adminizer:filterChanged")))}catch(g){if(console.error("[FilterPanel] Error applying filter:",g),g.response?.status===401){console.error("Session expired, redirecting to login..."),window.location.href="/adminizer/model/userap/login";return}alert(o("Error applying filter")+": "+(g.response?.data?.error||g.message))}},ys=async()=>{if(!K.name.trim()){E(o("Enter filter name"));return}X(!0),E("");try{const l=C.filter(F=>F.enabled).map(wt),g={filterId:p.id,name:K.name.trim(),description:K.description?.trim()||void 0,conditions:l,icon:K.icon||"bookmark",color:K.color||"#3b82f6",visibility:ne,groupIds:ne==="groups"?an:void 0,sortField:p.sortField,sortDirection:p.sortDirection};ne==="private"&&(g.apiEnabled=Ze,g.regenerateApiKey=Ze&&!Te),ge.length>0&&(g.columns=ge.map((F,I)=>({fieldName:F.fieldName,order:I})));const S=(await ee.post(`/adminizer/model/${u}/filter`,g)).data.filter;N(S.name),R(null),w([]),se("edit"),Q.current?.prev(),window.dispatchEvent(new CustomEvent("adminizer:filterChanged")),Ct({id:String(S.id),name:S.name||K.name.trim(),conditions:S.conditions||l,icon:S.icon,color:S.color})}catch(l){console.error("Error updating filter:",l),E(l.response?.data?.error||o("Error saving filter"))}finally{X(!1)}},Ct=v.useCallback(l=>{m(l.id),N(l.name),$e({conditions:l.conditions}),window.dispatchEvent(new CustomEvent("adminizer:filterChanged"))},[$e,m]),St=v.useCallback(()=>{w([]),N(""),window.dispatchEvent(new CustomEvent("adminizer:filterChanged")),d()},[d]),Nn=v.useCallback(l=>{R(l),N(l.name),He({name:l.name,description:l.description||"",icon:l.icon||"bookmark",color:l.color||"#3b82f6"});const g=l.visibility||"private";Ne(!s&&g==="public"?"private":g),un(l.groupIds||[]),ht(l.apiEnabled||!1),rn(l.apiKey||void 0),Sn(),$e({conditions:l.conditions}),se("edit"),Q.current?.next()},[s,$e]),js=v.useCallback(l=>{c===l&&St()},[c,St]),Rn=()=>{const l=new Date,g=String(l.getMonth()+1).padStart(2,"0");return`${l.getFullYear()}-${g}`},bn=()=>String(new Date().getFullYear()),Ns=(l,g,f)=>{if(l==="custom"&&f?.isCustomFilter)return vt(f,g);if(Fe(g)||l==="isNull"||l==="isNotNull"||l==="today")return"";if(l==="between")return Array.isArray(g)&&g.length===2?g:["",""];if(l==="month")return typeof g=="string"&&/^\d{4}-\d{2}$/.test(g)?g:Rn();if(l==="year")return typeof g=="string"&&/^\d{4}$/.test(g)?g:typeof g=="number"?String(g):bn();if(l==="monthBetween"){if(Array.isArray(g)&&g.length===2&&typeof g[0]=="string"&&/^\d{4}-\d{2}$/.test(g[0])&&typeof g[1]=="string"&&/^\d{4}-\d{2}$/.test(g[1]))return g;const S=Rn();return[S,S]}if(l==="yearBetween"){const S=I=>typeof I=="string"&&/^\d{4}$/.test(I)||typeof I=="number";if(Array.isArray(g)&&g.length===2&&S(g[0])&&S(g[1]))return[String(g[0]),String(g[1])];const F=bn();return[F,F]}return g},T=v.useCallback((l,g)=>{w(f=>f.map(S=>S.id===l?{...S,...g}:S)),$&&V(f=>f&&{...f,isModified:!0})},[$]),Rs=v.useCallback(l=>{if(nt.has(l)){_("placeholder");return}const g=tt.get(l);if(!g)return;const f=g.isCustomFilter?"custom":"eq",S=f==="custom"?vt(g,""):"",F={id:Date.now().toString(),fieldId:l,relationField:g.isRelation?g.relationFields?.[0]?.id:void 0,customHandler:g.isCustomFilter?g.customFilterHandlerId:void 0,enabled:!0,condition:f,value:S},I=[...C,F];w(I),_("placeholder"),$&&V(O=>O&&{...O,conditionCount:I.length,isModified:!0})},[nt,C,tt,vt,$]),bs=v.useCallback(l=>{w(g=>{const f=g.filter(S=>S.id!==l);return $&&V(S=>S&&{...S,conditionCount:f.length,isModified:!0}),f})},[$]),Fs=v.useCallback(()=>{Q.current?.close(),R(null)},[]),$s=v.useCallback((l,g)=>{if(!g.isRelation)return g;if(!g.relationFields||g.relationFields.length===0)return null;const f=g.relationFields.find(S=>S.id===l.relationField)||g.relationFields[0];return{id:f.id,label:f.label,type:f.type,options:f.options,isCustomFilter:!1}},[]),rt=v.useMemo(()=>[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")},{value:"like",label:o("Contains")},{value:"startsWith",label:o("Starts with")},{value:"endsWith",label:o("Ends with")},{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}],[o]),Fn=v.useMemo(()=>{const l=new Map;return h.forEach(g=>{if(g.isRelation){l.set(g.id,[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")}]);return}let f=[];switch(g.type){case"number":case"integer":case"float":f=[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")},{value:"gt",label:o("Greater than")},{value:"gte",label:o("Greater or equal")},{value:"lt",label:o("Less than")},{value:"lte",label:o("Less or equal")},{value:"between",label:o("Between")},{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}];break;case"date":case"datetime":f=[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")},{value:"gt",label:o("After")},{value:"gte",label:o("After or equal")},{value:"lt",label:o("Before")},{value:"lte",label:o("Before or equal")},{value:"between",label:o("Between")},{value:"today",label:o("Today")},{value:"month",label:o("Month")},{value:"year",label:o("Year")},{value:"monthBetween",label:o("Month range")},{value:"yearBetween",label:o("Year range")},{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}];break;case"boolean":f=[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")},{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}];break;case"select":case"select-many":case"association":case"association-many":f=[{value:"eq",label:o("Equal")},{value:"neq",label:o("Not equal")},{value:"in",label:o("In list")},{value:"notIn",label:o("Not in list")},{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}];break;case"json":case"jsoneditor":case"object":case"array":f=[{value:"isNull",label:o("Is empty")},{value:"isNotNull",label:o("Is not empty")}];break;default:f=[...rt];break}g.isCustomFilter&&g.customFilterHandlerId&&(f=[...f,{value:"custom",label:g.customFilterConditionLabel||o("Custom filtering")}]),l.set(g.id,f)}),l},[h,rt,o]),_s=v.useCallback(l=>Fn.get(l)||rt,[Fn,rt]),yt=v.useMemo(()=>h.filter(l=>!nt.has(l.id)),[nt,h]),Is=v.useCallback((l,g)=>{if(g.isCustomFilter&&l.condition==="custom"){const f=st(g);if(f.length>0){const S=Fe(l.value)?l.value:f.length===1&&l.value!==void 0&&l.value!==null?{[f[0][0]]:l.value}:{};return n.jsx("div",{className:"flex gap-1 flex-wrap",children:f.map(([F,I])=>n.jsx(U,{type:I.type||"text",value:String(S[F]??""),onChange:O=>T(l.id,{value:{...S,[F]:O.target.value}}),placeholder:I.placeholder||F,className:"w-full sm:w-[150px] h-9"},F))})}return n.jsx(U,{type:"text",value:String(l.value??""),onChange:S=>T(l.id,{value:S.target.value}),placeholder:o("Value..."),className:"w-full sm:w-[220px] h-9"})}if(l.condition==="isNull"||l.condition==="isNotNull"||l.condition==="today")return null;if(g.type==="boolean")return n.jsxs(Ve,{value:l.value===!0?"true":l.value===!1?"false":"",onValueChange:f=>T(l.id,{value:f==="true"?!0:f==="false"?!1:null}),children:[n.jsx(Ae,{className:"w-full sm:w-[120px] h-9",size:"sm",children:n.jsx(De,{placeholder:o("Select...")})}),n.jsxs(ze,{className:"z-[1100]",children:[n.jsx(ve,{value:"true",children:o("Yes")}),n.jsx(ve,{value:"false",children:o("No")})]})]});if(g.type==="number"||g.type==="integer"||g.type==="float"){if(l.condition==="between"){const f=Array.isArray(l.value)?l.value:["",""];return n.jsxs("div",{className:"flex gap-1 flex-wrap",children:[n.jsx(U,{type:"number",value:f[0],onChange:S=>T(l.id,{value:[parseFloat(S.target.value)||"",f[1]]}),placeholder:o("From..."),className:"w-full sm:w-[120px] h-9"}),n.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),n.jsx(U,{type:"number",value:f[1],onChange:S=>T(l.id,{value:[f[0],parseFloat(S.target.value)||""]}),placeholder:o("To..."),className:"w-full sm:w-[120px] h-9"})]})}return n.jsx(U,{type:"number",value:l.value,onChange:f=>T(l.id,{value:parseFloat(f.target.value)||""}),placeholder:o("Value..."),className:"w-full sm:w-[150px] h-9"})}if((g.type==="date"||g.type==="datetime")&&l.condition==="month")return n.jsx(U,{type:"month",value:typeof l.value=="string"?l.value:"",onChange:f=>T(l.id,{value:f.target.value}),className:"w-full sm:w-[160px] h-9"});if((g.type==="date"||g.type==="datetime")&&l.condition==="year")return n.jsx(U,{type:"number",min:1900,max:9999,step:1,value:typeof l.value=="string"||typeof l.value=="number"?l.value:"",onChange:f=>T(l.id,{value:f.target.value}),placeholder:o("Year"),className:"w-full sm:w-[130px] h-9"});if((g.type==="date"||g.type==="datetime")&&l.condition==="monthBetween"){const f=Array.isArray(l.value)?l.value:["",""];return n.jsxs("div",{className:"flex gap-1 flex-wrap",children:[n.jsx(U,{type:"month",value:typeof f[0]=="string"?f[0]:"",onChange:S=>T(l.id,{value:[S.target.value,f[1]]}),className:"w-full sm:w-[160px] h-9"}),n.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),n.jsx(U,{type:"month",value:typeof f[1]=="string"?f[1]:"",onChange:S=>T(l.id,{value:[f[0],S.target.value]}),className:"w-full sm:w-[160px] h-9"})]})}if((g.type==="date"||g.type==="datetime")&&l.condition==="yearBetween"){const f=Array.isArray(l.value)?l.value:["",""];return n.jsxs("div",{className:"flex gap-1 flex-wrap",children:[n.jsx(U,{type:"number",min:1900,max:9999,step:1,value:typeof f[0]=="string"||typeof f[0]=="number"?f[0]:"",onChange:S=>T(l.id,{value:[S.target.value,f[1]]}),placeholder:o("From..."),className:"w-full sm:w-[120px] h-9"}),n.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),n.jsx(U,{type:"number",min:1900,max:9999,step:1,value:typeof f[1]=="string"||typeof f[1]=="number"?f[1]:"",onChange:S=>T(l.id,{value:[f[0],S.target.value]}),placeholder:o("To..."),className:"w-full sm:w-[120px] h-9"})]})}if(g.type==="date"){if(l.condition==="between"){const f=Array.isArray(l.value)?l.value:["",""],S=f[0],F=f[1];return n.jsxs("div",{className:"flex gap-1 flex-wrap",children:[n.jsxs(Ee,{open:dn,onOpenChange:gn,children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[140px] justify-start text-left font-normal",children:S&&S instanceof Date?jt(S,"dd.MM.yyyy",{locale:kt}):o("From...")})}),n.jsx(Pe,{className:"w-auto p-0",align:"start",children:n.jsx(Nt,{mode:"single",selected:S instanceof Date?S:void 0,onSelect:I=>{T(l.id,{value:[I||"",F]}),gn(!1)},initialFocus:!0})})]}),n.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),n.jsxs(Ee,{open:mn,onOpenChange:fn,children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[140px] justify-start text-left font-normal",children:F&&F instanceof Date?jt(F,"dd.MM.yyyy",{locale:kt}):o("To...")})}),n.jsx(Pe,{className:"w-auto p-0",align:"start",children:n.jsx(Nt,{mode:"single",selected:F instanceof Date?F:void 0,onSelect:I=>{T(l.id,{value:[S,I||""]}),fn(!1)},initialFocus:!0})})]})]})}return n.jsxs(Ee,{open:pn,onOpenChange:hn,children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[150px] justify-start text-left font-normal",children:l.value&&l.value instanceof Date?jt(l.value,"dd.MM.yyyy",{locale:kt}):o("Date...")})}),n.jsx(Pe,{className:"w-auto p-0",align:"start",children:n.jsx(Nt,{mode:"single",selected:l.value instanceof Date?l.value:void 0,onSelect:f=>{T(l.id,{value:f||""}),hn(!1)},initialFocus:!0})})]})}if(g.type==="month"||g.type==="week")return n.jsx(U,{type:g.type,value:l.value||"",onChange:f=>T(l.id,{value:f.target.value}),className:"w-full sm:w-[150px] h-9"});if(g.type==="datetime"){if(l.condition==="between"){const f=Array.isArray(l.value)?l.value:["",""];return n.jsxs("div",{className:"flex gap-1 flex-wrap",children:[n.jsx(U,{type:"datetime-local",value:f[0]||"",onChange:S=>T(l.id,{value:[S.target.value,f[1]]}),className:"w-full sm:w-[180px] h-9"}),n.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),n.jsx(U,{type:"datetime-local",value:f[1]||"",onChange:S=>T(l.id,{value:[f[0],S.target.value]}),className:"w-full sm:w-[180px] h-9"})]})}return n.jsx(U,{type:"datetime-local",value:l.value||"",onChange:f=>T(l.id,{value:f.target.value}),className:"w-full sm:w-[180px] h-9"})}if(g.type==="time")return n.jsx(U,{type:"time",value:l.value||"",onChange:f=>T(l.id,{value:f.target.value}),className:"w-full sm:w-[150px] h-9"});if(g.type==="select"&&l.condition==="in"){const f=Array.isArray(l.value)?l.value:[l.value].filter(Boolean);return n.jsxs(Ee,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[180px] justify-start",children:f.length===0?o("Select..."):`${f.length} ${o("selected")}`})}),n.jsx(Pe,{className:"w-[200px] p-0",align:"start",children:n.jsxs(Rt,{children:[n.jsx(bt,{placeholder:o("Search..."),className:"h-8"}),n.jsxs(Ft,{children:[n.jsx($t,{children:o("No results")}),n.jsx(_t,{children:g.options?.map(S=>{const F=f.includes(S.value);return n.jsxs(It,{value:S.value,onSelect:()=>{const I=F?f.filter(O=>O!==S.value):[...f,S.value];T(l.id,{value:I})},children:[n.jsx(qe,{checked:F,className:"mr-2 [&_svg]:!text-primary-foreground"}),S.label]},S.value)})})]})]})})]})}if(g.type==="select-many"&&l.condition==="in"){const f=Array.isArray(l.value)?l.value:[l.value].filter(Boolean);return n.jsxs(Ee,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[180px] justify-start",children:f.length===0?o("Select..."):`${f.length} ${o("selected")}`})}),n.jsx(Pe,{className:"w-[200px] p-0",align:"start",children:n.jsxs(Rt,{children:[n.jsx(bt,{placeholder:o("Search..."),className:"h-8"}),n.jsxs(Ft,{children:[n.jsx($t,{children:o("No results")}),n.jsx(_t,{children:g.options?.map(S=>{const F=f.includes(S.value);return n.jsxs(It,{value:S.value,onSelect:()=>{const I=F?f.filter(O=>O!==S.value):[...f,S.value];T(l.id,{value:I})},children:[n.jsx(qe,{checked:F,className:"mr-2 [&_svg]:!text-primary-foreground"}),S.label]},S.value)})})]})]})})]})}if(g.type==="select")return n.jsxs(Ve,{value:l.value,onValueChange:f=>T(l.id,{value:f}),children:[n.jsx(Ae,{className:"w-full sm:w-[180px] h-9",size:"sm",children:n.jsx(De,{placeholder:o("Select...")})}),n.jsx(ze,{className:"z-[1100]",children:g.options?.map(f=>n.jsx(ve,{value:f.value,children:f.label},f.value))})]});if(g.type==="select-many"){const f=Array.isArray(l.value)?l.value:[l.value].filter(Boolean);return n.jsxs(Ee,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"sm",className:"h-9 w-[180px] justify-start",children:f.length===0?o("Select..."):`${f.length} ${o("selected")}`})}),n.jsx(Pe,{className:"w-[200px] p-0",align:"start",children:n.jsxs(Rt,{children:[n.jsx(bt,{placeholder:o("Search..."),className:"h-8"}),n.jsxs(Ft,{children:[n.jsx($t,{children:o("No results")}),n.jsx(_t,{children:g.options?.map(S=>{const F=f.includes(S.value);return n.jsxs(It,{value:S.value,onSelect:()=>{const I=F?f.filter(O=>O!==S.value):[...f,S.value];T(l.id,{value:I})},children:[n.jsx(qe,{checked:F,className:"mr-2 [&_svg]:!text-primary-foreground"}),S.label]},S.value)})})]})]})})]})}return n.jsx(U,{value:String(l.value),onChange:f=>T(l.id,{value:f.target.value}),placeholder:o("Value..."),className:"w-full sm:w-[200px] h-9"})},[pn,dn,st,T,Fe,o,mn]);return n.jsxs(n.Fragment,{children:[n.jsxs(Hs,{ref:Q,children:[n.jsx(Ts,{}),n.jsxs(Os,{children:[n.jsx(Mn,{className:"w-[95vw] sm:w-[90vw] max-w-none",children:n.jsx("div",{className:"relative h-full",children:n.jsxs("div",{className:"h-full overflow-y-auto mt-5 pr-2 sm:pr-5",children:[n.jsxs(Et,{children:[n.jsx(Mt,{children:o("Filters")}),n.jsx(Pt,{children:o(c&&c!==ie?"Select a filter or create a new one":"Select a saved filter or create a new one")})]}),n.jsxs("div",{className:"space-y-4 py-4",children:[n.jsxs(M,{onClick:()=>{R(null),w([]),N(o("New filter")),Q.current?.next()},className:"w-full",variant:"outline",children:[n.jsx(Gs,{className:"h-4 w-4 mr-2"}),o("Add filter")]}),$&&z&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2",children:o("Active filter")}),n.jsxs("div",{className:"flex flex-wrap sm:flex-nowrap items-center gap-2 p-3 rounded-md border bg-accent/50 border-accent",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.jsx("span",{className:"text-lg",children:"📝"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"font-medium text-sm truncate",children:z.name}),n.jsxs("div",{className:"text-xs text-muted-foreground",children:[z.conditionCount," ",o("conditions"),z.isModified&&` (${o("modified")})`]})]})]}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:ps,title:o("Apply filter"),children:n.jsx(qn,{className:"h-3.5 w-3.5"})}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:Cn,title:o("Edit"),children:n.jsx(en,{className:"h-3.5 w-3.5"})}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:hs,title:o("Save"),children:n.jsx(Bs,{className:"h-3.5 w-3.5"})}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:Cs,title:o("Reset filter"),children:n.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})]}),u&&n.jsxs(n.Fragment,{children:[!$&&n.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2",children:o("Saved filters")}),n.jsx(ai,{modelName:u,activeFilterId:c,onApplyFilter:Ct,onEditFilter:Nn,onDeleteFilter:js,user:t})]}),c&&c!==ie&&n.jsx("div",{className:"pt-4 border-t",children:n.jsxs(M,{onClick:St,variant:"destructive",className:"w-full",children:[n.jsx(Le,{className:"h-4 w-4 mr-2"}),o("Reset filter")]})})]})]})})}),n.jsx(Mn,{className:"w-[95vw] sm:w-[90vw] max-w-none",children:n.jsx("div",{className:"relative h-full",children:n.jsx("div",{className:"h-full overflow-y-auto mt-5 pr-2 sm:pr-5",children:Oe==="columns"?n.jsxs(n.Fragment,{children:[n.jsxs(Et,{children:[n.jsx(Mt,{children:o("Columns settings")}),n.jsx(Pt,{children:o("Select and arrange columns to display in the table")})]}),Ye?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:o("Loading columns...")})}):n.jsxs("div",{className:"py-4",children:[n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsxs("div",{className:"flex flex-col h-[400px]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("h3",{className:"text-sm font-medium",children:o("Available columns")}),ye.length>0&&n.jsx(M,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:us,children:o("Add all")})]}),n.jsx("div",{className:"flex-1 border rounded-md overflow-y-auto p-1 bg-muted/10",children:ye.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o("No available columns")}):ye.map(l=>n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 text-sm hover:bg-muted/50 rounded-sm group",children:[n.jsx("span",{className:"truncate",title:l.label,children:l.label}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 shrink-0 opacity-100 lg:opacity-0 lg:group-hover:opacity-100 transition-opacity",onClick:()=>os(l),children:n.jsx(Us,{className:"h-4 w-4"})})]},l.fieldName))})]}),n.jsxs("div",{className:"flex flex-col h-[400px]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("h3",{className:"text-sm font-medium",children:o("Visible columns")}),xe.length>0&&n.jsx(M,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:cs,children:o("Hide all")})]}),n.jsx("div",{className:"flex-1 border rounded-md overflow-y-auto p-1 bg-muted/10",children:xe.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o("Move columns here")}):xe.map((l,g)=>n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 text-sm hover:bg-muted/50 rounded-sm group",children:[n.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-shrink-0 gap-0.5",children:[n.jsx(M,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",disabled:g===0,onClick:()=>ds(g),children:n.jsx(Ks,{className:"h-3 w-3"})}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",disabled:g===xe.length-1,onClick:()=>gs(g),children:n.jsx(Ws,{className:"h-3 w-3"})})]}),n.jsx("span",{className:"truncate",title:l.label,children:l.label})]}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 shrink-0 opacity-100 lg:opacity-0 lg:group-hover:opacity-100 transition-opacity",onClick:()=>as(l),children:n.jsx(Xs,{className:"h-4 w-4"})})]},l.fieldName))})]})]}),n.jsxs("p",{className:"text-xs text-muted-foreground mt-3 text-center",children:[o("Use buttons")," ← → ",o("to move and")," ↑ ↓ ",o("to change order")]}),Je&&n.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-2 rounded mt-3",children:Je})]}),n.jsx(Pn,{className:"mt-8 pb-4",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full",children:[n.jsx(M,{variant:"outline",onClick:()=>se("edit"),children:o("Back")}),n.jsx("div",{className:"flex-1"}),n.jsx(M,{onClick:ls,children:o("Save")})]})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(Et,{children:[n.jsx(Mt,{children:Oe==="edit"?p?`${o("Edit filter")}: ${x}`:x||o("New filter"):o("Save filter")}),n.jsx(Pt,{children:o(Oe==="edit"?p?"Change filter conditions and parameters":"Configure filter conditions":"Specify name and parameters for saving")})]}),Oe==="edit"?n.jsxs("div",{className:"space-y-4 py-4",children:[p&&n.jsxs("div",{className:"space-y-4 border-b pb-4",children:[n.jsx("h3",{className:"text-sm font-medium",children:o("Filter parameters")}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium",children:[o("Name")," ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(U,{value:K.name,onChange:l=>He({...K,name:l.target.value}),placeholder:o("Enter filter name")})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Description")}),n.jsx(kn,{value:K.description,onChange:l=>He({...K,description:l.target.value}),placeholder:o("Description"),rows:2})]}),i?n.jsxs("div",{className:"space-y-3 p-3 border rounded-lg bg-muted/20",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-medium",children:o("Filter visibility")})]}),(()=>{if(!((p?.ownerId||p?.ownerInfo?.id)===t?.id)){const f=p?.ownerInfo?.fullName||p?.ownerInfo?.login||o("Unknown");return n.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 rounded-md",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(ke,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:o("Someone else's private filter")}),n.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300 mt-1",children:[o("Owner"),": ",f]}),n.jsx("div",{className:"text-xs text-amber-600 dark:text-amber-400 mt-1",children:o("You cannot change someone else's filter visibility")})]})]})})}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",ne==="private"&&"bg-accent"),onClick:()=>Ne("private"),children:[n.jsx("input",{type:"radio",name:"editVisibility",checked:ne==="private",onChange:()=>Ne("private"),className:"h-4 w-4"}),n.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Private")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("Only for you")})]})]}),n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",ne==="groups"&&"bg-accent"),onClick:()=>Ne("groups"),children:[n.jsx("input",{type:"radio",name:"editVisibility",checked:ne==="groups",onChange:()=>Ne("groups"),className:"h-4 w-4"}),n.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("For groups")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("For selected groups")})]})]}),s&&n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",ne==="public"&&"bg-accent"),onClick:()=>Ne("public"),children:[n.jsx("input",{type:"radio",name:"editVisibility",checked:ne==="public",onChange:()=>Ne("public"),className:"h-4 w-4"}),n.jsx(qt,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Public")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("For all users")})]})]})]}),ne==="groups"&&et.length>0&&n.jsx("div",{className:"pt-2 border-t",children:n.jsx(zn,{groups:et,selectedGroupIds:an,onGroupsChange:un,modelName:u})})]})})()]}):ne==="groups"?n.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-muted/20",children:[n.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("For groups")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("Visible only to your group")})]})]}):n.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-muted/20",children:[n.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Private filter")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("Visible only to you")})]})]}),n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("div",{className:"space-y-2 flex-1",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Icon")}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:[...Hn,""].map(l=>n.jsx(M,{variant:K.icon===l?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>He({...K,icon:l}),children:l?n.jsx(Ce,{name:l,className:"!text-[18px]"}):n.jsx(Le,{className:"h-4 w-4"})},l||"none"))})]}),n.jsxs("div",{className:"space-y-2 flex-1",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Color")}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"].map(l=>n.jsx(M,{variant:K.color===l?"default":"outline",size:"sm",className:"h-8 w-8 p-0 rounded-full",style:{backgroundColor:K.color===l?l:"transparent"},onClick:()=>He({...K,color:l})},l))})]})]}),p&&ne==="private"&&n.jsxs("div",{className:"border rounded-lg p-3 bg-muted/20 mt-4",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ys,{checked:Ze,onCheckedChange:l=>{if(l&&!H){pe(!0),ht(!1);return}ht(l),l&&!Te&&rn(crypto.randomUUID())}}),n.jsx("span",{className:"text-sm font-medium",children:o("API access (feed)")})]})}),Ze&&Te&&n.jsxs("div",{className:"flex items-center gap-2 pt-3 border-t mt-3",children:[n.jsx(M,{variant:"outline",size:"sm",onClick:()=>jn(xs(),o("JSON URL")),children:"JSON"}),n.jsx(M,{variant:"outline",size:"sm",onClick:()=>jn(vs(),o("XML URL")),children:"XML"})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-sm font-medium",children:o(p?"Filter conditions":"Add condition")}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("span",{className:"text-sm text-muted-foreground",children:[o("Add"),":"]}),n.jsx("div",{className:"w-full sm:w-auto",children:n.jsxs(Ve,{value:j,onValueChange:l=>{l!=="placeholder"&&Rs(l)},disabled:yt.length===0,children:[n.jsx(Ae,{className:"w-full sm:w-[200px] h-8",size:"sm",children:n.jsx(De,{placeholder:o("Select field")})}),n.jsxs(ze,{className:"z-[1100]",children:[n.jsx(ve,{value:"placeholder",disabled:!0,className:"text-muted-foreground",children:yt.length===0?o("No results"):o("Select field")}),yt.map(l=>n.jsx(ve,{value:l.id,children:l.label},l.id))]})]})})]}),C.length>0&&n.jsx("div",{className:"space-y-2",children:C.map(l=>{const g=tt.get(l.fieldId);if(!g)return null;const f=_s(l.fieldId),S=$s(l,g);return n.jsxs("div",{className:"flex flex-col items-stretch gap-2 p-2 border rounded-md bg-muted/30 sm:flex-row sm:items-center",children:[n.jsx("span",{className:"text-sm font-medium sm:min-w-[120px] truncate",title:g.label,children:g.label}),g.isRelation&&n.jsxs(Ve,{value:l.relationField||"",onValueChange:F=>T(l.id,{relationField:F,value:""}),children:[n.jsx(Ae,{className:"w-full sm:w-[200px] h-9",size:"sm",children:n.jsx(De,{placeholder:o("Select field")})}),n.jsx(ze,{className:"z-[1100]",children:(g.relationFields||[]).map(F=>n.jsx(ve,{value:F.id,children:F.label},F.id))})]}),n.jsxs(Ve,{value:l.condition,onValueChange:F=>T(l.id,{condition:F,value:Ns(F,l.value,g)}),children:[n.jsx(Ae,{className:"w-full sm:w-[180px] h-9",size:"sm",children:n.jsx(De,{})}),n.jsx(ze,{className:"z-[1100]",children:f.map(F=>n.jsx(ve,{value:F.value,children:F.label},F.value))})]}),n.jsx("div",{className:"w-full sm:flex-1",children:S?Is(l,S):null}),n.jsx(M,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 self-end sm:self-auto sm:ml-auto",onClick:()=>bs(l.id),children:n.jsx(Le,{className:"h-4 w-4"})})]},l.id)})}),C.length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:o("No conditions. Add a condition above.")})]})]}):n.jsxs("div",{className:"space-y-4 py-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium",children:[o("Name")," ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(U,{value:A.name,onChange:l=>{W({...A,name:l.target.value}),D(!0)},placeholder:o("Enter filter name"),autoFocus:!0}),G&&!A.name.trim()&&n.jsx("p",{className:"text-xs text-destructive",children:G})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Description")}),n.jsx(kn,{value:A.description,onChange:l=>W({...A,description:l.target.value}),placeholder:o("Description"),rows:2})]}),i?n.jsxs("div",{className:"space-y-3 p-3 border rounded-lg bg-muted/20",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-medium",children:o("Filter visibility")})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",me==="private"&&"bg-accent"),onClick:()=>je("private"),children:[n.jsx("input",{type:"radio",name:"saveVisibility",checked:me==="private",onChange:()=>je("private"),className:"h-4 w-4"}),n.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Private")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("Only for you")})]})]}),n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",me==="groups"&&"bg-accent"),onClick:()=>je("groups"),children:[n.jsx("input",{type:"radio",name:"saveVisibility",checked:me==="groups",onChange:()=>je("groups"),className:"h-4 w-4"}),n.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("For groups")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("For selected groups")})]})]}),s&&n.jsxs("label",{className:ue("flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors",me==="public"&&"bg-accent"),onClick:()=>je("public"),children:[n.jsx("input",{type:"radio",name:"saveVisibility",checked:me==="public",onChange:()=>je("public"),className:"h-4 w-4"}),n.jsx(qt,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Public")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("For all users")})]})]})]}),me==="groups"&&et.length>0&&n.jsx("div",{className:"pt-2 border-t",children:n.jsx(zn,{groups:et,selectedGroupIds:ln,onGroupsChange:on,modelName:u})})]}):n.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-muted/20",children:[n.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:o("Private filter")}),n.jsx("div",{className:"text-xs text-muted-foreground",children:o("Visible only to you")})]})]}),n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("div",{className:"space-y-2 flex-1",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Icon")}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:[...Hn,""].map(l=>n.jsx(M,{variant:A.icon===l?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>W({...A,icon:l}),children:l?n.jsx(Ce,{name:l,className:"!text-[18px]"}):n.jsx(Le,{className:"h-4 w-4"})},l||"none"))})]}),n.jsxs("div",{className:"space-y-2 flex-1",children:[n.jsx("label",{className:"text-sm font-medium",children:o("Color")}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"].map(l=>n.jsx(M,{variant:A.color===l?"default":"outline",size:"sm",className:"h-8 w-8 p-0 rounded-full",style:{backgroundColor:A.color===l?l:"transparent"},onClick:()=>W({...A,color:l})},l))})]})]}),G&&A.name.trim()&&n.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-2 rounded",children:G})]}),n.jsx(Pn,{className:"mt-8 pb-4",children:Oe==="edit"?n.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full",children:[n.jsx(M,{variant:"outline",onClick:Fs,disabled:C.length===0,children:o("Cancel")}),n.jsxs(M,{variant:"outline",size:"sm",className:"gap-2",onClick:cn,children:[n.jsx(Gt,{className:"h-4 w-4"}),o("Columns")]}),n.jsx("div",{className:"flex-1"}),p?n.jsx(M,{onClick:ys,disabled:B||!K.name.trim(),children:o(B?"Saving...":"Save changes")}):n.jsx(M,{onClick:()=>Ss(C),disabled:C.length===0,children:o("Apply")})]}):n.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full",children:[n.jsx(M,{variant:"outline",onClick:()=>{se("edit")},disabled:B,children:o("Back")}),n.jsxs(M,{variant:"outline",size:"sm",className:"gap-2",onClick:cn,children:[n.jsx(Gt,{className:"h-4 w-4"}),o("Columns")]}),n.jsx("div",{className:"flex-1"}),n.jsx(M,{onClick:ws,disabled:B||!A.name.trim(),children:o(B?"Saving...":"Save")})]})})]})})})})]})]}),le&&n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:n.jsxs("div",{className:"bg-background rounded-lg shadow-lg max-w-md w-full p-6",children:[n.jsx("h3",{className:"text-lg font-semibold mb-2",children:o("API key is not created")}),n.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:o("The key is not created. Create it or contact an administrator.")}),n.jsx("div",{className:"flex justify-end",children:n.jsx(M,{variant:"outline",onClick:()=>pe(!1),children:o("OK")})})]})})]})}function hi({header:e,showSearch:r,onToggleSearch:t}){const s=e.filtersEnabled===!0,i=!!e.activeFilterName,a=new URLSearchParams(window.location.search).get("filterId"),u=i&&!!a,[c,m]=v.useState(!1),{t:d}=We(e.modelResource.name),o=async x=>{if(!c){m(!0);try{const p=new URLSearchParams(window.location.search).get("filterId")||void 0,R=await ee.post(`${e.modelResource.uri}/export`,{format:x,filterId:p},{responseType:"blob"}),j=R.headers["content-type"],_=R.data instanceof Blob?R.data:new Blob([R.data],j?{type:j}:void 0),$=window.URL.createObjectURL(_),b=document.createElement("a");b.href=$;const z=R.headers["content-disposition"];let V=`${e.modelResource.name}_export.${x==="xlsx"?"xlsx":x}`;if(z){const A=z.match(/filename="?(.+?)"?$/);A&&(V=A[1])}b.setAttribute("download",V),document.body.appendChild(b),b.click(),document.body.removeChild(b),window.URL.revokeObjectURL($),ce.success(`${d("Export to")} ${x.toUpperCase()} ${d("completed")}`)}catch(N){if(console.error("Export error:",N),N.response?.data instanceof Blob)try{const p=await N.response.data.text(),R=JSON.parse(p);ce.error(R.error||R.message||d("Export error"))}catch{ce.error(d("Export error"))}else ce.error(N.response?.data?.error||N.response?.data?.message||d("Export error"))}finally{m(!1)}}},C=x=>{const N=typeof x.customHandler=="string"?x.customHandler.split(".").pop():"",p=x.fieldName||x.field||N||d("Custom filtering"),R=x.operator,j=x.value,_={eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",like:d("Contains"),notLike:d("Not contains"),in:d("In list"),notIn:d("Not in list"),isNull:d("Is null"),isNotNull:d("Is not null"),between:d("Between")},$=R==="custom"?x.customHandlerName||d("Custom filtering"):_[R]||R;let b="";return Array.isArray(j)?b=j.map(V=>typeof V=="string"&&V.includes("T")?V.split("T")[0]:String(V)).join(` ${d("and")} `):j&&typeof j=="object"?b=Object.entries(j).map(([z,V])=>`${z}: ${String(V??"")}`).join(", "):b=typeof j=="string"&&j.includes("T")?j.split("T")[0]:String(j),`${p} ${$} ${b}`},w=()=>{const x=window.adminizerFilterPanel;if(x&&x.openFilterDialog)x.openFilterDialog();else{const N=document.getElementById("filter-panel-trigger");N&&N.click()}},h=()=>{const x=new URLSearchParams(window.location.search);x.delete("filterId"),Zt.get(window.location.pathname,Object.fromEntries(x),{preserveState:!0,preserveScroll:!0})},y=()=>{const x=window.adminizerFilterPanel;if(x&&x.openEditCurrentFilter){x.openEditCurrentFilter(a||void 0);return}w()};return n.jsxs("div",{className:"bg-background",children:[s&&n.jsx(pi,{}),n.jsxs("div",{className:"flex flex-wrap gap-2 py-3",children:[e.crudActions?.createTitle&&n.jsx(M,{asChild:!0,children:n.jsxs(Ue,{href:`${e.modelResource.uri}/add`,children:[n.jsx(de,{iconNode:Js}),e.crudActions.createTitle]})}),s&&n.jsxs(M,{variant:"outline",onClick:w,children:[n.jsx(de,{iconNode:Bt}),d("Filters")]}),i&&n.jsxs(ct,{children:[n.jsx(dt,{asChild:!0,children:n.jsxs(M,{variant:"outline",disabled:c,children:[n.jsx(de,{iconNode:c?Vn:Qs}),d(c?"Exporting...":"Export")]})}),n.jsx(gt,{align:"start",children:n.jsxs(Ut,{className:"grid gap-1",children:[n.jsx(be,{onClick:()=>o("json"),className:ue("cursor-pointer"),children:n.jsxs("div",{className:"flex items-center gap-4 w-full",children:[n.jsx("span",{className:"font-mono text-xs w-8 shrink-0",children:"JSON"}),n.jsx("span",{className:"text-muted-foreground text-xs",children:d("Data in JSON format")})]})}),n.jsx(be,{onClick:()=>o("csv"),className:ue("cursor-pointer"),children:n.jsxs("div",{className:"flex items-center gap-4 w-full",children:[n.jsx("span",{className:"font-mono text-xs w-8 shrink-0",children:"CSV"}),n.jsx("span",{className:"text-muted-foreground text-xs",children:d("Text format CSV")})]})}),n.jsx(be,{onClick:()=>o("xlsx"),className:ue("cursor-pointer"),children:n.jsxs("div",{className:"flex items-center gap-4 w-full",children:[n.jsx("span",{className:"font-mono text-xs w-8 shrink-0",children:"XLSX"}),n.jsx("span",{className:"text-muted-foreground text-xs",children:d("Excel file")})]})})]})})]}),n.jsxs(M,{className:"transition-none cursor-pointer",variant:r?"destructive":"outline",onClick:t,children:[n.jsx(de,{iconNode:r?Vn:Gn}),r?e.resetBtn:e.searchBtn]}),e.actions.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"gap-2 ml-0 sm:ml-6 hidden lg:flex",children:e.actions.map(x=>n.jsx(M,{asChild:!0,variant:"outline",children:x.type==="blank"?n.jsxs("a",{href:x.link,target:"_blank",children:[x.icon&&n.jsx(Ce,{name:x.icon,className:"!text-[18px]"}),x.title]}):n.jsxs(Ue,{href:x.link,children:[x.icon&&n.jsx(Ce,{name:x.icon,className:"!text-[18px]"}),x.title]})},x.id))}),n.jsx("div",{className:"block lg:hidden ml-0 sm:ml-6",children:n.jsxs(ct,{children:[n.jsx(dt,{asChild:!0,children:n.jsx(M,{variant:"outline",size:"icon",children:n.jsx(Un,{})})}),n.jsx(gt,{className:"w-fit",side:"right",align:"start",children:n.jsx(Ut,{className:"grid gap-2",children:e.actions.map(x=>n.jsx(M,{asChild:!0,variant:"outline",children:n.jsxs("a",{href:x.link,target:"_blank",children:[n.jsx(Ce,{name:x.icon,className:"!text-[18px]"}),x.title]})},x.id))})})]})})]})]}),i&&n.jsx("div",{className:"border-t pt-3 pb-2",children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(mt,{variant:"secondary",className:"gap-1 h-7 max-w-full",children:[n.jsx(Bt,{className:"h-3 w-3"}),n.jsx("span",{className:"font-medium truncate",children:e.activeFilterName})]}),n.jsxs(M,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground",onClick:y,title:d("Edit filter"),disabled:!u,children:[n.jsx(en,{className:"h-4 w-4"}),n.jsx("span",{className:"ml-1",children:d("Edit")})]}),n.jsxs(M,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-destructive",onClick:h,title:d("Reset filter"),children:[n.jsx(Le,{className:"h-4 w-4"}),n.jsx("span",{className:"ml-1",children:d("Reset")})]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("span",{className:"text-sm text-muted-foreground",children:[d("Conditions"),":"]}),e.activeFilterConditions?.map((x,N)=>n.jsx(mt,{variant:"outline",className:"gap-1 text-xs max-w-[250px] truncate",title:C(x),children:n.jsx("span",{className:"truncate",children:C(x)})},N))]})]})})]})}function xi({rowId:e,modelResourceUri:r,modelResourceName:t,crudActions:s,inlineActions:i,delModal:a}){return n.jsxs(ct,{children:[n.jsx(dt,{asChild:!0,className:"cursor-pointer",children:n.jsx(M,{variant:"outline",size:"icon",children:n.jsx(Un,{})})}),n.jsxs(gt,{className:"w-46",side:"right",align:"start",children:[n.jsxs(Ut,{children:[s?.editTitle&&n.jsx(be,{asChild:!0,className:"cursor-pointer",children:n.jsxs(Ue,{href:`${r}/edit/${e}`,onClick:()=>{localStorage.setItem("backUrl",window.location.pathname+window.location.search)},children:[n.jsx(de,{iconNode:Zs}),s.editTitle]})}),s?.viewsTitle&&n.jsx(be,{asChild:!0,className:"cursor-pointer",children:n.jsxs(Ue,{href:`${r}/view/${e}`,children:[n.jsx(de,{iconNode:er}),s.viewsTitle]})}),s?.deleteTitle&&n.jsx(be,{asChild:!0,className:"cursor-pointer",children:n.jsx(Kn,{btnTitle:s.deleteTitle,delModal:a,btnCLass:"font-normal text-destructive hover:text-destructive w-full cursor-pointer justify-start",link:`${r}/remove/${e}?referTo=${encodeURIComponent(window.location.search)}`})})]}),i&&i.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bn,{}),i.map(u=>n.jsx(be,{asChild:!0,className:"cursor-pointer",children:u.type==="blank"?n.jsxs("a",{target:"_blank",href:`${u.link}?id=${e}&modelResourceName=${t}`,children:[u.icon&&n.jsx(Ce,{name:u.icon,className:"!text-[18px] mr-2"}),n.jsx("span",{children:u.title})]}):n.jsxs(Ue,{href:`${u.link}/${e}?id=${e}&modelResourceName=${t}`,children:[u.icon&&n.jsx(Ce,{name:u.icon,className:"!text-[18px] mr-2"}),n.jsx("span",{children:u.title})]})},u.id))]})]})]})}function vi(e){return{id:"actions",accessorKey:"actions",enableHiding:!1,meta:e.thActionsTitle,header:()=>n.jsx("div",{className:"text-center",children:e.thActionsTitle}),cell:({row:r})=>n.jsx("div",{className:"text-center",children:["deleteTitle","viewsTitle","editTitle"].some(t=>e.crudActions?.[t]&&e.crudActions?.[t].trim()!=="")&&n.jsx(xi,{rowId:r.original.id,modelResourceUri:e.modelResourceUri,modelResourceName:e.modelResourceName,crudActions:e.crudActions,inlineActions:e.inlineActions,delModal:e.delModal})})}}const wi="v1";function Tn(e){return typeof e.id=="string"&&e.id.length>0?e.id:typeof e.accessorKey=="string"&&e.accessorKey.length>0?e.accessorKey:null}function ss(e,r,t){if(!e||typeof e!="object")return{};const s=e,i={};return Object.entries(s).forEach(([a,u])=>{!r.has(a)||t.has(a)||typeof u=="boolean"&&(i[a]=u)}),i}function On(e,r,t){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(e);return s?ss(JSON.parse(s),r,t):{}}catch{return{}}}function Ci(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(r))}catch{}}function Si(e,r){const t=v.useMemo(()=>`adminizer:list:${e}:columns:${wi}`,[e]),s=v.useMemo(()=>{const m=new Set;return r.forEach(d=>{const o=Tn(d);o&&m.add(o)}),m},[r]),i=v.useMemo(()=>{const m=new Set;return r.forEach(d=>{if(d.enableHiding===!1){const o=Tn(d);o&&m.add(o)}}),m},[r]),[a,u]=v.useState(()=>On(t,s,i));v.useEffect(()=>{u(On(t,s,i))},[t,s,i]);const c=v.useCallback(m=>{u(d=>{const o=typeof m=="function"?m(d):m,C=ss(o,s,i);return Ci(t,C),C})},[s,i,t]);return{columnVisibility:a,onColumnVisibilityChange:c}}const yi=()=>{const e=Qt(),r=e.props.data,t=e.props.header,s=e.props.customColumns,{t:i}=We(t.modelResource.name),a=t.pageSizeOptions.map(String),[u,c]=v.useState(r.data);v.useEffect(()=>{c(r.data)},[r.data]);const m=v.useCallback((J,D,B)=>{c(X=>X.map(G=>G.id===J?{...G,[D]:B}:G))},[]),{loading:d,searchValue:o,showSearch:C,currentPage:w,count:h,changeCount:y,handlePageChange:x,handleCustomSort:N,handleGlobalSearch:p,handleSearch:R,handleColumnSearch:j,toggleSearch:_}=oi({header:t}),$=r.page||w,b=v.useMemo(()=>ni(r.recordsFiltered,parseInt(h),$,5),[r.recordsFiltered,h,$,o]);v.useEffect(()=>{e.props.flash&&(e.props.flash.success&&ce.success(e.props.flash.success),e.props.flash.error&&ce.error(e.props.flash.error))},[e.props.flash]);const z=li(e.props.columns,t.modelResource.name,m,N,j,R,C&&!t.filtersEnabled),V=v.useMemo(()=>{const J=vi({thActionsTitle:t.thActionsTitle,crudActions:t.crudActions,inlineActions:t.inlineActions,modelResourceUri:t.modelResource.uri,modelResourceName:t.modelResource.name,delModal:t.delModal});let D=[J,...z];if(s&&s.length>0){const B=new Map(s.sort((G,E)=>G.order-E.order).map(G=>[G.fieldName,G])),X=z.filter(G=>G.accessorKey==="actions"?!0:B.has(G.accessorKey));X.sort((G,E)=>{const H=B.get(G.accessorKey)?.order??999,q=B.get(E.accessorKey)?.order??999;return H-q}),D=[J,...X]}return D},[t.thActionsTitle,t.crudActions,t.inlineActions,t.modelResource.uri,t.modelResource.name,t.delModal,z,s]),{columnVisibility:A,onColumnVisibilityChange:W}=Si(t.modelResource.name,V);return n.jsxs(n.Fragment,{children:[n.jsx(tr,{position:"top-center",richColors:!0,closeButton:!0}),n.jsxs("div",{className:`flex h-full min-h-0 flex-1 flex-col gap-4 rounded-xl p-4 ${d?"opacity-50":""}`,children:[n.jsx(hi,{header:t,showSearch:C,onToggleSearch:_}),n.jsx(ti,{columns:V,data:u,columnVisibility:A,onColumnVisibilityChange:W,searchValue:o,searchTxt:t.searchBtn,notFoundContent:t.notFoundContent,globalSearch:C,onGlobalSearch:p,handleSearch:R,columnVisibilityLabel:i("Columns"),footer:J=>n.jsxs("div",{className:"mt-4 mb-4 flex flex-wrap justify-center md:justify-between gap-4 items-end",children:[n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-1 gap-4 items-center justify-items-center md:justify-items-normal",children:[n.jsxs("p",{className:"text-sm text-foreground/70",children:["Show ",b.from," - ",b.to," of ",b.total]}),n.jsxs("div",{className:"flex flex-wrap items-center justify-center md:justify-start gap-2",children:[J({display:"icon",side:"top"}),n.jsx("div",{className:"max-w-fit",children:n.jsxs(Ve,{onValueChange:D=>y(D),value:h,children:[n.jsx(Ae,{className:"w-full cursor-pointer",children:n.jsx(De,{placeholder:h})}),n.jsx(ze,{children:a.map(D=>n.jsx(ve,{value:D,children:D},D))})]})})]})]}),n.jsx("div",{children:u.length>0&&n.jsx(sr,{pagination:b,pageChange:x,currentPage:$})})]})})]})]})},ji=[],Ui=()=>n.jsx(nr,{breadcrumbs:ji,className:"overflow-auto h-[calc(100svh-16px)]",children:n.jsx(yi,{})});export{Ui as default};
@@ -0,0 +1 @@
1
+ import{c7 as an,ck as ln,ch as dn,c8 as c,bM as un,ay as G,bT as gn,aw as K,aB as hn,ao as pn,an as fn,r as W,az as q,aA as mn,cf as V}from"./app.js";import{Icon as P}from"./icon-C2JNaLxH.js";import{aZ as E}from"./handsontable-BI98OF5R.js";import O from"./input-error-CH2caTtO.js";import"./jsoneditor-DVNQmA6G.js";import"./monaco-Bl4zdWCn.js";const X=(n,t,e)=>{let r=1n,s=n%e;for(;t;)t&1n&&(r=r*s%e),s=s*s%e,t=t>>1n;return r};function M(n,t,e){return typeof n=="bigint"&&typeof t=="bigint"&&typeof e=="bigint"?X(n,t,e):Number(X(BigInt(n),BigInt(t),BigInt(e)))}const b=crypto,yn=new TextEncoder,xn=new TextDecoder("utf-8",{ignoreBOM:!0}),T={encode:n=>yn.encode(n),decode:n=>xn.decode(n)},en=(()=>{const t=[..."0123456789abcdef"],e=new Array(256);for(let r=0;r<256;r++)e[r]=`${t[r>>>4&15]}${t[r&15]}`;return e})(),wn=(()=>{const n={};for(let t=0;t<256;t++){const e=en[t],r=e[0],s=r.toUpperCase(),a=e[1],o=a.toUpperCase();n[e]=t,n[`${r}${o}`]=t,n[`${s}${a}`]=t,n[`${s}${o}`]=t}return n})(),bn=n=>!(n.length%2||!/^[a-fA-F0-9]*$/.test(n)),z={encode:n=>{let t="";for(let e=0,r=n.length;e<r;e++)t+=en[n[e]];return t},encodeStr:n=>z.encode(T.encode(n)),decode:n=>{const t=n.length/2,e=new Uint8Array(t);for(let r=0;r<t;r++)e[r]=wn[n.slice(r*2,r*2+2)];return e},decodeStr:n=>T.decode(z.decode(n)),is:bn},tn=n=>z.encode(n),Y=new TextEncoder,U=n=>{const t=async o=>o instanceof Uint8Array?b.subtle.importKey("raw",o,{name:"PBKDF2"},!1,["deriveBits"]):typeof o=="string"?t(Y.encode(o.normalize())):o,e=(o,i,l,d)=>(i=typeof i=="string"?Y.encode(i):i,b.subtle.deriveBits({name:"PBKDF2",salt:i,iterations:l,hash:{name:n}},o,d)),r=async(o,i,l,d)=>{const g=await t(o);return await e(g,i,l,d*8)},s=async(o,i,l,d)=>new Uint8Array(await r(o,i,l,d)),a=async(o,i,l,d)=>tn(await s(o,i,l,d));return a.buffer=r,a.hex=a,a.uint8=s,a},rn={sha1:U("SHA-1"),sha256:U("SHA-256"),sha384:U("SHA-384"),sha512:U("SHA-512")},D=n=>{const t=new Uint8Array(n);return b.getRandomValues(t),t},vn=new TextEncoder,R=n=>{const t=s=>(s=typeof s=="string"?vn.encode(s):s,b.subtle.digest(n,s)),e=async s=>new Uint8Array(await t(s)),r=async s=>tn(await e(s));return r.buffer=t,r.hex=r,r.uint8=e,r};R("SHA-1");const sn=R("SHA-256");R("SHA-384");R("SHA-512");const x={encode:n=>{if(n!==n>>0)throw new Error("Invalid 32-bit integer");const t=n>>24&255,e=n>>16&255,r=n>>8&255,s=n>>0&255;return new Uint8Array([t,e,r,s])},decode:n=>{if(n.length!==4)throw new Error("Invalid 32-bit integer");const t=n[0],e=n[1],r=n[2],s=n[3];return(t<<24)+(e<<16)+(r<<8)+(s<<0)}},on=n=>{const t=n.reduce((r,s)=>r+s.byteLength,0),e=new Uint8Array(t);for(let r=0,s=0,a=n.length;s<a;s++)e.set(n[s],r),r+=n[s].byteLength;return e},kn=async(n,t,e,r)=>{n=typeof n=="string"?T.encode(n):n,e=typeof e=="string"?T.encode(e):e||D(32),e=e.length===32?e:await sn.uint8(e);const s=new Uint8Array([1]),a=Math.max(1,r||0),o=await rn.sha256.uint8(t,e,a,32),i=await b.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt"]),l=D(16),d=await b.subtle.encrypt({name:"AES-GCM",iv:l,length:256,tagLength:128},i,n),g=new Uint8Array(d);return on([s,e,x.encode(a),l,g])},_n=async(n,t)=>{if(n[0]!==1)throw new Error("Unsupported encrypted archive version");const r=n.subarray(1,33),s=x.decode(n.subarray(33,37)),a=n.subarray(37,53),o=n.subarray(53),i=await rn.sha256.uint8(t,r,s,32),l=await b.subtle.importKey("raw",i,"AES-GCM",!1,["decrypt"]),d=await b.subtle.decrypt({name:"AES-GCM",iv:a,length:256,tagLength:128},l,o);return new Uint8Array(d)},Z=Object.freeze(Object.defineProperty({__proto__:null,decrypt:_n,encrypt:kn},Symbol.toStringTag,{value:"Module"}));function I(n){let t,e=0;return()=>((!t||e===t.length)&&(t=new n(65536/(n.BYTES_PER_ELEMENT*8)),e=0,b.getRandomValues(t)),t[e++])}function jn(n,t){let e=0,r=t;return()=>(r===t&&(e=n(),r=0),e&1<<r++?1:0)}const L={get1:jn(I(Uint8Array),8),get8:I(Uint8Array),get16:I(Uint16Array),get32:I(Uint32Array),get64:I(BigUint64Array)},Cn=Object.assign(()=>BigInt(L.get1()),{BITS:1}),Nn=Object.assign(()=>BigInt(L.get8()),{BITS:8}),Sn=Object.assign(()=>BigInt(L.get16()),{BITS:16}),An=Object.assign(()=>BigInt(L.get32()),{BITS:32}),Bn=Object.assign(()=>L.get64(),{BITS:64}),u=n=>{const t=n<=1?Cn:n<=8?Nn:n<=16?Sn:n<=32?An:Bn,e=t.BITS;if(n===e)return t();if(n===128)return t()<<64n|t();if(n===160)return u(128)<<32n|u(32);if(n===192)return u(128)<<64n|u(64);if(n===224)return u(160)<<64n|u(64);if(n===256)return u(128)<<128n|u(128);if(n===384)return u(256)<<128n|u(128);if(n===512)return u(256)<<256n|u(256);if(n===1024)return u(512)<<512n|u(512);if(n===2048)return u(1024)<<1024n|u(1024);let r=0,s=0n;for(;r<n;){const a=Math.min(e,n-r),o=2n**BigInt(a)-1n,l=t()&o;if(n===a)return l;s=r?s|l<<BigInt(r):l,r+=a}return s},cn=(n,t)=>{if(n=BigInt(n),t=BigInt(t),n<0n||t<0n)throw new Error("Negative ranges are not supported");if(t<=n)throw new Error('"max" must be at least equal to "min" plus 1');const e=t-n-1n,r=e.toString(2).length;for(;;){const s=u(r);if(!(s>e))return s+n}},J=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n],En=(n,t=8)=>{if(n<=1n)return!1;for(let s=0,a=J.length;s<a;s++){const o=J[s];if(n%o===0n)return n===o}if(n<=1000n)return!1;let e=0n,r=n-1n;for(;(r&1n)===0n;)e+=1n,r>>=1n;for(let s=0;s<t;s++){const a=cn(2n,n-2n);let o=M(a,r,n),i=0n;for(let l=0;l<e;l++){if(i=M(o,2n,n),i===1n&&o!==1n&&o!==n-1n)return!1;o=i}if(i!==1n)return!1}return!0},Q=(n,t=8)=>{let e=u(n);for((e&1n)===0n&&(e+=1n);;){if(En(e,t))return e;e+=2n}},w={encode:n=>{let t=0n;for(let e=0,r=n.length;e<r;e++)t|=BigInt(n[e])<<(BigInt(r)-BigInt(e)-1n)*8n;return t},decode:n=>{if(n<0n)throw new Error("Negative BigInts are not supported");const t=[];for(;n;)t.push(Number(n&0xffn)),n>>=8n;return new Uint8Array(t.reverse())}},nn={archive:n=>{const[t,e,r,s,a]=n,o=w.decode(t),i=x.encode(o.length),l=w.decode(e),d=x.encode(l.length),g=w.decode(r),f=x.encode(g.length),h=w.decode(s),m=x.encode(h.length);return on([i,o,d,l,f,g,m,h,a])},unarchive:n=>{const e=n.slice(0,4),r=x.decode(e),s=4,a=n.slice(s,s+r),o=w.encode(a),i=s+r,l=n.slice(i,i+4),d=x.decode(l),g=i+4,f=n.slice(g,g+d),h=w.encode(f),m=g+d,v=n.slice(m,m+4),N=x.decode(v),p=m+4,S=n.slice(p,p+N),A=w.encode(S),k=p+N,y=n.slice(k,k+4),B=x.decode(y),C=k+4,_=n.slice(C,C+B),F=w.encode(_),$=C+B,j=n.slice($);return[o,h,A,F,j]}},In=(n,t,e)=>{let r=n%e;if(t<=BigInt(Number.MAX_SAFE_INTEGER))for(let s=Number(t);s>0;s--)r=r*r%e;else for(let s=t;s>0n;s--)r=r*r%e;return r%e},Tn={generate:async n=>{const t=n.primeBits??100,e=n.primeRounds??20,r=n.opsPerSecond??33e5,s=n.duration??1e3,a=n.message,o=Q(t,e),i=Q(t,e),l=o*i,d=(o-1n)*(i-1n),g=r,f=s,h=BigInt(Math.round(Math.max(1,g/1e3)*f)),m=await sn.uint8(D(32)),v=a,N=await Z.encrypt(v,m),p=cn(1n,l-1n),S=M(2n,h,d),A=M(p,S,l),k=w.encode(m)+A;return nn.archive([l,p,h,k,N])},solve:async n=>{const[t,e,r,s,a]=nn.unarchive(n),o=In(e,r,t),i=w.decode(s-o),l=await Z.decrypt(a,i);return T.decode(l)}};function $n(){const[n,t]=E.useState(!1);E.useEffect(()=>{an()},[]);const e=ln(),r=Array.isArray(e.props.captchaTask)&&e.props.captchaTask.length>0,s=e.props.captchaMessages||{},[a,o]=E.useState(s.initial||"I'm not a robot"),[i,l]=E.useState(!1),[d,g]=E.useState(!1),{post:f,data:h,setData:m,processing:v,transform:N,errors:p,clearErrors:S}=dn({login:"",password:"",captchaSolution:"",redirectTo:e.props.redirectTo??""}),A=y=>{if(y.preventDefault(),!r){f(e.props.submitLink,{onError:C=>{for(const _ of Object.keys(C))V.error(C[_])}});return}t(!0),o(s.solving||"Solving CAPTCHA..."),l(!1),(async()=>{try{let _=function(j){return new Promise(H=>setTimeout(H,j))};var C=_;await _(100);const F=new Uint8Array(e.props.captchaTask),$=await Tn.solve(F);o(s.success||"Verification complete!"),t(!1),l(!0),N(j=>({...j,captchaSolution:$})),f(e.props.submitLink,{onError:j=>{for(const H of Object.keys(j))V.error(j[H])}})}catch(_){console.error("Error solving CAPTCHA:",_),o(s.error||"Error solving CAPTCHA. Try again.")}})()},k=(y,B)=>{S(),m(y,B)};return c.jsxs("div",{className:"bg-sidebar flex min-h-svh w-full justify-center",children:[c.jsx(un,{position:"top-center",richColors:!0,closeButton:!0}),c.jsxs("div",{className:"rounded-xl border bg-card text-card-foreground shadow p-6 max-w-sm w-full h-fit mt-[15%]",children:[c.jsx("h1",{className:"font-medium mb-6 text-xl",children:e.props.title}),e.props.description&&c.jsx("p",{className:"font-thin mb-6 text-xs pb-10",children:e.props.description}),c.jsxs("form",{onSubmit:A,children:[h.redirectTo&&c.jsx("input",{type:"hidden",name:"redirectTo",value:h.redirectTo}),c.jsxs("div",{className:"grid gap-5",children:[r&&c.jsx(O,{message:p.captchaSolution}),c.jsxs("div",{className:"grid gap-4",children:[c.jsx(G,{htmlFor:"login",children:e.props.login}),c.jsxs("div",{className:"relative",children:[c.jsx(P,{iconNode:gn,className:"size-5 absolute inset-2 text-muted-foreground"}),c.jsx(K,{id:"login",className:`pl-10 ${p.login?"border-red-500":""}`,type:"text",required:!0,tabIndex:1,autoComplete:"username",value:h.login,disabled:v||n,onChange:y=>{k("login",y.target.value)},placeholder:e.props.login}),c.jsx(O,{message:p.login})]})]}),c.jsxs("div",{className:"grid gap-4",children:[c.jsx(G,{htmlFor:"password",children:e.props.password}),c.jsxs("div",{className:"relative",children:[c.jsx(P,{iconNode:hn,className:"size-5 absolute inset-2 text-muted-foreground"}),c.jsx(K,{id:"password",className:`pl-10 pr-10 ${p.password?"border-red-500":""}`,type:d?"text":"password",required:!0,disabled:v||n,tabIndex:1,autoComplete:"current-password",value:h.password,onChange:y=>{k("password",y.target.value)},placeholder:e.props.password}),c.jsx("button",{type:"button",onClick:()=>g(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:c.jsx(P,{iconNode:d?pn:fn,className:"size-5"})}),c.jsx(O,{message:p.password})]})]}),c.jsxs("div",{className:"flex gap-4",children:[c.jsx(W,{type:"submit",className:"w-fit",disabled:v||n,children:e.props.submitButton}),e.props.registerLink&&c.jsx(W,{asChild:!0,variant:"outline",children:c.jsx(q,{href:e.props.registerLink.link,className:`${v||n} ? 'pointer-events-none opacity-50' : ''`,children:e.props.registerLink.title})})]})]}),r&&c.jsxs("div",{className:"bg-card border rounded-lg shadow-lg p-4 mt-6 flex items-center space-x-4",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14l-5-4.87 6.91-1.01L12 2z"})})}),c.jsx("div",{className:`${n?"":"hidden"}`,children:c.jsx(P,{iconNode:mn,className:"animate-spin size-6 absolute inset-0 m-auto text-muted-foreground"})})]}),c.jsx("div",{className:"text-foreground font-semibold",children:a}),c.jsx("div",{className:`transition-opacity ${i?"opacity-100 visible":"opacity-0 invisible"}`,children:c.jsx("svg",{id:"checkmark",xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:c.jsx("path",{className:"checkmark",strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]})]}),e.props.addishinalLoginPage&&c.jsx("div",{className:"mt-6 text-center",children:c.jsx(q,{href:e.props.addishinalLoginPage.link,className:"text-sm underline",target:e.props.addishinalLoginPage.link.startsWith("http://")||e.props.addishinalLoginPage.link.startsWith("https://")?"_blank":void 0,rel:e.props.addishinalLoginPage.link.startsWith("http://")||e.props.addishinalLoginPage.link.startsWith("https://")?"noopener noreferrer":void 0,children:e.props.addishinalLoginPage.title})})]})]})}export{$n as default};