@argusoft/medplat-core 1.0.30 → 1.0.32

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 (226) hide show
  1. package/dist/{AccessRights-xrday-L1.js → AccessRights-DBjTQA1-.js} +395 -390
  2. package/dist/AccessRights-DBjTQA1-.js.map +1 -0
  3. package/dist/{AddFeatures-D1sU8RjY.js → AddFeatures-COj4ZTIM.js} +2 -2
  4. package/dist/{AddFeatures-D1sU8RjY.js.map → AddFeatures-COj4ZTIM.js.map} +1 -1
  5. package/dist/AddMenuConfiguration-Creeib5X.js +11223 -0
  6. package/dist/AddMenuConfiguration-Creeib5X.js.map +1 -0
  7. package/dist/AddMenuConfiguration.css +1 -1
  8. package/dist/{BrandsPage-DmRW5bhm-Bk1szrjI.js → BrandsPage-CdcAvaml-ZtVTX6vX.js} +43 -43
  9. package/dist/{BrandsPage-DmRW5bhm-Bk1szrjI.js.map → BrandsPage-CdcAvaml-ZtVTX6vX.js.map} +1 -1
  10. package/dist/{CategoriesPage-BsS5IQh3-B03lWRY5.js → CategoriesPage-BprQEYJw-CclreTv1.js} +109 -102
  11. package/dist/CategoriesPage-BprQEYJw-CclreTv1.js.map +1 -0
  12. package/dist/{ChangePasswordModalCore-BPsJquTS.js → ChangePasswordModalCore-DZGOkbRY.js} +3 -3
  13. package/dist/{ChangePasswordModalCore-BPsJquTS.js.map → ChangePasswordModalCore-DZGOkbRY.js.map} +1 -1
  14. package/dist/ConditionConfig-Bpm6OoV5.js +408 -0
  15. package/dist/ConditionConfig-Bpm6OoV5.js.map +1 -0
  16. package/dist/{DashboardPage-C3bKc5na-sBd9Yqbi.js → DashboardPage-CTiGSx71-CsYohJ5e.js} +32 -32
  17. package/dist/{DashboardPage-C3bKc5na-sBd9Yqbi.js.map → DashboardPage-CTiGSx71-CsYohJ5e.js.map} +1 -1
  18. package/dist/EntityManagement-BGwJGl9k.js +62 -0
  19. package/dist/EntityManagement-BGwJGl9k.js.map +1 -0
  20. package/dist/EventConfig-BY2cgGyx.js +27 -0
  21. package/dist/{EventConfig-BmLemzX3.js.map → EventConfig-BY2cgGyx.js.map} +1 -1
  22. package/dist/EventConfigurations-B-z7xHh_.js +544 -0
  23. package/dist/EventConfigurations-B-z7xHh_.js.map +1 -0
  24. package/dist/EventConfigurations.css +1 -1
  25. package/dist/EventsExceptionModal-DafomIv6.js +188 -0
  26. package/dist/EventsExceptionModal-DafomIv6.js.map +1 -0
  27. package/dist/EventsUi-Dl_yckSA.js +263 -0
  28. package/dist/EventsUi-Dl_yckSA.js.map +1 -0
  29. package/dist/FacilityPicker-BXa2VF7i-Dab_Jwa5.js +112 -0
  30. package/dist/FacilityPicker-BXa2VF7i-Dab_Jwa5.js.map +1 -0
  31. package/dist/{FeatureMenu-DYJmDt7q.js → FeatureMenu-Kc73yPHH.js} +9 -5
  32. package/dist/FeatureMenu-Kc73yPHH.js.map +1 -0
  33. package/dist/{FhirServerList-DuTwnngN.js → FhirServerList-CrIHMAxz.js} +16 -16
  34. package/dist/{FhirServerList-DuTwnngN.js.map → FhirServerList-CrIHMAxz.js.map} +1 -1
  35. package/dist/{FhirServerProfile-CUOwC6Wb.js → FhirServerProfile-D3aYcpwY.js} +8 -8
  36. package/dist/{FhirServerProfile-CUOwC6Wb.js.map → FhirServerProfile-D3aYcpwY.js.map} +1 -1
  37. package/dist/{FhirServerWizard-DZI8Olku.js → FhirServerWizard-Db6Hm4bQ.js} +15 -15
  38. package/dist/{FhirServerWizard-DZI8Olku.js.map → FhirServerWizard-Db6Hm4bQ.js.map} +1 -1
  39. package/dist/{GrantPermissionModal-BDN66Atn.js → GrantPermissionModal-D7iNZd0M.js} +54 -51
  40. package/dist/GrantPermissionModal-D7iNZd0M.js.map +1 -0
  41. package/dist/ImmunizationConfigurationBase-lKsJZMak.js +8060 -0
  42. package/dist/ImmunizationConfigurationBase-lKsJZMak.js.map +1 -0
  43. package/dist/InventoryPage-JadYMCzU-CzJQfQ2A.js +1017 -0
  44. package/dist/InventoryPage-JadYMCzU-CzJQfQ2A.js.map +1 -0
  45. package/dist/LocationWiseExpectedTargetPage-CjKk1aTF.js +1344 -0
  46. package/dist/LocationWiseExpectedTargetPage-CjKk1aTF.js.map +1 -0
  47. package/dist/{ManageDynamicFeature-BU0I45dd.js → ManageDynamicFeature-CuyYfx_P.js} +104 -97
  48. package/dist/ManageDynamicFeature-CuyYfx_P.js.map +1 -0
  49. package/dist/ManageEventConfiguration-DqPbn3Oi.js +1216 -0
  50. package/dist/ManageEventConfiguration-DqPbn3Oi.js.map +1 -0
  51. package/dist/ManageEventConfiguration.css +1 -1
  52. package/dist/ManageRole-CyfpySt9.js +981 -0
  53. package/dist/ManageRole-CyfpySt9.js.map +1 -0
  54. package/dist/{ManageUser-DCFkUMV9.js → ManageUser-Dm0l833u.js} +286 -286
  55. package/dist/{ManageUser-DCFkUMV9.js.map → ManageUser-Dm0l833u.js.map} +1 -1
  56. package/dist/{MemberProfileCard-BdUNgHRB-VywqQdFF.js → MemberProfileCard-01d_jz3w-DYHtbgMX.js} +46 -46
  57. package/dist/{MemberProfileCard-BdUNgHRB-VywqQdFF.js.map → MemberProfileCard-01d_jz3w-DYHtbgMX.js.map} +1 -1
  58. package/dist/MobileAnalytics-C9oc2yAo.js +18399 -0
  59. package/dist/MobileAnalytics-C9oc2yAo.js.map +1 -0
  60. package/dist/MobileMenuManagement-BmzTPXy7.js +231 -0
  61. package/dist/MobileMenuManagement-BmzTPXy7.js.map +1 -0
  62. package/dist/MobileTypeEventConfigModal-DodU3beR.js +752 -0
  63. package/dist/MobileTypeEventConfigModal-DodU3beR.js.map +1 -0
  64. package/dist/{NewServerManagement-Cxe0dV0O.js → NewServerManagement-BdayO78D.js} +368 -352
  65. package/dist/NewServerManagement-BdayO78D.js.map +1 -0
  66. package/dist/OtherTypeEventConfigModal-D_9S50aI.js +1414 -0
  67. package/dist/OtherTypeEventConfigModal-D_9S50aI.js.map +1 -0
  68. package/dist/{PaymentCreatePage-CIVe0P0p-25BQVpOX.js → PaymentCreatePage-D6NZBUC3-DxXf2kvH.js} +58 -58
  69. package/dist/{PaymentCreatePage-CIVe0P0p-25BQVpOX.js.map → PaymentCreatePage-D6NZBUC3-DxXf2kvH.js.map} +1 -1
  70. package/dist/{PaymentsPage-BvPe5Q9F-D2gfziwW.js → PaymentsPage-CHieGNrn-BnYCtqHd.js} +37 -37
  71. package/dist/{PaymentsPage-BvPe5Q9F-D2gfziwW.js.map → PaymentsPage-CHieGNrn-BnYCtqHd.js.map} +1 -1
  72. package/dist/{PermissionsModal-CCYkcKlC.js → PermissionsModal-Dxbkkrqe.js} +18 -18
  73. package/dist/PermissionsModal-Dxbkkrqe.js.map +1 -0
  74. package/dist/{PickupBatchLinesEditor-DHmcAG23-DL2p6IKJ.js → PickupBatchLinesEditor-QPaqFtUO-CY7BShYh.js} +2 -2
  75. package/dist/{PickupBatchLinesEditor-DHmcAG23-DL2p6IKJ.js.map → PickupBatchLinesEditor-QPaqFtUO-CY7BShYh.js.map} +1 -1
  76. package/dist/PickupCreatePage-C7_67u_u-OId8-e2a.js +801 -0
  77. package/dist/PickupCreatePage-C7_67u_u-OId8-e2a.js.map +1 -0
  78. package/dist/{PickupsPage-Ctpghavs-CUp4uIZq.js → PickupsPage-BWblMlic-CWkgeBw0.js} +132 -132
  79. package/dist/PickupsPage-BWblMlic-CWkgeBw0.js.map +1 -0
  80. package/dist/PmGuard-BvUUbU80-BpYNaDzl.js +641 -0
  81. package/dist/PmGuard-BvUUbU80-BpYNaDzl.js.map +1 -0
  82. package/dist/ProductEditPage-Dbq4vUAA-BoBmTPPL.js +1523 -0
  83. package/dist/ProductEditPage-Dbq4vUAA-BoBmTPPL.js.map +1 -0
  84. package/dist/{ProductsPage-CupVmOD4-D45a_hf-.js → ProductsPage-BI22nPb4-CQBjnc-n.js} +44 -43
  85. package/dist/ProductsPage-BI22nPb4-CQBjnc-n.js.map +1 -0
  86. package/dist/PurchaseCreatePage-C0EK9z4w-BQMTsjE7.js +724 -0
  87. package/dist/PurchaseCreatePage-C0EK9z4w-BQMTsjE7.js.map +1 -0
  88. package/dist/{PurchaseRequestDetailPage-Dg_MRY_N-D1bgTEAn.js → PurchaseRequestDetailPage-DhBuOGHZ-CWZPqzt9.js} +428 -418
  89. package/dist/PurchaseRequestDetailPage-DhBuOGHZ-CWZPqzt9.js.map +1 -0
  90. package/dist/{PurchaseRequestsPage-DPAPzpmm-mDH2IrTl.js → PurchaseRequestsPage-Bj9HUMxb-B7-AxT8m.js} +65 -65
  91. package/dist/{PurchaseRequestsPage-DPAPzpmm-mDH2IrTl.js.map → PurchaseRequestsPage-Bj9HUMxb-B7-AxT8m.js.map} +1 -1
  92. package/dist/{PurchasesPage-It1GHiXl-eH4IsF_U.js → PurchasesPage-Djl1AqD_-DXeYFMrX.js} +55 -55
  93. package/dist/{PurchasesPage-It1GHiXl-eH4IsF_U.js.map → PurchasesPage-Djl1AqD_-DXeYFMrX.js.map} +1 -1
  94. package/dist/{RoleManagement-s8iNx2Mu.js → RoleManagement-DVYufwy-.js} +3 -3
  95. package/dist/{RoleManagement-s8iNx2Mu.js.map → RoleManagement-DVYufwy-.js.map} +1 -1
  96. package/dist/Roles-BoNGJhtR.js +19 -0
  97. package/dist/Roles-BoNGJhtR.js.map +1 -0
  98. package/dist/{SaleCreatePage-C9kFmTvm-B3Y0o4CX.js → SaleCreatePage-DHBLmlBr-BlgjVsq6.js} +39 -39
  99. package/dist/{SaleCreatePage-C9kFmTvm-B3Y0o4CX.js.map → SaleCreatePage-DHBLmlBr-BlgjVsq6.js.map} +1 -1
  100. package/dist/{SalesPage-D18DCseD-BxktGDRQ.js → SalesPage-eF9Yr42z-BQ9FlXC3.js} +61 -61
  101. package/dist/{SalesPage-D18DCseD-BxktGDRQ.js.map → SalesPage-eF9Yr42z-BQ9FlXC3.js.map} +1 -1
  102. package/dist/SettingsPage-Cre-UE3r-9ntnLYsQ.js +741 -0
  103. package/dist/SettingsPage-Cre-UE3r-9ntnLYsQ.js.map +1 -0
  104. package/dist/{ShowFlywayQuery-D1y_4A1u.js → ShowFlywayQuery-DIOUdYfG.js} +26 -19
  105. package/dist/{ShowFlywayQuery-D1y_4A1u.js.map → ShowFlywayQuery-DIOUdYfG.js.map} +1 -1
  106. package/dist/{StorageUnitsPage-7EqwuMOI-BwUso1Th.js → StorageUnitsPage-CTEVuemZ-B4osG74N.js} +253 -223
  107. package/dist/StorageUnitsPage-CTEVuemZ-B4osG74N.js.map +1 -0
  108. package/dist/{SubMenu-eEDhZUvh.js → SubMenu-OO2zhKiu.js} +5 -3
  109. package/dist/SubMenu-OO2zhKiu.js.map +1 -0
  110. package/dist/{TableDetails-BtafRxXb.js → TableDetails-Cc40dEUs.js} +272 -267
  111. package/dist/TableDetails-Cc40dEUs.js.map +1 -0
  112. package/dist/{TableList-Dpo6dO7S.js → TableList-B5tX4wII.js} +316 -312
  113. package/dist/TableList-B5tX4wII.js.map +1 -0
  114. package/dist/{TransactionsPage-DrH53pVS-BkhIGB6C.js → TransactionsPage-Zuu7sjID-B-ACzvd1.js} +195 -180
  115. package/dist/TransactionsPage-Zuu7sjID-B-ACzvd1.js.map +1 -0
  116. package/dist/TransferCreatePage-DlT0nCDj-B2SdPgYB.js +635 -0
  117. package/dist/TransferCreatePage-DlT0nCDj-B2SdPgYB.js.map +1 -0
  118. package/dist/TransfersPage-DqaSvHda-G2tFa5Jq.js +600 -0
  119. package/dist/TransfersPage-DqaSvHda-G2tFa5Jq.js.map +1 -0
  120. package/dist/TypeConfiguration-EaFiOzRE.js +114 -0
  121. package/dist/TypeConfiguration-EaFiOzRE.js.map +1 -0
  122. package/dist/UserList-Cf5B-o_1.js +1904 -0
  123. package/dist/UserList-Cf5B-o_1.js.map +1 -0
  124. package/dist/Users-MC7txo1V.js +43 -0
  125. package/dist/{Users-Bpc4Sazd.js.map → Users-MC7txo1V.js.map} +1 -1
  126. package/dist/VaccineEducation-T_UE57Ef.js +231 -0
  127. package/dist/VaccineEducation-T_UE57Ef.js.map +1 -0
  128. package/dist/VaccineEducation.css +1 -0
  129. package/dist/VaccineEducationConfigurator-CWc20_rv.js +50948 -0
  130. package/dist/VaccineEducationConfigurator-CWc20_rv.js.map +1 -0
  131. package/dist/VaccineEducationConfigurator.css +4 -0
  132. package/dist/VaccineEducationList-Ok7_5EFb.js +334 -0
  133. package/dist/VaccineEducationList-Ok7_5EFb.js.map +1 -0
  134. package/dist/VialsPage-LoDaUqVv-DmMXbK8j.js +457 -0
  135. package/dist/VialsPage-LoDaUqVv-DmMXbK8j.js.map +1 -0
  136. package/dist/{constants-ClZJY2x1-MkSWn6TZ.js → constants-BTpJFQe_-CYPZIqQF.js} +166 -56
  137. package/dist/constants-BTpJFQe_-CYPZIqQF.js.map +1 -0
  138. package/dist/dashboardLayoutUtils--xUnoKPa.js +615 -0
  139. package/dist/dashboardLayoutUtils--xUnoKPa.js.map +1 -0
  140. package/dist/index-mfoqII2U.js +524 -0
  141. package/dist/index-mfoqII2U.js.map +1 -0
  142. package/dist/{index-D9YNFPn9.js → index-o8Pyt1Bt.js} +445 -439
  143. package/dist/index-o8Pyt1Bt.js.map +1 -0
  144. package/dist/index.css +1 -1
  145. package/dist/index.js +1 -1
  146. package/dist/index.lib-BySa9-Z-.js +936 -0
  147. package/dist/index.lib-BySa9-Z-.js.map +1 -0
  148. package/dist/listValueStore-5d4vNGQM-WclZ5nBG.js +43 -0
  149. package/dist/listValueStore-5d4vNGQM-WclZ5nBG.js.map +1 -0
  150. package/package.json +5 -1
  151. package/dist/AccessRights-xrday-L1.js.map +0 -1
  152. package/dist/AddMenuConfiguration-e5BVXhmw.js +0 -8547
  153. package/dist/AddMenuConfiguration-e5BVXhmw.js.map +0 -1
  154. package/dist/CategoriesPage-BsS5IQh3-B03lWRY5.js.map +0 -1
  155. package/dist/ConditionConfig-Ddz9halE.js +0 -395
  156. package/dist/ConditionConfig-Ddz9halE.js.map +0 -1
  157. package/dist/ConditionConfig.css +0 -1
  158. package/dist/EntityManagement-CPQL6qBj.js +0 -50
  159. package/dist/EntityManagement-CPQL6qBj.js.map +0 -1
  160. package/dist/EventConfig-BmLemzX3.js +0 -26
  161. package/dist/EventConfigurations-Bzh1qWXU.js +0 -450
  162. package/dist/EventConfigurations-Bzh1qWXU.js.map +0 -1
  163. package/dist/EventsExceptionModal-B2SRrnB1.js +0 -200
  164. package/dist/EventsExceptionModal-B2SRrnB1.js.map +0 -1
  165. package/dist/EventsSkeleton-BIcPks4T.js +0 -61
  166. package/dist/EventsSkeleton-BIcPks4T.js.map +0 -1
  167. package/dist/FacilityPicker-BiZeupmP-CyPHmj6b.js +0 -79
  168. package/dist/FacilityPicker-BiZeupmP-CyPHmj6b.js.map +0 -1
  169. package/dist/FeatureMenu-DYJmDt7q.js.map +0 -1
  170. package/dist/GrantPermissionModal-BDN66Atn.js.map +0 -1
  171. package/dist/ImmunizationConfigurationBase-Di1KO3oW.js +0 -7639
  172. package/dist/ImmunizationConfigurationBase-Di1KO3oW.js.map +0 -1
  173. package/dist/InventoryPage-C_AxSy7A-QLvlL4rE.js +0 -665
  174. package/dist/InventoryPage-C_AxSy7A-QLvlL4rE.js.map +0 -1
  175. package/dist/ManageDynamicFeature-BU0I45dd.js.map +0 -1
  176. package/dist/ManageEventConfiguration-CoYcpjR9.js +0 -1085
  177. package/dist/ManageEventConfiguration-CoYcpjR9.js.map +0 -1
  178. package/dist/ManageRole-CNZBRKGU.js +0 -776
  179. package/dist/ManageRole-CNZBRKGU.js.map +0 -1
  180. package/dist/MobileAnalytics-pQoE8cG1.js +0 -16888
  181. package/dist/MobileAnalytics-pQoE8cG1.js.map +0 -1
  182. package/dist/MobileMenuManagement-Cf8IZlla.js +0 -108
  183. package/dist/MobileMenuManagement-Cf8IZlla.js.map +0 -1
  184. package/dist/MobileTypeEventConfigModal-BeveaX0C.js +0 -783
  185. package/dist/MobileTypeEventConfigModal-BeveaX0C.js.map +0 -1
  186. package/dist/NewServerManagement-Cxe0dV0O.js.map +0 -1
  187. package/dist/OtherTypeEventConfigModal-CM6VkdmY.js +0 -2046
  188. package/dist/OtherTypeEventConfigModal-CM6VkdmY.js.map +0 -1
  189. package/dist/PermissionsModal-CCYkcKlC.js.map +0 -1
  190. package/dist/PickupCreatePage-CB0Sl0Hb-Mmj7zESG.js +0 -783
  191. package/dist/PickupCreatePage-CB0Sl0Hb-Mmj7zESG.js.map +0 -1
  192. package/dist/PickupsPage-Ctpghavs-CUp4uIZq.js.map +0 -1
  193. package/dist/PmGuard-b10TGXEi-G3N0G_Wg.js +0 -599
  194. package/dist/PmGuard-b10TGXEi-G3N0G_Wg.js.map +0 -1
  195. package/dist/ProductEditPage-C1thoKHu-URQaZ6st.js +0 -1302
  196. package/dist/ProductEditPage-C1thoKHu-URQaZ6st.js.map +0 -1
  197. package/dist/ProductsPage-CupVmOD4-D45a_hf-.js.map +0 -1
  198. package/dist/PurchaseCreatePage-YD3NmhPQ-2j4etSjM.js +0 -648
  199. package/dist/PurchaseCreatePage-YD3NmhPQ-2j4etSjM.js.map +0 -1
  200. package/dist/PurchaseRequestDetailPage-Dg_MRY_N-D1bgTEAn.js.map +0 -1
  201. package/dist/Roles-BIyiic67.js +0 -14
  202. package/dist/Roles-BIyiic67.js.map +0 -1
  203. package/dist/SettingsPage-VsxI-ano-DcmtUUEj.js +0 -747
  204. package/dist/SettingsPage-VsxI-ano-DcmtUUEj.js.map +0 -1
  205. package/dist/StorageUnitsPage-7EqwuMOI-BwUso1Th.js.map +0 -1
  206. package/dist/SubMenu-eEDhZUvh.js.map +0 -1
  207. package/dist/TableDetails-BtafRxXb.js.map +0 -1
  208. package/dist/TableList-Dpo6dO7S.js.map +0 -1
  209. package/dist/TransactionsPage-DrH53pVS-BkhIGB6C.js.map +0 -1
  210. package/dist/TransferCreatePage-CuvoMrYH-DTTfHjz-.js +0 -315
  211. package/dist/TransferCreatePage-CuvoMrYH-DTTfHjz-.js.map +0 -1
  212. package/dist/TransfersPage-Cf701t8s-BBbN7cBf.js +0 -476
  213. package/dist/TransfersPage-Cf701t8s-BBbN7cBf.js.map +0 -1
  214. package/dist/TypeConfiguration-3O6ABrK-.js +0 -117
  215. package/dist/TypeConfiguration-3O6ABrK-.js.map +0 -1
  216. package/dist/UserList-DgPxsnj2.js +0 -1129
  217. package/dist/UserList-DgPxsnj2.js.map +0 -1
  218. package/dist/Users-Bpc4Sazd.js +0 -41
  219. package/dist/VialsPage-8oAc1yFv-Cl3FUXBJ.js +0 -321
  220. package/dist/VialsPage-8oAc1yFv-Cl3FUXBJ.js.map +0 -1
  221. package/dist/constants-ClZJY2x1-MkSWn6TZ.js.map +0 -1
  222. package/dist/dashboardLayoutUtils-D1xCAxp3.js +0 -405
  223. package/dist/dashboardLayoutUtils-D1xCAxp3.js.map +0 -1
  224. package/dist/index-D9YNFPn9.js.map +0 -1
  225. package/dist/index.lib-Dn8PMkeD.js +0 -862
  226. package/dist/index.lib-Dn8PMkeD.js.map +0 -1
@@ -0,0 +1,1344 @@
1
+ import { jsx as e, jsxs as r, Fragment as $t } from "react/jsx-runtime";
2
+ import { useMemo as ne, useState as v, useEffect as vt, Suspense as Ht, lazy as Kt } from "react";
3
+ import { Box as Y, LinearProgress as Gt, Alert as Me, Stack as N, Typography as f, Button as _, CircularProgress as qt, Paper as le, Divider as me, TextField as ye, FormControl as Ue, InputLabel as Be, Select as je, MenuItem as fe, Dialog as $e, DialogTitle as He, DialogContent as Ke, DialogActions as xt, Tooltip as Pe, Switch as Jt, IconButton as bt, Card as Vt, Chip as Ee, Drawer as Xt, FormHelperText as Zt, TableContainer as nt, Table as at, TableHead as it, TableRow as te, TableCell as w, TableBody as rt } from "@mui/material";
4
+ import { alpha as Qt } from "@mui/material/styles";
5
+ import { FontAwesomeIcon as D } from "@fortawesome/react-fontawesome";
6
+ import { faLock as Te, faPlus as en, faGripVertical as tn, faTrashCan as nn, faPrint as an, faFileExcel as rn, faSliders as on, faFilter as sn, faXmark as ln, faLockOpen as ot, faFloppyDisk as cn } from "@fortawesome/free-solid-svg-icons";
7
+ import { useSelector as qe } from "react-redux";
8
+ import { showToast as y } from "@/common/toaster/toaster";
9
+ import { api as dn } from "@/common/interceptors/AxiosInterceptor";
10
+ import { execute as B } from "@/common/services/QueryBuilder";
11
+ import { useNavigate as hn } from "react-router";
12
+ import ae from "prop-types";
13
+ import { useSensors as un, useSensor as st, PointerSensor as pn, KeyboardSensor as mn, DndContext as fn, closestCenter as gn } from "@dnd-kit/core";
14
+ import { sortableKeyboardCoordinates as yn, SortableContext as vn, verticalListSortingStrategy as xn, arrayMove as bn, useSortable as wn } from "@dnd-kit/sortable";
15
+ import { restrictToVerticalAxis as Cn, restrictToParentElement as Tn } from "@dnd-kit/modifiers";
16
+ import { CSS as Sn } from "@dnd-kit/utilities";
17
+ import { x as ue } from "./xlsx.min-D1LFqt_b.js";
18
+ const Z = "LOCATION", q = "FACILITY", Le = "TOP_DOWN", wt = "BOTTOM_UP", Oe = (t) => {
19
+ var a, i;
20
+ return (i = (a = t == null ? void 0 : t.data) == null ? void 0 : a.result) == null ? void 0 : i[0];
21
+ }, Q = (t, a) => {
22
+ var d, k, h, T;
23
+ const i = ((k = (d = t == null ? void 0 : t.response) == null ? void 0 : d.data) == null ? void 0 : k.message) || ((T = (h = t == null ? void 0 : t.response) == null ? void 0 : h.data) == null ? void 0 : T.errorMessage) || (t == null ? void 0 : t.message) || "", s = /ERROR:\s*([^\n\r]+)/.exec(i);
24
+ return s ? s[1].trim() : a;
25
+ }, Re = (t, a) => {
26
+ if (t == null || t === "") return a;
27
+ if (typeof t == "object")
28
+ return t.value !== void 0 ? Re(t.value, a) : t;
29
+ try {
30
+ return JSON.parse(t) ?? a;
31
+ } catch {
32
+ return a;
33
+ }
34
+ }, Ct = async () => {
35
+ var i;
36
+ const t = await B({ code: "medplat_lwet_retrieve_indicators" });
37
+ return [...Re((i = Oe(t)) == null ? void 0 : i.indicators, [])].sort(
38
+ (s, d) => (s.displayOrder ?? 0) - (d.displayOrder ?? 0)
39
+ );
40
+ }, In = async (t) => (await B({
41
+ code: "medplat_lwet_save_indicators",
42
+ parameters: { indicators: JSON.stringify(t) }
43
+ }), t), _e = {
44
+ pastYears: 2,
45
+ futureYears: 1,
46
+ direction: Le,
47
+ depth: Z
48
+ }, Tt = async () => {
49
+ var i;
50
+ const t = await B({ code: "medplat_lwet_retrieve_settings" }), a = Re((i = Oe(t)) == null ? void 0 : i.settings, null);
51
+ return {
52
+ pastYears: (a == null ? void 0 : a.pastYears) ?? _e.pastYears,
53
+ futureYears: (a == null ? void 0 : a.futureYears) ?? _e.futureYears,
54
+ direction: (a == null ? void 0 : a.direction) ?? _e.direction,
55
+ depth: (a == null ? void 0 : a.depth) ?? _e.depth
56
+ };
57
+ }, kn = async (t) => (await B({
58
+ code: "medplat_lwet_save_settings",
59
+ parameters: { settings: JSON.stringify(t) }
60
+ }), t), En = async () => {
61
+ var i;
62
+ const t = await B({ code: "medplat_lwet_check_existing_targets" }), a = (i = Oe(t)) == null ? void 0 : i.hasData;
63
+ return a === !0 || a === "true";
64
+ }, Je = (t) => t && {
65
+ entityId: t.entityId,
66
+ financialYear: t.financialYear,
67
+ values: Re(t.values, {}),
68
+ state: t.state,
69
+ noOfTimesUnlocked: t.noOfTimesUnlocked ?? 0,
70
+ isDerived: t.isDerived === !0 || t.isDerived === "true"
71
+ }, _n = async (t, a, i = Z) => {
72
+ const s = await B({
73
+ code: "medplat_lwet_retrieve_target",
74
+ parameters: { entityId: t, financialYear: a, entityType: i }
75
+ });
76
+ return Je(Oe(s)) || null;
77
+ }, lt = async (t, a, i = Z) => {
78
+ var d;
79
+ const s = await B({
80
+ code: "medplat_lwet_retrieve_child_targets",
81
+ parameters: { entityId: t, financialYear: a, entityType: i }
82
+ });
83
+ return (((d = s == null ? void 0 : s.data) == null ? void 0 : d.result) || []).map(Je);
84
+ }, ct = async (t, a, i = Z) => {
85
+ await B({
86
+ code: "medplat_lwet_save_targets",
87
+ parameters: {
88
+ rows: JSON.stringify(
89
+ t.map((s) => ({
90
+ entityId: s.entityId,
91
+ values: s.values || {},
92
+ state: s.state
93
+ }))
94
+ ),
95
+ financialYear: a,
96
+ entityType: i
97
+ }
98
+ });
99
+ }, dt = async (t, a, i = Z) => {
100
+ await B({
101
+ code: "medplat_lwet_unlock_targets",
102
+ parameters: { entityIds: JSON.stringify(t), financialYear: a, entityType: i }
103
+ });
104
+ }, Ln = (t) => dn.get("location/childlocations", { params: { locationId: t } }), ht = async (t) => {
105
+ var i;
106
+ const a = await B({
107
+ code: "medplat_lwet_retrieve_location_facilities",
108
+ parameters: { locationId: t }
109
+ });
110
+ return ((i = a == null ? void 0 : a.data) == null ? void 0 : i.result) || [];
111
+ }, ut = async (t, a) => {
112
+ var s;
113
+ const i = await B({
114
+ code: "medplat_lwet_retrieve_child_facility_targets",
115
+ parameters: { locationId: t, financialYear: a }
116
+ });
117
+ return (((s = i == null ? void 0 : i.data) == null ? void 0 : s.result) || []).map(Je);
118
+ }, On = async (t) => {
119
+ var i;
120
+ const a = await B({
121
+ code: "medplat_lwet_retrieve_child_locations_with_leaf",
122
+ parameters: { locationId: t }
123
+ });
124
+ return (((i = a == null ? void 0 : a.data) == null ? void 0 : i.result) || []).map((s) => ({
125
+ id: s.id,
126
+ name: s.name,
127
+ isLeaf: s.isLeaf === !0 || s.isLeaf === "true"
128
+ }));
129
+ }, pt = async (t, a) => {
130
+ await B({
131
+ code: "medplat_lwet_save_targets_bottom_up",
132
+ parameters: {
133
+ rows: JSON.stringify(
134
+ t.map((i) => ({
135
+ entityId: i.entityId,
136
+ values: i.values || {},
137
+ state: i.state
138
+ }))
139
+ ),
140
+ financialYear: a
141
+ }
142
+ });
143
+ }, Rn = async (t, a) => {
144
+ await B({
145
+ code: "medplat_lwet_save_targets_bottom_up_facility",
146
+ parameters: {
147
+ rows: JSON.stringify(
148
+ t.map((i) => ({
149
+ entityId: i.entityId,
150
+ values: i.values || {},
151
+ state: i.state
152
+ }))
153
+ ),
154
+ financialYear: a
155
+ }
156
+ });
157
+ };
158
+ function Nn(t = /* @__PURE__ */ new Date()) {
159
+ return t.getMonth() < 3 ? t.getFullYear() - 1 : t.getFullYear();
160
+ }
161
+ function St({ pastYears: t = 2, futureYears: a = 1 } = {}) {
162
+ const i = Nn(), s = [];
163
+ for (let d = i + a; d >= i - t; d--)
164
+ s.push(`${d}-${d + 1}`);
165
+ return s;
166
+ }
167
+ const Fn = "techo.manage.locationWiseExpectedTarget", ge = {
168
+ VIEW: "view.core.locationWiseExpectedTarget",
169
+ UPDATE: "update.core.locationWiseExpectedTarget",
170
+ UNLOCK: "unlock.core.locationWiseExpectedTarget",
171
+ CONFIGURE_INDICATORS: "configure.core.locationWiseExpectedTargetIndicators"
172
+ };
173
+ function It() {
174
+ const t = qe((a) => {
175
+ var i;
176
+ return (i = a.Authenticate) == null ? void 0 : i.linearMenuItems;
177
+ });
178
+ return ne(() => {
179
+ const a = t == null ? void 0 : t[Fn];
180
+ let i = a == null ? void 0 : a.featureJson;
181
+ if (typeof i == "string")
182
+ try {
183
+ i = JSON.parse(i);
184
+ } catch {
185
+ i = {};
186
+ }
187
+ const s = i && typeof i == "object" ? i : {}, d = (k) => !!k && s[k] === !0;
188
+ return {
189
+ has: d,
190
+ canView: d(ge.VIEW),
191
+ canUpdate: d(ge.UPDATE),
192
+ canUnlock: d(ge.UNLOCK),
193
+ canConfigureIndicators: d(ge.CONFIGURE_INDICATORS)
194
+ };
195
+ }, [t]);
196
+ }
197
+ function kt({ perm: t = ge.VIEW, children: a }) {
198
+ const i = It(), s = hn(), d = qe((h) => {
199
+ var T;
200
+ return (T = h.Authenticate) == null ? void 0 : T.linearMenuItems;
201
+ });
202
+ return d != null ? i.has(t) ? a : /* @__PURE__ */ e(Y, { sx: { p: 3 }, children: /* @__PURE__ */ e(Me, { severity: "warning", icon: /* @__PURE__ */ e(D, { icon: Te }), sx: { borderRadius: 1.5, alignItems: "flex-start" }, children: /* @__PURE__ */ r(N, { spacing: 1.25, children: [
203
+ /* @__PURE__ */ e(f, { sx: { fontWeight: 800 }, children: "You don’t have access to this page" }),
204
+ /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", children: "Your account doesn’t have the required permission for Location Wise Expected Target. Ask an admin to grant it via the role / user permission assignment." }),
205
+ /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(_, { size: "small", variant: "contained", onClick: () => s("/ui/"), children: "Back to Home" }) })
206
+ ] }) }) }) : /* @__PURE__ */ e(Y, { sx: { p: 3 }, children: /* @__PURE__ */ e(Gt, {}) });
207
+ }
208
+ kt.propTypes = {
209
+ perm: ae.string,
210
+ children: ae.node
211
+ };
212
+ let mt = 0;
213
+ function Et({ row: t, position: a, error: i, onChange: s, onRemove: d }) {
214
+ const { attributes: k, listeners: h, setNodeRef: T, transform: P, transition: L, isDragging: z } = wn({
215
+ id: t.key
216
+ });
217
+ return /* @__PURE__ */ r(
218
+ le,
219
+ {
220
+ ref: T,
221
+ variant: "outlined",
222
+ sx: {
223
+ px: 1.5,
224
+ py: 1,
225
+ mb: 0.75,
226
+ display: "flex",
227
+ alignItems: "center",
228
+ gap: 1.5,
229
+ borderRadius: 1.5,
230
+ transform: Sn.Transform.toString(P),
231
+ transition: L,
232
+ opacity: z ? 0.6 : 1,
233
+ boxShadow: z ? 6 : 0,
234
+ bgcolor: t.isActive === !1 ? "action.hover" : "background.paper"
235
+ },
236
+ children: [
237
+ /* @__PURE__ */ e(Pe, { title: "Drag to reorder", children: /* @__PURE__ */ e(
238
+ Y,
239
+ {
240
+ ...k,
241
+ ...h,
242
+ sx: {
243
+ display: "flex",
244
+ alignItems: "center",
245
+ cursor: "grab",
246
+ color: "text.disabled",
247
+ "&:active": { cursor: "grabbing" }
248
+ },
249
+ children: /* @__PURE__ */ e(D, { icon: tn, size: "sm" })
250
+ }
251
+ ) }),
252
+ /* @__PURE__ */ e(f, { variant: "caption", color: "text.secondary", sx: { width: 18, textAlign: "center" }, children: a }),
253
+ /* @__PURE__ */ e(
254
+ ye,
255
+ {
256
+ size: "small",
257
+ value: t.code,
258
+ onChange: (l) => s(t.key, "code", l.target.value.toUpperCase().replace(/\s+/g, "_")),
259
+ placeholder: "UPPER_CASE_CODE",
260
+ error: !!i,
261
+ helperText: i || " ",
262
+ sx: {
263
+ width: 220,
264
+ "& .MuiInputBase-input": { fontSize: 13, fontFamily: "monospace" },
265
+ "& .MuiFormHelperText-root": { fontSize: 10, mt: 0.25, mx: 0 }
266
+ }
267
+ }
268
+ ),
269
+ /* @__PURE__ */ e(
270
+ ye,
271
+ {
272
+ size: "small",
273
+ value: t.label,
274
+ onChange: (l) => s(t.key, "label", l.target.value),
275
+ placeholder: "Heading shown in the table",
276
+ helperText: " ",
277
+ fullWidth: !0,
278
+ sx: {
279
+ "& .MuiInputBase-input": { fontSize: 13 },
280
+ "& .MuiFormHelperText-root": { fontSize: 10, mt: 0.25, mx: 0 }
281
+ }
282
+ }
283
+ ),
284
+ /* @__PURE__ */ e(Pe, { title: t.isActive === !1 ? "Inactive - hidden from the table" : "Active", children: /* @__PURE__ */ e(
285
+ Jt,
286
+ {
287
+ size: "small",
288
+ checked: t.isActive !== !1,
289
+ onChange: (l) => s(t.key, "isActive", l.target.checked)
290
+ }
291
+ ) }),
292
+ /* @__PURE__ */ e(Pe, { title: "Remove", children: /* @__PURE__ */ e(bt, { size: "small", color: "error", onClick: () => d(t.key), children: /* @__PURE__ */ e(D, { icon: nn, size: "sm" }) }) })
293
+ ]
294
+ }
295
+ );
296
+ }
297
+ Et.propTypes = {
298
+ row: ae.object.isRequired,
299
+ position: ae.number.isRequired,
300
+ error: ae.string,
301
+ onChange: ae.func.isRequired,
302
+ onRemove: ae.func.isRequired
303
+ };
304
+ function _t({ onSaved: t }) {
305
+ const [a, i] = v([]), [s, d] = v(!1), [k, h] = v(!0), [T, P] = v(2), [L, z] = v(1), [l, S] = v({
306
+ direction: Le,
307
+ depth: Z
308
+ }), [j, E] = v({
309
+ direction: Le,
310
+ depth: Z
311
+ }), [ie, m] = v(!1), $ = ne(() => {
312
+ const o = {};
313
+ a.forEach((C) => {
314
+ const p = (C.code || "").trim();
315
+ p && (o[p] = (o[p] || 0) + 1);
316
+ });
317
+ const u = {};
318
+ return a.forEach((C) => {
319
+ const p = (C.code || "").trim();
320
+ p ? o[p] > 1 && (u[C.key] = "Already used") : u[C.key] = "Code is required";
321
+ }), u;
322
+ }, [a]), O = Object.keys($).length > 0, R = a.some((o) => !(o.label || "").trim()), x = (o) => {
323
+ const u = Number(o);
324
+ return o === "" || o === null || Number.isNaN(u) ? "Required" : Number.isInteger(u) ? u < 0 ? "Cannot be negative" : u > 20 ? "Maximum 20" : "" : "Whole number";
325
+ }, H = x(T), ve = x(L), ce = !!(H || ve), Se = St({
326
+ pastYears: Math.min(Math.max(Number(T) || 0, 0), 20),
327
+ futureYears: Math.min(Math.max(Number(L) || 0, 0), 20)
328
+ }), re = un(
329
+ st(pn, { activationConstraint: { distance: 4 } }),
330
+ st(mn, { coordinateGetter: yn })
331
+ );
332
+ vt(() => {
333
+ (async () => {
334
+ try {
335
+ const [o, u] = await Promise.all([
336
+ Ct(),
337
+ Tt()
338
+ ]);
339
+ i(o.map((C) => ({ ...C, key: mt++ }))), P(u.pastYears), z(u.futureYears), S({ direction: u.direction, depth: u.depth }), E({ direction: u.direction, depth: u.depth });
340
+ } catch (o) {
341
+ y({ message: Q(o, "Error loading configuration"), type: "error" });
342
+ } finally {
343
+ h(!1);
344
+ }
345
+ })();
346
+ }, []);
347
+ const Ne = (o, u, C) => {
348
+ i((p) => p.map((M) => M.key === o ? { ...M, [u]: C } : M));
349
+ }, Fe = () => {
350
+ i((o) => [
351
+ ...o,
352
+ { key: mt++, code: "", label: "", isActive: !0 }
353
+ ]);
354
+ }, De = (o) => {
355
+ i((u) => u.filter((C) => C.key !== o));
356
+ }, Ye = ({ active: o, over: u }) => {
357
+ !u || o.id === u.id || i((C) => {
358
+ const p = C.findIndex((J) => J.key === o.id), M = C.findIndex((J) => J.key === u.id);
359
+ return bn(C, p, M);
360
+ });
361
+ }, xe = l.direction !== j.direction || l.depth !== j.depth, ee = async () => {
362
+ d(!0);
363
+ try {
364
+ const o = a.map((p, M) => ({
365
+ code: p.code.trim(),
366
+ label: p.label.trim(),
367
+ displayOrder: M + 1,
368
+ isActive: p.isActive !== !1
369
+ })), [u, C] = await Promise.all([
370
+ In(o),
371
+ kn({
372
+ ...l,
373
+ pastYears: Number(T),
374
+ futureYears: Number(L)
375
+ })
376
+ ]);
377
+ E({ direction: C.direction, depth: C.depth }), y({ message: "Configuration saved successfully", type: "success" }), t == null || t({ indicators: u, settings: C });
378
+ } catch (o) {
379
+ y({ message: Q(o, "Error saving configuration"), type: "error" });
380
+ } finally {
381
+ d(!1);
382
+ }
383
+ }, Ie = async () => {
384
+ if (O) {
385
+ y({ message: "Fix the highlighted indicator codes first", type: "error" });
386
+ return;
387
+ }
388
+ if (R) {
389
+ y({ message: "Every indicator needs a label", type: "error" });
390
+ return;
391
+ }
392
+ if (ce) {
393
+ y({ message: "Financial year range must be between 0 and 20", type: "error" });
394
+ return;
395
+ }
396
+ if (xe) {
397
+ d(!0);
398
+ let o = !1;
399
+ try {
400
+ o = await En();
401
+ } catch (u) {
402
+ d(!1), y({ message: Q(u, "Error checking existing data"), type: "error" });
403
+ return;
404
+ }
405
+ if (d(!1), o) {
406
+ m(!0);
407
+ return;
408
+ }
409
+ }
410
+ await ee();
411
+ }, ze = async () => {
412
+ m(!1), await ee();
413
+ };
414
+ return k ? /* @__PURE__ */ e(Y, { display: "flex", justifyContent: "center", py: 4, children: /* @__PURE__ */ e(qt, {}) }) : /* @__PURE__ */ r(Y, { children: [
415
+ /* @__PURE__ */ e(Me, { severity: "info", sx: { mb: 2, borderRadius: 2, py: 0.5 }, children: /* @__PURE__ */ r(f, { variant: "body2", children: [
416
+ "These become the columns of the target table. Drag to reorder. The ",
417
+ /* @__PURE__ */ e("strong", { children: "code" }),
418
+ " is the stored key — changing it later orphans data already saved under the old code."
419
+ ] }) }),
420
+ a.length === 0 ? /* @__PURE__ */ r(
421
+ le,
422
+ {
423
+ variant: "outlined",
424
+ sx: { p: 4, textAlign: "center", borderRadius: 2, borderStyle: "dashed", mb: 2 },
425
+ children: [
426
+ /* @__PURE__ */ e(f, { color: "text.secondary", gutterBottom: !0, children: "No indicators configured yet." }),
427
+ /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", children: "Add one for each number this implementation plans targets against." })
428
+ ]
429
+ }
430
+ ) : /* @__PURE__ */ r(
431
+ fn,
432
+ {
433
+ sensors: re,
434
+ collisionDetection: gn,
435
+ onDragEnd: Ye,
436
+ modifiers: [Cn, Tn],
437
+ children: [
438
+ /* @__PURE__ */ r(
439
+ Y,
440
+ {
441
+ sx: {
442
+ display: "flex",
443
+ alignItems: "center",
444
+ gap: 1.5,
445
+ px: 1.5,
446
+ pb: 0.5,
447
+ color: "text.secondary"
448
+ },
449
+ children: [
450
+ /* @__PURE__ */ e(Y, { sx: { width: 20 } }),
451
+ /* @__PURE__ */ e(Y, { sx: { width: 18 } }),
452
+ /* @__PURE__ */ e(f, { variant: "caption", fontWeight: 700, sx: { width: 220 }, children: "CODE" }),
453
+ /* @__PURE__ */ e(f, { variant: "caption", fontWeight: 700, sx: { flex: 1 }, children: "COLUMN HEADING" }),
454
+ /* @__PURE__ */ e(f, { variant: "caption", fontWeight: 700, sx: { width: 58, textAlign: "center" }, children: "ACTIVE" }),
455
+ /* @__PURE__ */ e(Y, { sx: { width: 30 } })
456
+ ]
457
+ }
458
+ ),
459
+ /* @__PURE__ */ e(vn, { items: a.map((o) => o.key), strategy: xn, children: /* @__PURE__ */ e(Y, { sx: { maxHeight: 420, overflowY: "auto", pr: 0.5 }, children: a.map((o, u) => /* @__PURE__ */ e(
460
+ Et,
461
+ {
462
+ row: o,
463
+ position: u + 1,
464
+ error: $[o.key],
465
+ onChange: Ne,
466
+ onRemove: De
467
+ },
468
+ o.key
469
+ )) }) })
470
+ ]
471
+ }
472
+ ),
473
+ /* @__PURE__ */ e(_, { startIcon: /* @__PURE__ */ e(D, { icon: en }), onClick: Fe, variant: "outlined", sx: { mt: 1.5 }, children: "Add Indicator" }),
474
+ /* @__PURE__ */ e(me, { sx: { my: 2.5 } }),
475
+ /* @__PURE__ */ e(f, { variant: "subtitle2", fontWeight: 700, gutterBottom: !0, children: "Financial years offered in the filter" }),
476
+ /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", sx: { mb: 1.5 }, children: "Counted either side of the current financial year. Keep at least one future year so next year's targets can be entered before it starts." }),
477
+ /* @__PURE__ */ r(N, { direction: "row", spacing: 2, alignItems: "center", children: [
478
+ /* @__PURE__ */ e(
479
+ ye,
480
+ {
481
+ size: "small",
482
+ type: "number",
483
+ label: "Past years",
484
+ value: T,
485
+ onChange: (o) => P(o.target.value),
486
+ error: !!H,
487
+ helperText: H || " ",
488
+ sx: { width: 140 }
489
+ }
490
+ ),
491
+ /* @__PURE__ */ e(
492
+ ye,
493
+ {
494
+ size: "small",
495
+ type: "number",
496
+ label: "Future years",
497
+ value: L,
498
+ onChange: (o) => z(o.target.value),
499
+ error: !!ve,
500
+ helperText: ve || " ",
501
+ sx: { width: 140 }
502
+ }
503
+ ),
504
+ /* @__PURE__ */ e(f, { variant: "caption", color: "text.secondary", children: Se.join(", ") })
505
+ ] }),
506
+ /* @__PURE__ */ e(me, { sx: { my: 2.5 } }),
507
+ /* @__PURE__ */ e(f, { variant: "subtitle2", fontWeight: 700, gutterBottom: !0, children: "How targets flow through the hierarchy" }),
508
+ /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", sx: { mb: 1.5 }, children: "Direction decides who enters the number first; depth decides how far down it goes." }),
509
+ /* @__PURE__ */ r(N, { direction: "row", spacing: 2, alignItems: "flex-start", flexWrap: "wrap", useFlexGap: !0, children: [
510
+ /* @__PURE__ */ r(Ue, { size: "small", sx: { width: 240 }, children: [
511
+ /* @__PURE__ */ e(Be, { id: "lwet-direction-label", children: "Direction" }),
512
+ /* @__PURE__ */ r(
513
+ je,
514
+ {
515
+ labelId: "lwet-direction-label",
516
+ label: "Direction",
517
+ value: l.direction,
518
+ onChange: (o) => S((u) => ({ ...u, direction: o.target.value })),
519
+ children: [
520
+ /* @__PURE__ */ e(fe, { value: Le, children: "Top to bottom (root enters, distributes down)" }),
521
+ /* @__PURE__ */ e(fe, { value: wt, children: "Bottom to top (leaves enter, sum up)" })
522
+ ]
523
+ }
524
+ )
525
+ ] }),
526
+ /* @__PURE__ */ r(Ue, { size: "small", sx: { width: 240 }, children: [
527
+ /* @__PURE__ */ e(Be, { id: "lwet-depth-label", children: "Depth" }),
528
+ /* @__PURE__ */ r(
529
+ je,
530
+ {
531
+ labelId: "lwet-depth-label",
532
+ label: "Depth",
533
+ value: l.depth,
534
+ onChange: (o) => S((u) => ({ ...u, depth: o.target.value })),
535
+ children: [
536
+ /* @__PURE__ */ e(fe, { value: Z, children: "Up to location" }),
537
+ /* @__PURE__ */ e(fe, { value: q, children: "Up to facility" })
538
+ ]
539
+ }
540
+ )
541
+ ] })
542
+ ] }),
543
+ xe && /* @__PURE__ */ e(Me, { severity: "warning", sx: { mt: 1.5, borderRadius: 2, py: 0.5 }, children: /* @__PURE__ */ e(f, { variant: "body2", children: "Changing this affects how every financial year's data is interpreted. Existing targets are not converted automatically." }) }),
544
+ /* @__PURE__ */ e(N, { direction: "row", justifyContent: "flex-end", sx: { mt: 2.5 }, children: /* @__PURE__ */ e(
545
+ _,
546
+ {
547
+ variant: "contained",
548
+ disabled: s || O || R || ce,
549
+ onClick: Ie,
550
+ children: s ? "Saving..." : "Save Configuration"
551
+ }
552
+ ) }),
553
+ /* @__PURE__ */ r($e, { open: ie, onClose: () => m(!1), maxWidth: "xs", fullWidth: !0, children: [
554
+ /* @__PURE__ */ e(He, { children: "Confirm mode switch" }),
555
+ /* @__PURE__ */ e(Ke, { children: /* @__PURE__ */ e(f, { variant: "body2", children: "Target data already exists. Switching direction or depth changes how it is entered and aggregated going forward, but existing rows are not converted or cleared - they may no longer add up correctly until re-entered under the new mode. Continue anyway?" }) }),
556
+ /* @__PURE__ */ r(xt, { children: [
557
+ /* @__PURE__ */ e(_, { color: "inherit", onClick: () => m(!1), children: "Cancel" }),
558
+ /* @__PURE__ */ e(_, { variant: "contained", color: "warning", disableElevation: !0, onClick: ze, children: "Switch Anyway" })
559
+ ] })
560
+ ] })
561
+ ] });
562
+ }
563
+ _t.propTypes = {
564
+ onSaved: ae.func
565
+ };
566
+ const Dn = {
567
+ font: { bold: !0, color: { rgb: "FFFFFF" } },
568
+ fill: { fgColor: { rgb: "243A50" } },
569
+ alignment: { horizontal: "center", vertical: "center", wrapText: !0 }
570
+ }, Yn = { font: { bold: !0 } }, zn = { font: { bold: !0 } };
571
+ function Lt({
572
+ indicators: t,
573
+ locationHierarchy: a,
574
+ parentValues: i,
575
+ childRows: s,
576
+ totals: d,
577
+ differences: k,
578
+ childEntityType: h,
579
+ isBottomUp: T
580
+ }) {
581
+ const L = ["#", h === "FACILITY" ? "Facility Name" : "Location Name", ...t.map((l) => l.label)], z = [
582
+ [
583
+ "",
584
+ a || "Selected location",
585
+ ...t.map((l) => (i == null ? void 0 : i[l.code]) ?? 0)
586
+ ],
587
+ ...s.map((l, S) => [
588
+ S + 1,
589
+ l.name,
590
+ ...t.map((j) => {
591
+ var E;
592
+ return ((E = l.values) == null ? void 0 : E[j.code]) ?? 0;
593
+ })
594
+ ]),
595
+ ["", "Total", ...t.map((l) => d[l.code] ?? 0)]
596
+ ];
597
+ return T || z.push(["", "Difference", ...t.map((l) => k[l.code] ?? 0)]), { columns: L, rows: z };
598
+ }
599
+ function An({
600
+ indicators: t,
601
+ locationHierarchy: a,
602
+ financialYear: i,
603
+ parentValues: s,
604
+ childRows: d,
605
+ totals: k,
606
+ differences: h,
607
+ childEntityType: T,
608
+ isBottomUp: P
609
+ }) {
610
+ const { columns: L, rows: z } = Lt({
611
+ indicators: t,
612
+ locationHierarchy: a,
613
+ parentValues: s,
614
+ childRows: d,
615
+ totals: k,
616
+ differences: h,
617
+ childEntityType: T,
618
+ isBottomUp: P
619
+ }), l = [];
620
+ l.push(["Location:", a || "-"]), l.push(["Financial Year:", i || "-"]), l.push([]);
621
+ const S = l.length;
622
+ l.push(L), z.forEach((R) => l.push(R));
623
+ const j = ue.utils.aoa_to_sheet(l), E = ue.utils.decode_range(j["!ref"]), ie = P ? 1 : 2, m = E.e.r - (ie - 1);
624
+ for (let R = E.s.r; R <= E.e.r; R++)
625
+ for (let x = E.s.c; x <= E.e.c; x++) {
626
+ const H = j[ue.utils.encode_cell({ r: R, c: x })];
627
+ H && (R === S ? H.s = Dn : R >= m ? H.s = zn : R < S - 1 && x === 0 && (H.s = Yn));
628
+ }
629
+ j["!cols"] = L.map((R, x) => ({ wch: x === 1 ? 28 : 18 }));
630
+ const $ = ue.utils.book_new();
631
+ ue.utils.book_append_sheet($, j, "Sheet1");
632
+ const O = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
633
+ ue.writeFile($, `Location Wise Expected Target(${O}).xlsx`);
634
+ }
635
+ const pe = (t) => String(t ?? "").replace(
636
+ /[&<>"']/g,
637
+ (a) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[a]
638
+ );
639
+ function Wn({
640
+ indicators: t,
641
+ locationHierarchy: a,
642
+ financialYear: i,
643
+ parentValues: s,
644
+ childRows: d,
645
+ totals: k,
646
+ differences: h,
647
+ generatedBy: T,
648
+ childEntityType: P,
649
+ isBottomUp: L
650
+ }) {
651
+ const { columns: z, rows: l } = Lt({
652
+ indicators: t,
653
+ locationHierarchy: a,
654
+ parentValues: s,
655
+ childRows: d,
656
+ totals: k,
657
+ differences: h,
658
+ childEntityType: P,
659
+ isBottomUp: L
660
+ }), S = L ? 1 : 2, j = z.map(($) => `<th>${pe($)}</th>`).join(""), E = l.map(($, O) => {
661
+ const R = O >= l.length - S, x = $.map((H) => `<td>${pe(H)}</td>`).join("");
662
+ return `<tr class="${R ? "footer-row" : ""}">${x}</tr>`;
663
+ }).join(""), ie = `Generated by ${pe(T)} at ${pe(
664
+ (/* @__PURE__ */ new Date()).toLocaleString()
665
+ )}`, m = window.open("", "_blank");
666
+ m && (m.document.write(`
667
+ <html>
668
+ <head>
669
+ <title>Location Wise Expected Target</title>
670
+ <style>
671
+ @page { size: landscape; margin: 10mm; }
672
+ body { font-family: Arial, Helvetica, sans-serif; color: #1c2733; margin: 0; }
673
+ h2 { text-align: center; margin: 0 0 6px; font-size: 16px; }
674
+ .meta { text-align: center; font-size: 12px; margin-bottom: 12px; }
675
+ table { width: 100%; border-collapse: collapse; font-size: 11px; }
676
+ th, td { border: 1px solid #9aa5b1; padding: 4px 6px; text-align: left; }
677
+ th { background: #e6eef5; font-weight: bold; }
678
+ .footer-row td { font-weight: bold; background: #f2f5f8; }
679
+ .print-footer { margin-top: 10px; font-size: 10px; color: #5a6877; }
680
+ </style>
681
+ </head>
682
+ <body onload="setTimeout(function () { window.print(); window.close(); }, 300);">
683
+ <h2>Location Wise Expected Target</h2>
684
+ <div class="meta">
685
+ <strong>Location:</strong> ${pe(a || "-")}
686
+ &nbsp;&nbsp;<strong>Financial Year:</strong> ${pe(i || "-")}
687
+ </div>
688
+ <table><thead><tr>${j}</tr></thead><tbody>${E}</tbody></table>
689
+ <div class="print-footer">${ie}</div>
690
+ </body>
691
+ </html>
692
+ `), m.document.close());
693
+ }
694
+ const Pn = Kt(
695
+ () => import("@/views/feature-components/LocationDirective/LocationDirectiveV2")
696
+ ), K = "DRAFT", G = "LOCKED", se = "UNLOCKED", Ge = (t) => t.palette.mode === "dark" ? t.palette.grey[900] : t.palette.grey[100], ft = (t) => t.reduce((a, i) => ({ ...a, [i.code]: 0 }), {}), gt = {
697
+ "& .MuiTableCell-root": {
698
+ border: "1px solid",
699
+ borderColor: "divider",
700
+ px: 1,
701
+ py: 0.5,
702
+ fontSize: 13,
703
+ lineHeight: 1.35
704
+ },
705
+ "& .MuiTableCell-head": {
706
+ fontWeight: 700,
707
+ backgroundColor: Ge,
708
+ whiteSpace: "normal"
709
+ }
710
+ }, yt = {
711
+ width: "100%",
712
+ "& .MuiInputBase-input": { py: 0.5, px: 1, fontSize: 13 }
713
+ };
714
+ function Mn() {
715
+ const t = It(), a = qe((n) => {
716
+ var c;
717
+ return (c = n.Authenticate) == null ? void 0 : c.user;
718
+ }), [i, s] = v({}), [d, k] = v([]), [h, T] = v(""), [P, L] = v([]), [z, l] = v(!1), [S, j] = v(!1), [E, ie] = v(""), [m, $] = v(null), [O, R] = v([]), [x, H] = v(Z), [ve, ce] = v(!1), [Se, re] = v(!0), [Ne, Fe] = v(null), [De, Ye] = v(!1), [xe, ee] = v(null), [Ie, ze] = v(!1), [o, u] = v({ pastYears: 2, futureYears: 1, direction: "TOP_DOWN", depth: "LOCATION" }), C = ne(() => St(o), [o]), p = o.direction === wt, M = o.depth === q, J = p ? !M && De : Ne === 0, b = ne(
719
+ () => P.filter((n) => n.isActive !== !1),
720
+ [P]
721
+ ), Ot = async () => {
722
+ try {
723
+ const [n, c] = await Promise.all([
724
+ Ct(),
725
+ Tt()
726
+ ]);
727
+ L(n), u(c);
728
+ } catch (n) {
729
+ y({ message: Q(n, "Error loading configuration"), type: "error" });
730
+ }
731
+ };
732
+ vt(() => {
733
+ Ot();
734
+ }, []);
735
+ const ke = ne(() => {
736
+ const n = {};
737
+ return b.forEach((c) => {
738
+ n[c.code] = O.reduce(
739
+ (g, I) => {
740
+ var A;
741
+ return g + (Number((A = I.values) == null ? void 0 : A[c.code]) || 0);
742
+ },
743
+ 0
744
+ );
745
+ }), n;
746
+ }, [O, b]), be = ne(() => {
747
+ const n = {};
748
+ return b.forEach((c) => {
749
+ var I;
750
+ const g = Number((I = m == null ? void 0 : m.values) == null ? void 0 : I[c.code]) || 0;
751
+ n[c.code] = g - (ke[c.code] || 0);
752
+ }), n;
753
+ }, [ke, m, b]), V = (m == null ? void 0 : m.state) || K, X = ne(() => p ? M && x !== q ? [] : O.filter((n) => n.isLeaf) : O, [p, O, M, x]), de = ne(() => X.some((n) => n.state === G) ? G : X.some((n) => n.state === se) ? se : K, [X]), Rt = t.canUpdate && J && (V === K || V === se), Ae = t.canUpdate && (de === K || de === se) && (p || V === G), Ve = (n) => X.length > 0 && X.every((c) => {
754
+ var g, I;
755
+ return ((g = c.values) == null ? void 0 : g[n]) !== null && ((I = c.values) == null ? void 0 : I[n]) !== void 0;
756
+ }), Nt = (n) => p || be[n] === 0, Ft = b.every((n) => Ve(n.code)), Dt = p ? !0 : b.every((n) => be[n.code] === 0), Yt = b.every((n) => {
757
+ var g;
758
+ const c = (g = m == null ? void 0 : m.values) == null ? void 0 : g[n.code];
759
+ return c != null && c !== "";
760
+ }), Xe = () => ({
761
+ indicators: b,
762
+ locationHierarchy: E,
763
+ financialYear: h,
764
+ parentValues: m == null ? void 0 : m.values,
765
+ childRows: O,
766
+ totals: ke,
767
+ differences: be,
768
+ childEntityType: x,
769
+ isBottomUp: p
770
+ }), zt = () => {
771
+ const n = (a == null ? void 0 : a.fullName) || `${(a == null ? void 0 : a.firstName) || ""} ${(a == null ? void 0 : a.lastName) || ""}`.trim() || (a == null ? void 0 : a.userName) || "-";
772
+ Wn({ ...Xe(), generatedBy: n });
773
+ }, he = async () => {
774
+ var g, I, A;
775
+ ze(!0);
776
+ const n = (I = (g = i == null ? void 0 : i.finalSelected) == null ? void 0 : g.optionSelected) == null ? void 0 : I.id;
777
+ if (!n) {
778
+ y({ message: "Please select a location", type: "error" });
779
+ return;
780
+ }
781
+ if (!h) {
782
+ y({ message: "Please select financial year", type: "error" });
783
+ return;
784
+ }
785
+ l(!0);
786
+ const c = Object.keys(i || {}).filter(
787
+ (U) => /^level\d+$/.test(U) && i[U]
788
+ );
789
+ Fe(Math.max(c.length - 1, 0));
790
+ try {
791
+ let U, oe, we = !1, Ce;
792
+ if (p) {
793
+ const W = await On(n);
794
+ Ce = W.length === 0, M && Ce ? (we = !0, U = await ht(n), oe = await ut(n, h)) : (U = W, oe = await lt(n, h));
795
+ } else {
796
+ const F = (await Ln(n)).data || [];
797
+ Ce = F.length === 0, we = Ce && M, U = we ? await ht(n) : F, oe = we ? await ut(n, h) : await lt(n, h);
798
+ }
799
+ Ye(Ce), H(we ? q : Z);
800
+ const jt = await _n(n, h);
801
+ $(
802
+ jt || {
803
+ entityId: n,
804
+ financialYear: h,
805
+ values: ft(b),
806
+ state: K,
807
+ noOfTimesUnlocked: 0
808
+ }
809
+ );
810
+ const tt = {};
811
+ oe.forEach((W) => {
812
+ tt[W.entityId] = W;
813
+ }), R(
814
+ U.map((W) => {
815
+ const F = tt[W.id];
816
+ return {
817
+ id: W.id,
818
+ name: W.name,
819
+ isLeaf: W.isLeaf !== !1,
820
+ values: (F == null ? void 0 : F.values) || ft(b),
821
+ state: (F == null ? void 0 : F.state) || K,
822
+ noOfTimesUnlocked: (F == null ? void 0 : F.noOfTimesUnlocked) || 0
823
+ };
824
+ })
825
+ );
826
+ let We = "";
827
+ for (let W = 1; W <= (((A = i == null ? void 0 : i.finalSelected) == null ? void 0 : A.level) || 0); W++) {
828
+ const F = i == null ? void 0 : i[`level${W}`];
829
+ if (!F) break;
830
+ We += We ? ` > ${F.name}` : F.name;
831
+ }
832
+ ie(We), j(!0), re(!1);
833
+ } catch (U) {
834
+ y({ message: Q(U, "Error loading targets"), type: "error" });
835
+ } finally {
836
+ l(!1);
837
+ }
838
+ }, Ze = (n) => {
839
+ const c = String(n).replace(/[^\d]/g, "");
840
+ return c === "" ? null : Math.min(Number(c), 1e9);
841
+ }, At = (n, c, g) => {
842
+ R(
843
+ (I) => I.map(
844
+ (A) => A.id === n ? { ...A, values: { ...A.values, [c]: Ze(g) } } : A
845
+ )
846
+ );
847
+ }, Wt = (n, c) => {
848
+ $((g) => ({
849
+ ...g,
850
+ values: { ...g.values, [n]: Ze(c) }
851
+ }));
852
+ }, Qe = async (n) => {
853
+ if (!Yt) {
854
+ y({ message: "Please fill up all the values first", type: "error" });
855
+ return;
856
+ }
857
+ if (!h) {
858
+ y({ message: "Please select financial year", type: "error" });
859
+ return;
860
+ }
861
+ l(!0);
862
+ try {
863
+ p ? await pt(
864
+ [{ entityId: m.entityId, values: m.values, state: n }],
865
+ h
866
+ ) : await ct([{ ...m, state: n }], h), y({ message: "Saved successfully", type: "success" }), await he();
867
+ } catch (c) {
868
+ y({ message: Q(c, "Error saving"), type: "error" });
869
+ } finally {
870
+ l(!1);
871
+ }
872
+ }, Pt = async () => {
873
+ l(!0);
874
+ try {
875
+ await dt([m.entityId], h), y({ message: "Data unlocked successfully", type: "success" }), await he();
876
+ } catch (n) {
877
+ y({ message: Q(n, "Error unlocking"), type: "error" });
878
+ } finally {
879
+ l(!1);
880
+ }
881
+ }, et = async (n, c) => {
882
+ if (!h || X.length === 0) {
883
+ y({ message: "Nothing to save", type: "error" });
884
+ return;
885
+ }
886
+ l(!0);
887
+ try {
888
+ const g = X.map((I) => ({
889
+ entityId: I.id,
890
+ values: c.reduce((A, U) => {
891
+ var oe;
892
+ return { ...A, [U]: (oe = I.values) == null ? void 0 : oe[U] };
893
+ }, {}),
894
+ state: n
895
+ }));
896
+ p && x === q ? await Rn(g, h) : p ? await pt(g, h) : await ct(g, h, x), y({ message: "Records saved successfully", type: "success" }), await he();
897
+ } catch (g) {
898
+ y({ message: Q(g, "Error saving"), type: "error" });
899
+ } finally {
900
+ l(!1);
901
+ }
902
+ }, Mt = async (n) => {
903
+ if (!Ve(n)) {
904
+ y({ message: "Please fill up all the values first", type: "error" });
905
+ return;
906
+ }
907
+ if (!Nt(n)) {
908
+ y({ message: "Total should match with the given targets", type: "error" });
909
+ return;
910
+ }
911
+ await et(K, [n]);
912
+ }, Ut = async () => {
913
+ if (!Ft) {
914
+ y({ message: "Please fill up all the values first", type: "error" });
915
+ return;
916
+ }
917
+ if (!Dt) {
918
+ y({ message: "Total should match with the given targets", type: "error" });
919
+ return;
920
+ }
921
+ await et(G, b.map((n) => n.code));
922
+ }, Bt = async () => {
923
+ l(!0);
924
+ try {
925
+ await dt(X.map((n) => n.id), h, x), y({ message: "Data unlocked successfully", type: "success" }), await he();
926
+ } catch (n) {
927
+ y({ message: Q(n, "Error unlocking"), type: "error" });
928
+ } finally {
929
+ l(!1);
930
+ }
931
+ };
932
+ return /* @__PURE__ */ r(Vt, { variant: "elevation", className: "mt-6 p-3 flex flex-col shadow-xl", sx: { p: 3 }, children: [
933
+ /* @__PURE__ */ r(
934
+ N,
935
+ {
936
+ direction: { xs: "column", sm: "row" },
937
+ justifyContent: "space-between",
938
+ alignItems: { xs: "flex-start", sm: "center" },
939
+ spacing: 1.5,
940
+ sx: { mb: 2 },
941
+ children: [
942
+ /* @__PURE__ */ e(Y, { children: S ? /* @__PURE__ */ r(N, { direction: "row", spacing: 1, flexWrap: "wrap", useFlexGap: !0, children: [
943
+ /* @__PURE__ */ e(Ee, { size: "small", color: "primary", variant: "outlined", label: E || "Location" }),
944
+ /* @__PURE__ */ e(Ee, { size: "small", color: "primary", variant: "outlined", label: `FY ${h}` })
945
+ ] }) : /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", children: "Select a location and financial year to begin" }) }),
946
+ /* @__PURE__ */ r(N, { direction: "row", spacing: 1, alignItems: "center", children: [
947
+ S && b.length > 0 && /* @__PURE__ */ r($t, { children: [
948
+ /* @__PURE__ */ e(
949
+ _,
950
+ {
951
+ size: "small",
952
+ variant: "outlined",
953
+ color: "inherit",
954
+ startIcon: /* @__PURE__ */ e(D, { icon: an }),
955
+ onClick: zt,
956
+ children: "Print"
957
+ }
958
+ ),
959
+ /* @__PURE__ */ e(
960
+ _,
961
+ {
962
+ size: "small",
963
+ variant: "outlined",
964
+ startIcon: /* @__PURE__ */ e(D, { icon: rn }),
965
+ onClick: () => An(Xe()),
966
+ sx: {
967
+ color: "success.main",
968
+ borderColor: "success.main",
969
+ "&:hover": {
970
+ borderColor: "success.dark",
971
+ bgcolor: (n) => Qt(n.palette.success.main, 0.08)
972
+ }
973
+ },
974
+ children: "Excel"
975
+ }
976
+ )
977
+ ] }),
978
+ t.canConfigureIndicators && /* @__PURE__ */ e(_, { variant: "outlined", startIcon: /* @__PURE__ */ e(D, { icon: on }), onClick: () => ce(!0), children: "Configure" })
979
+ ] })
980
+ ]
981
+ }
982
+ ),
983
+ !Se && /* @__PURE__ */ r(
984
+ Y,
985
+ {
986
+ onClick: () => re(!0),
987
+ sx: {
988
+ position: "fixed",
989
+ right: 0,
990
+ top: "50%",
991
+ transform: "translateY(-50%)",
992
+ zIndex: (n) => n.zIndex.drawer - 1,
993
+ display: "flex",
994
+ alignItems: "center",
995
+ gap: 0.75,
996
+ px: 1,
997
+ py: 2,
998
+ cursor: "pointer",
999
+ bgcolor: "primary.main",
1000
+ color: "primary.contrastText",
1001
+ borderTopLeftRadius: 8,
1002
+ borderBottomLeftRadius: 8,
1003
+ boxShadow: 3,
1004
+ writingMode: "vertical-rl",
1005
+ "&:hover": { bgcolor: "primary.dark" }
1006
+ },
1007
+ children: [
1008
+ /* @__PURE__ */ e(D, { icon: sn, size: "sm", style: { writingMode: "horizontal-tb" } }),
1009
+ /* @__PURE__ */ e(f, { variant: "body2", fontWeight: 700, sx: { letterSpacing: 0.5 }, children: "Select Location" })
1010
+ ]
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ r(
1014
+ Xt,
1015
+ {
1016
+ anchor: "right",
1017
+ open: Se,
1018
+ onClose: () => re(!1),
1019
+ PaperProps: {
1020
+ sx: {
1021
+ width: { xs: "100%", sm: 420 },
1022
+ p: 2.5,
1023
+ display: "flex",
1024
+ flexDirection: "column"
1025
+ }
1026
+ },
1027
+ children: [
1028
+ /* @__PURE__ */ r(N, { direction: "row", alignItems: "center", justifyContent: "space-between", sx: { mb: 1 }, children: [
1029
+ /* @__PURE__ */ e(f, { variant: "h6", children: "Select Location" }),
1030
+ /* @__PURE__ */ e(bt, { size: "small", onClick: () => re(!1), children: /* @__PURE__ */ e(D, { icon: ln, size: "sm" }) })
1031
+ ] }),
1032
+ /* @__PURE__ */ e(me, { sx: { mb: 2 } }),
1033
+ /* @__PURE__ */ r(Y, { sx: { flex: 1, overflowY: "auto" }, children: [
1034
+ /* @__PURE__ */ e(Ht, { fallback: null, children: /* @__PURE__ */ e(
1035
+ Pn,
1036
+ {
1037
+ selectedLocation: i,
1038
+ setSelectedLocation: s,
1039
+ locations: d,
1040
+ setLocations: k,
1041
+ fetchAccordingToUserAoi: !0,
1042
+ fetchUptoLevel: 5,
1043
+ requiredUptoLevel: 1
1044
+ }
1045
+ ) }),
1046
+ /* @__PURE__ */ r(Ue, { fullWidth: !0, required: !0, error: Ie && !h, sx: { mt: 2 }, children: [
1047
+ /* @__PURE__ */ e(Be, { id: "lwet-financial-year-label", children: "Select Financial Year" }),
1048
+ /* @__PURE__ */ r(
1049
+ je,
1050
+ {
1051
+ labelId: "lwet-financial-year-label",
1052
+ label: "Select Financial Year",
1053
+ value: h,
1054
+ onChange: (n) => T(n.target.value),
1055
+ children: [
1056
+ /* @__PURE__ */ e(fe, { value: "", children: /* @__PURE__ */ e("em", { children: "--Select--" }) }),
1057
+ C.map((n) => /* @__PURE__ */ e(fe, { value: n, children: n }, n))
1058
+ ]
1059
+ }
1060
+ ),
1061
+ Ie && !h && /* @__PURE__ */ e(Zt, { children: "Please select financial year" })
1062
+ ] })
1063
+ ] }),
1064
+ /* @__PURE__ */ e(me, { sx: { my: 2 } }),
1065
+ /* @__PURE__ */ r(N, { direction: "row", spacing: 1, justifyContent: "flex-end", children: [
1066
+ /* @__PURE__ */ e(_, { variant: "outlined", color: "inherit", onClick: () => re(!1), children: "Close" }),
1067
+ /* @__PURE__ */ e(_, { variant: "contained", disabled: z, onClick: he, children: z ? "Searching..." : "Search" })
1068
+ ] })
1069
+ ]
1070
+ }
1071
+ ),
1072
+ !S && /* @__PURE__ */ e(
1073
+ le,
1074
+ {
1075
+ variant: "outlined",
1076
+ sx: { p: 5, textAlign: "center", borderRadius: 2, borderStyle: "dashed" },
1077
+ children: /* @__PURE__ */ e(f, { color: "text.secondary", children: "Pick a location and financial year to load targets." })
1078
+ }
1079
+ ),
1080
+ S && P.length === 0 && /* @__PURE__ */ e(
1081
+ le,
1082
+ {
1083
+ variant: "outlined",
1084
+ sx: { p: 4, textAlign: "center", borderRadius: 2, borderStyle: "dashed" },
1085
+ children: /* @__PURE__ */ r(f, { color: "text.secondary", children: [
1086
+ "No indicators are configured for this implementation yet.",
1087
+ t.canConfigureIndicators ? " Use “Configure” above to add some." : " Ask an admin to configure them."
1088
+ ] })
1089
+ }
1090
+ ),
1091
+ S && m && b.length > 0 && /* @__PURE__ */ r(le, { variant: "outlined", sx: { borderRadius: 2, mb: 3, overflow: "hidden" }, children: [
1092
+ /* @__PURE__ */ e(
1093
+ N,
1094
+ {
1095
+ direction: "row",
1096
+ alignItems: "center",
1097
+ justifyContent: "space-between",
1098
+ sx: { px: 1.5, py: 1, bgcolor: Ge },
1099
+ children: /* @__PURE__ */ e(N, { direction: "row", alignItems: "center", spacing: 1, children: /* @__PURE__ */ r(f, { variant: "subtitle2", fontWeight: 700, children: [
1100
+ "Target for ",
1101
+ E || "selected location"
1102
+ ] }) })
1103
+ }
1104
+ ),
1105
+ /* @__PURE__ */ e(me, {}),
1106
+ /* @__PURE__ */ e(nt, { children: /* @__PURE__ */ r(at, { size: "small", sx: gt, children: [
1107
+ /* @__PURE__ */ e(it, { children: /* @__PURE__ */ r(te, { children: [
1108
+ /* @__PURE__ */ e(w, { sx: { width: 56 }, children: "#" }),
1109
+ /* @__PURE__ */ e(w, { sx: { minWidth: 180 }, children: "Location Name" }),
1110
+ b.map((n) => /* @__PURE__ */ e(w, { children: n.label }, n.code))
1111
+ ] }) }),
1112
+ /* @__PURE__ */ e(rt, { children: /* @__PURE__ */ r(te, { children: [
1113
+ /* @__PURE__ */ e(w, {}),
1114
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ r(N, { direction: "row", alignItems: "center", justifyContent: "space-between", children: [
1115
+ /* @__PURE__ */ e("span", { children: E || "Selected location" }),
1116
+ V === G && /* @__PURE__ */ e(Y, { component: "span", sx: { color: "error.main", display: "inline-flex" }, children: /* @__PURE__ */ e(D, { icon: Te, size: "sm" }) })
1117
+ ] }) }),
1118
+ b.map((n) => {
1119
+ var c;
1120
+ return /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
1121
+ ye,
1122
+ {
1123
+ type: "text",
1124
+ inputMode: "numeric",
1125
+ size: "small",
1126
+ sx: yt,
1127
+ disabled: !Rt,
1128
+ value: ((c = m.values) == null ? void 0 : c[n.code]) ?? "",
1129
+ onChange: (g) => Wt(n.code, g.target.value)
1130
+ }
1131
+ ) }, n.code);
1132
+ })
1133
+ ] }) })
1134
+ ] }) }),
1135
+ !J && !p && /* @__PURE__ */ e(f, { variant: "caption", color: "text.secondary", sx: { display: "block", px: 1.5, py: 1 }, children: "This location's own target is set when its parent distributes targets, so it can't be entered here. Only the top level of the hierarchy enters its target directly." }),
1136
+ !J && p && /* @__PURE__ */ r(f, { variant: "caption", color: "text.secondary", sx: { display: "block", px: 1.5, py: 1 }, children: [
1137
+ "This value is calculated automatically as the sum of its",
1138
+ " ",
1139
+ x === q ? "facilities" : "child locations",
1140
+ " - it updates whenever the ",
1141
+ x === q ? "facilities" : "locations",
1142
+ " ",
1143
+ "below it are saved."
1144
+ ] }),
1145
+ J && /* @__PURE__ */ r(N, { direction: "row", spacing: 1, justifyContent: "center", sx: { py: 1.5 }, children: [
1146
+ V === K && t.canUpdate && /* @__PURE__ */ e(_, { size: "small", variant: "outlined", onClick: () => Qe(K), children: "Save" }),
1147
+ t.canUpdate && (V === K || V === se) && /* @__PURE__ */ e(
1148
+ _,
1149
+ {
1150
+ size: "small",
1151
+ variant: "contained",
1152
+ disableElevation: !0,
1153
+ startIcon: /* @__PURE__ */ e(D, { icon: Te, style: { fontSize: 16 } }),
1154
+ onClick: () => Qe(G),
1155
+ children: "Save & Lock"
1156
+ }
1157
+ ),
1158
+ t.canUpdate && t.canUnlock && V === G && /* @__PURE__ */ e(
1159
+ _,
1160
+ {
1161
+ size: "small",
1162
+ variant: "outlined",
1163
+ color: "warning",
1164
+ startIcon: /* @__PURE__ */ e(D, { icon: ot, style: { fontSize: 16 } }),
1165
+ onClick: () => ee("parent"),
1166
+ children: "Unlock"
1167
+ }
1168
+ )
1169
+ ] })
1170
+ ] }),
1171
+ S && b.length > 0 && O.length === 0 && (!p || !J) && /* @__PURE__ */ e(
1172
+ le,
1173
+ {
1174
+ variant: "outlined",
1175
+ sx: { p: 3, textAlign: "center", borderRadius: 2, borderStyle: "dashed", mt: 2 },
1176
+ children: /* @__PURE__ */ e(f, { variant: "body2", color: "text.secondary", children: x === q ? p ? "This location has no active facilities to enter values for." : "This location has no active facilities, so there is nothing to distribute to." : "This location has no child locations, so there is nothing to distribute to." })
1177
+ }
1178
+ ),
1179
+ S && O.length > 0 && b.length > 0 && /* @__PURE__ */ r(le, { variant: "outlined", sx: { borderRadius: 2, overflow: "hidden" }, children: [
1180
+ /* @__PURE__ */ r(
1181
+ N,
1182
+ {
1183
+ direction: "row",
1184
+ alignItems: "center",
1185
+ justifyContent: "space-between",
1186
+ sx: { px: 1.5, py: 1, bgcolor: Ge },
1187
+ children: [
1188
+ /* @__PURE__ */ r(N, { direction: "row", alignItems: "center", spacing: 1, children: [
1189
+ /* @__PURE__ */ e(f, { variant: "subtitle2", fontWeight: 700, children: "Targets to be distributed" }),
1190
+ /* @__PURE__ */ e(
1191
+ Ee,
1192
+ {
1193
+ size: "small",
1194
+ variant: "outlined",
1195
+ label: `${O.length} ${x === q ? "facilities" : "locations"}`
1196
+ }
1197
+ )
1198
+ ] }),
1199
+ !p && V !== G && (J ? /* @__PURE__ */ e(f, { variant: "caption", color: "text.secondary", children: "Lock the target above to start distributing it" }) : /* @__PURE__ */ r(f, { variant: "caption", color: "warning.main", sx: { maxWidth: 520, textAlign: "right" }, children: [
1200
+ "This location's own target is ",
1201
+ V === se ? "reopened" : "still in draft",
1202
+ ", so it can't be distributed yet. Someone at the level above needs to lock it (select the parent location and use Save & Lock)."
1203
+ ] }))
1204
+ ]
1205
+ }
1206
+ ),
1207
+ /* @__PURE__ */ e(me, {}),
1208
+ /* @__PURE__ */ e(nt, { sx: { maxHeight: 520 }, children: /* @__PURE__ */ r(at, { size: "small", stickyHeader: !0, sx: gt, children: [
1209
+ /* @__PURE__ */ e(it, { children: /* @__PURE__ */ r(te, { children: [
1210
+ /* @__PURE__ */ e(w, { sx: { fontWeight: 700, width: 56 }, children: "#" }),
1211
+ /* @__PURE__ */ e(w, { sx: { fontWeight: 700, minWidth: 180 }, children: x === q ? "Facility Name" : "Location Name" }),
1212
+ b.map((n) => /* @__PURE__ */ e(w, { sx: { fontWeight: 700 }, children: n.label }, n.code))
1213
+ ] }) }),
1214
+ /* @__PURE__ */ r(rt, { children: [
1215
+ O.map((n, c) => {
1216
+ const g = p && x !== q && (!n.isLeaf || M);
1217
+ return /* @__PURE__ */ r(te, { hover: !0, children: [
1218
+ /* @__PURE__ */ e(w, { children: c + 1 }),
1219
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ r(N, { direction: "row", alignItems: "center", justifyContent: "space-between", children: [
1220
+ /* @__PURE__ */ e("span", { children: n.name }),
1221
+ n.state === G && /* @__PURE__ */ e(Y, { component: "span", sx: { color: "error.main", display: "inline-flex" }, children: /* @__PURE__ */ e(D, { icon: Te, size: "sm" }) })
1222
+ ] }) }),
1223
+ b.map((I) => {
1224
+ var A;
1225
+ return /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
1226
+ ye,
1227
+ {
1228
+ type: "text",
1229
+ inputMode: "numeric",
1230
+ size: "small",
1231
+ sx: yt,
1232
+ disabled: g || !Ae || n.state === G,
1233
+ value: ((A = n.values) == null ? void 0 : A[I.code]) ?? "",
1234
+ onChange: (U) => At(n.id, I.code, U.target.value)
1235
+ }
1236
+ ) }, I.code);
1237
+ })
1238
+ ] }, n.id);
1239
+ }),
1240
+ /* @__PURE__ */ r(te, { sx: { bgcolor: "action.hover" }, children: [
1241
+ /* @__PURE__ */ e(w, {}),
1242
+ /* @__PURE__ */ e(w, { sx: { fontWeight: 700 }, children: "Total" }),
1243
+ b.map((n) => /* @__PURE__ */ e(w, { sx: { fontWeight: 700 }, children: ke[n.code] }, n.code))
1244
+ ] }),
1245
+ !p && /* @__PURE__ */ r(te, { sx: { bgcolor: "action.hover" }, children: [
1246
+ /* @__PURE__ */ e(w, {}),
1247
+ /* @__PURE__ */ e(w, { sx: { fontWeight: 700 }, children: "Difference" }),
1248
+ b.map((n) => /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
1249
+ Ee,
1250
+ {
1251
+ size: "small",
1252
+ label: be[n.code],
1253
+ color: be[n.code] === 0 ? "success" : "error"
1254
+ }
1255
+ ) }, n.code))
1256
+ ] }),
1257
+ X.length > 0 && de === K && Ae && t.canUpdate && /* @__PURE__ */ r(te, { children: [
1258
+ /* @__PURE__ */ e(w, {}),
1259
+ /* @__PURE__ */ e(w, {}),
1260
+ b.map((n) => /* @__PURE__ */ e(w, { align: "center", children: /* @__PURE__ */ e(
1261
+ _,
1262
+ {
1263
+ size: "small",
1264
+ variant: "outlined",
1265
+ startIcon: /* @__PURE__ */ e(D, { icon: cn, style: { fontSize: 14 } }),
1266
+ onClick: () => Mt(n.code),
1267
+ sx: {
1268
+ py: 0.1,
1269
+ px: 1,
1270
+ fontSize: 11,
1271
+ minWidth: 0,
1272
+ "& .MuiButton-startIcon": { mr: 0.5 }
1273
+ },
1274
+ children: "Save"
1275
+ }
1276
+ ) }, n.code))
1277
+ ] }),
1278
+ /* @__PURE__ */ e(te, { children: /* @__PURE__ */ e(w, { align: "center", colSpan: b.length + 2, children: /* @__PURE__ */ r(N, { direction: "row", spacing: 1, justifyContent: "center", sx: { py: 0.5 }, children: [
1279
+ t.canUpdate && Ae && X.length > 0 && (de === K || de === se) && /* @__PURE__ */ e(
1280
+ _,
1281
+ {
1282
+ size: "small",
1283
+ variant: "contained",
1284
+ disableElevation: !0,
1285
+ startIcon: /* @__PURE__ */ e(D, { icon: Te, style: { fontSize: 16 } }),
1286
+ onClick: Ut,
1287
+ children: "Save & Lock"
1288
+ }
1289
+ ),
1290
+ t.canUpdate && t.canUnlock && de === G && /* @__PURE__ */ e(
1291
+ _,
1292
+ {
1293
+ size: "small",
1294
+ variant: "outlined",
1295
+ color: "warning",
1296
+ startIcon: /* @__PURE__ */ e(D, { icon: ot, style: { fontSize: 16 } }),
1297
+ onClick: () => ee("children"),
1298
+ children: "Unlock"
1299
+ }
1300
+ )
1301
+ ] }) }) })
1302
+ ] })
1303
+ ] }) })
1304
+ ] }),
1305
+ /* @__PURE__ */ r($e, { open: !!xe, onClose: () => ee(null), maxWidth: "xs", fullWidth: !0, children: [
1306
+ /* @__PURE__ */ e(He, { children: "Confirm" }),
1307
+ /* @__PURE__ */ e(Ke, { children: /* @__PURE__ */ e(f, { variant: "body2", children: "Are you sure you want to unlock the data for editing?" }) }),
1308
+ /* @__PURE__ */ r(xt, { children: [
1309
+ /* @__PURE__ */ e(_, { color: "inherit", onClick: () => ee(null), children: "Cancel" }),
1310
+ /* @__PURE__ */ e(
1311
+ _,
1312
+ {
1313
+ variant: "contained",
1314
+ color: "warning",
1315
+ disableElevation: !0,
1316
+ onClick: () => {
1317
+ const n = xe;
1318
+ ee(null), n === "parent" ? Pt() : Bt();
1319
+ },
1320
+ children: "Unlock"
1321
+ }
1322
+ )
1323
+ ] })
1324
+ ] }),
1325
+ /* @__PURE__ */ r($e, { open: ve, onClose: () => ce(!1), maxWidth: "md", fullWidth: !0, children: [
1326
+ /* @__PURE__ */ e(He, { sx: { pb: 1 }, children: "Configure" }),
1327
+ /* @__PURE__ */ e(Ke, { dividers: !0, children: /* @__PURE__ */ e(
1328
+ _t,
1329
+ {
1330
+ onSaved: ({ indicators: n, settings: c }) => {
1331
+ L(n), c && u(c), ce(!1), S && he();
1332
+ }
1333
+ }
1334
+ ) })
1335
+ ] })
1336
+ ] });
1337
+ }
1338
+ function ia() {
1339
+ return /* @__PURE__ */ e(kt, { perm: ge.VIEW, children: /* @__PURE__ */ e(Mn, {}) });
1340
+ }
1341
+ export {
1342
+ ia as default
1343
+ };
1344
+ //# sourceMappingURL=LocationWiseExpectedTargetPage-CjKk1aTF.js.map