@atlashub/smartstack 3.21.0 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js → AgentSkillsPage-BWQSCYl-.js} +2 -2
  2. package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js.map → AgentSkillsPage-BWQSCYl-.js.map} +1 -1
  3. package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js → AgentSkillsPage-IQcMnBaD.js} +2 -2
  4. package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js.map → AgentSkillsPage-IQcMnBaD.js.map} +1 -1
  5. package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js → AgentWorkloadPage-DqrjkvWL.js} +2 -2
  6. package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js.map → AgentWorkloadPage-DqrjkvWL.js.map} +1 -1
  7. package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js → AgentWorkloadPage-w-HiyFYP.js} +2 -2
  8. package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js.map → AgentWorkloadPage-w-HiyFYP.js.map} +1 -1
  9. package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js → ApiCatalogDetailPage-D3L8Yf4G.js} +3 -3
  10. package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js.map → ApiCatalogDetailPage-D3L8Yf4G.js.map} +1 -1
  11. package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js → ApiCatalogDetailPage-MPT3Kz6H.js} +2 -2
  12. package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js.map → ApiCatalogDetailPage-MPT3Kz6H.js.map} +1 -1
  13. package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js → ApiCatalogPage-D4Hg3uiS.js} +2 -2
  14. package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js.map → ApiCatalogPage-D4Hg3uiS.js.map} +1 -1
  15. package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js → ApiCatalogPage-DRg5Cz0r.js} +2 -2
  16. package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js.map → ApiCatalogPage-DRg5Cz0r.js.map} +1 -1
  17. package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js → ApplicationDetailPage-Caizuyn2.js} +2 -2
  18. package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js.map → ApplicationDetailPage-Caizuyn2.js.map} +1 -1
  19. package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js → ApplicationDetailPage-CuCW6aMB.js} +4 -4
  20. package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js.map → ApplicationDetailPage-CuCW6aMB.js.map} +1 -1
  21. package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js → ApplicationsDashboardPage-B2MW8-Kc.js} +2 -2
  22. package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js.map → ApplicationsDashboardPage-B2MW8-Kc.js.map} +1 -1
  23. package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js → ApplicationsDashboardPage-BDIjFIYZ.js} +3 -3
  24. package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js.map → ApplicationsDashboardPage-BDIjFIYZ.js.map} +1 -1
  25. package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js → ApplicationsGridPage-DV-FihKj.js} +2 -2
  26. package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js.map → ApplicationsGridPage-DV-FihKj.js.map} +1 -1
  27. package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js → ApplicationsGridPage-DXsTfXPI.js} +2 -2
  28. package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js.map → ApplicationsGridPage-DXsTfXPI.js.map} +1 -1
  29. package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js → ApplicationsListPage--CGkyBuJ.js} +2 -2
  30. package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js.map → ApplicationsListPage--CGkyBuJ.js.map} +1 -1
  31. package/dist/chunks/{ApplicationsListPage-C91v2rZt.js → ApplicationsListPage-JUX823bh.js} +2 -2
  32. package/dist/chunks/{ApplicationsListPage-C91v2rZt.js.map → ApplicationsListPage-JUX823bh.js.map} +1 -1
  33. package/dist/chunks/{ApplicationsPage-BCbgotIx.js → ApplicationsPage-6zgFye6w.js} +2 -2
  34. package/dist/chunks/{ApplicationsPage-BCbgotIx.js.map → ApplicationsPage-6zgFye6w.js.map} +1 -1
  35. package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js → ApplicationsPage-CQPuuiO6.js} +4 -4
  36. package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js.map → ApplicationsPage-CQPuuiO6.js.map} +1 -1
  37. package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js → AssignmentRulesPage-CFffeEbo.js} +2 -2
  38. package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js.map → AssignmentRulesPage-CFffeEbo.js.map} +1 -1
  39. package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js → AssignmentRulesPage-D78UeUId.js} +2 -2
  40. package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js.map → AssignmentRulesPage-D78UeUId.js.map} +1 -1
  41. package/dist/chunks/{AssignmentsPage-DmfBYQAD.js → AssignmentsPage-Cww2ifZF.js} +2 -2
  42. package/dist/chunks/{AssignmentsPage-DmfBYQAD.js.map → AssignmentsPage-Cww2ifZF.js.map} +1 -1
  43. package/dist/chunks/{AssignmentsPage-sRCCBmRc.js → AssignmentsPage-DE_QS2LO.js} +2 -2
  44. package/dist/chunks/{AssignmentsPage-sRCCBmRc.js.map → AssignmentsPage-DE_QS2LO.js.map} +1 -1
  45. package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js → AuthCallbackPage-CA2nO6DG.js} +2 -2
  46. package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js.map → AuthCallbackPage-CA2nO6DG.js.map} +1 -1
  47. package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js → AuthCallbackPage-CDUAoX-N.js} +2 -2
  48. package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js.map → AuthCallbackPage-CDUAoX-N.js.map} +1 -1
  49. package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js → ConfirmEmailPage-BqsILAYH.js} +2 -2
  50. package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js.map → ConfirmEmailPage-BqsILAYH.js.map} +1 -1
  51. package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js → ConfirmEmailPage-INeHCuMB.js} +2 -2
  52. package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js.map → ConfirmEmailPage-INeHCuMB.js.map} +1 -1
  53. package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js → CreateSupportTicketPage-BWeuV2aU.js} +2 -2
  54. package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js.map → CreateSupportTicketPage-BWeuV2aU.js.map} +1 -1
  55. package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js → CreateSupportTicketPage-OBwF4v7b.js} +2 -2
  56. package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js.map → CreateSupportTicketPage-OBwF4v7b.js.map} +1 -1
  57. package/dist/chunks/{DashboardPage-CUZ80NGV.js → DashboardPage-CKHqWrdS.js} +3 -3
  58. package/dist/chunks/{DashboardPage-CUZ80NGV.js.map → DashboardPage-CKHqWrdS.js.map} +1 -1
  59. package/dist/chunks/{DashboardPage-CaNOAstg.js → DashboardPage-COmc9b__.js} +3 -3
  60. package/dist/chunks/{DashboardPage-CaNOAstg.js.map → DashboardPage-COmc9b__.js.map} +1 -1
  61. package/dist/chunks/{DashboardPage-B48_rQFi.js → DashboardPage-CfKZHiSj.js} +2 -2
  62. package/dist/chunks/{DashboardPage-B48_rQFi.js.map → DashboardPage-CfKZHiSj.js.map} +1 -1
  63. package/dist/chunks/{DashboardPage-CUZV1J9t.js → DashboardPage-CwEZZ3jx.js} +2 -2
  64. package/dist/chunks/{DashboardPage-CUZV1J9t.js.map → DashboardPage-CwEZZ3jx.js.map} +1 -1
  65. package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js → EscalationConfigPage--7lgZ0kJ.js} +2 -2
  66. package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js.map → EscalationConfigPage--7lgZ0kJ.js.map} +1 -1
  67. package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js → EscalationConfigPage-DPyiBcqV.js} +2 -2
  68. package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js.map → EscalationConfigPage-DPyiBcqV.js.map} +1 -1
  69. package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js → ForceChangePasswordPage-BE-6umub.js} +2 -2
  70. package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js.map → ForceChangePasswordPage-BE-6umub.js.map} +1 -1
  71. package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js → ForceChangePasswordPage-CnsYoWmV.js} +2 -2
  72. package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js.map → ForceChangePasswordPage-CnsYoWmV.js.map} +1 -1
  73. package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js → ForgotPasswordPage-CSq4DnFF.js} +2 -2
  74. package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js.map → ForgotPasswordPage-CSq4DnFF.js.map} +1 -1
  75. package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js → ForgotPasswordPage-DZLVolAC.js} +2 -2
  76. package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js.map → ForgotPasswordPage-DZLVolAC.js.map} +1 -1
  77. package/dist/chunks/{GroupDetailPage-DFBvVO1S.js → GroupDetailPage-Bf9Wb_2j.js} +5 -5
  78. package/dist/chunks/{GroupDetailPage-DFBvVO1S.js.map → GroupDetailPage-Bf9Wb_2j.js.map} +1 -1
  79. package/dist/chunks/{GroupDetailPage-B2FkKrGG.js → GroupDetailPage-R-hf3rJ7.js} +2 -2
  80. package/dist/chunks/{GroupDetailPage-B2FkKrGG.js.map → GroupDetailPage-R-hf3rJ7.js.map} +1 -1
  81. package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js → MyAccessRequestsPage-BIisvWM6.js} +2 -2
  82. package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js.map → MyAccessRequestsPage-BIisvWM6.js.map} +1 -1
  83. package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js → MyAccessRequestsPage-BLSV7Tbx.js} +2 -2
  84. package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js.map → MyAccessRequestsPage-BLSV7Tbx.js.map} +1 -1
  85. package/dist/chunks/{MyTenantsPage-BEcYYdGR.js → MyTenantsPage-D-7k9CP1.js} +3 -3
  86. package/dist/chunks/{MyTenantsPage-BEcYYdGR.js.map → MyTenantsPage-D-7k9CP1.js.map} +1 -1
  87. package/dist/chunks/{MyTenantsPage-D9f85zjF.js → MyTenantsPage-DqGW6aDt.js} +2 -2
  88. package/dist/chunks/{MyTenantsPage-D9f85zjF.js.map → MyTenantsPage-DqGW6aDt.js.map} +1 -1
  89. package/dist/chunks/{MyTicketsPage-DJR8h6y1.js → MyTicketsPage--DgDsnZA.js} +2 -2
  90. package/dist/chunks/{MyTicketsPage-DJR8h6y1.js.map → MyTicketsPage--DgDsnZA.js.map} +1 -1
  91. package/dist/chunks/{MyTicketsPage-DiOUExKJ.js → MyTicketsPage-CqJ3Aqob.js} +2 -2
  92. package/dist/chunks/{MyTicketsPage-DiOUExKJ.js.map → MyTicketsPage-CqJ3Aqob.js.map} +1 -1
  93. package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js → NavigationAppsPage-Bebis_RT.js} +2 -2
  94. package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js.map → NavigationAppsPage-Bebis_RT.js.map} +1 -1
  95. package/dist/chunks/{NavigationAppsPage-If7tmCFY.js → NavigationAppsPage-THNPOAjv.js} +2 -2
  96. package/dist/chunks/{NavigationAppsPage-If7tmCFY.js.map → NavigationAppsPage-THNPOAjv.js.map} +1 -1
  97. package/dist/chunks/{NotificationsPage-C29Lln5o.js → NotificationsPage-CAbNW_Cn.js} +2 -2
  98. package/dist/chunks/{NotificationsPage-C29Lln5o.js.map → NotificationsPage-CAbNW_Cn.js.map} +1 -1
  99. package/dist/chunks/{NotificationsPage-BiaLRb0s.js → NotificationsPage-DxwizUhL.js} +2 -2
  100. package/dist/chunks/{NotificationsPage-BiaLRb0s.js.map → NotificationsPage-DxwizUhL.js.map} +1 -1
  101. package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js → OnboardingWizardPage-C6HlbJ3K.js} +2 -2
  102. package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js.map → OnboardingWizardPage-C6HlbJ3K.js.map} +1 -1
  103. package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js → OnboardingWizardPage-CyC2zONO.js} +2 -2
  104. package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js.map → OnboardingWizardPage-CyC2zONO.js.map} +1 -1
  105. package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js → PermissionDetailPage-BDHiNgky.js} +2 -2
  106. package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js.map → PermissionDetailPage-BDHiNgky.js.map} +1 -1
  107. package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js → PermissionDetailPage-C5K17ydY.js} +2 -2
  108. package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js.map → PermissionDetailPage-C5K17ydY.js.map} +1 -1
  109. package/dist/chunks/{PermissionsPage-l0PnY-EE.js → PermissionsPage-COI5LJPo.js} +2 -2
  110. package/dist/chunks/{PermissionsPage-l0PnY-EE.js.map → PermissionsPage-COI5LJPo.js.map} +1 -1
  111. package/dist/chunks/{PermissionsPage-DLy9U3P3.js → PermissionsPage-CkOwH2_d.js} +2 -2
  112. package/dist/chunks/{PermissionsPage-DLy9U3P3.js.map → PermissionsPage-CkOwH2_d.js.map} +1 -1
  113. package/dist/chunks/{PortalDashboardPage-DFBx38-x.js → PortalDashboardPage-CoEC4CmC.js} +2 -2
  114. package/dist/chunks/{PortalDashboardPage-DFBx38-x.js.map → PortalDashboardPage-CoEC4CmC.js.map} +1 -1
  115. package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js → PortalDashboardPage-DrYymEf-.js} +2 -2
  116. package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js.map → PortalDashboardPage-DrYymEf-.js.map} +1 -1
  117. package/dist/chunks/{PreferencesPage-BBu8yZQB.js → PreferencesPage-CJRaU3ba.js} +2 -2
  118. package/dist/chunks/{PreferencesPage-BBu8yZQB.js.map → PreferencesPage-CJRaU3ba.js.map} +1 -1
  119. package/dist/chunks/{PreferencesPage-B81MsNV1.js → PreferencesPage-Cqr9mAab.js} +2 -2
  120. package/dist/chunks/{PreferencesPage-B81MsNV1.js.map → PreferencesPage-Cqr9mAab.js.map} +1 -1
  121. package/dist/chunks/{ProfilePage-DDrl10zj.js → ProfilePage-BZVpg6-l.js} +2 -2
  122. package/dist/chunks/{ProfilePage-DDrl10zj.js.map → ProfilePage-BZVpg6-l.js.map} +1 -1
  123. package/dist/chunks/{ProfilePage-DPoXwdnc.js → ProfilePage-Cu_FITeL.js} +2 -2
  124. package/dist/chunks/{ProfilePage-DPoXwdnc.js.map → ProfilePage-Cu_FITeL.js.map} +1 -1
  125. package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js → ReferencesManagementPage-DUlVk9Ps.js} +3 -3
  126. package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js.map → ReferencesManagementPage-DUlVk9Ps.js.map} +1 -1
  127. package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js → ReferencesManagementPage-ZCuYtqd7.js} +2 -2
  128. package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js.map → ReferencesManagementPage-ZCuYtqd7.js.map} +1 -1
  129. package/dist/chunks/{RegisterPage-CiQib3-6.js → RegisterPage-C4xmVwh9.js} +2 -2
  130. package/dist/chunks/{RegisterPage-CiQib3-6.js.map → RegisterPage-C4xmVwh9.js.map} +1 -1
  131. package/dist/chunks/{RegisterPage-bXCcJD88.js → RegisterPage-DGyzoIHT.js} +2 -2
  132. package/dist/chunks/{RegisterPage-bXCcJD88.js.map → RegisterPage-DGyzoIHT.js.map} +1 -1
  133. package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js → ResetPasswordPage-DqDD6VPR.js} +2 -2
  134. package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js.map → ResetPasswordPage-DqDD6VPR.js.map} +1 -1
  135. package/dist/chunks/{ResetPasswordPage-CubPG3yv.js → ResetPasswordPage-Glu-aeqv.js} +2 -2
  136. package/dist/chunks/{ResetPasswordPage-CubPG3yv.js.map → ResetPasswordPage-Glu-aeqv.js.map} +1 -1
  137. package/dist/chunks/{ResolutionModal-Bg7XZmR1.js → ResolutionModal-CxjANAOP.js} +2 -2
  138. package/dist/chunks/{ResolutionModal-Bg7XZmR1.js.map → ResolutionModal-CxjANAOP.js.map} +1 -1
  139. package/dist/chunks/{ResolutionModal-DqRk_T0n.js → ResolutionModal-Duat18qV.js} +2 -2
  140. package/dist/chunks/{ResolutionModal-DqRk_T0n.js.map → ResolutionModal-Duat18qV.js.map} +1 -1
  141. package/dist/chunks/{RoleDetailPage-Blau6_4c.js → RoleDetailPage-BQffUSnt.js} +3 -3
  142. package/dist/chunks/{RoleDetailPage-Blau6_4c.js.map → RoleDetailPage-BQffUSnt.js.map} +1 -1
  143. package/dist/chunks/{RoleDetailPage-CiRVxxIP.js → RoleDetailPage-JTm5lD1_.js} +2 -2
  144. package/dist/chunks/{RoleDetailPage-CiRVxxIP.js.map → RoleDetailPage-JTm5lD1_.js.map} +1 -1
  145. package/dist/chunks/{RolesPage-Pm-RN3lP.js → RolesPage-B9rRzciI.js} +2 -2
  146. package/dist/chunks/{RolesPage-Pm-RN3lP.js.map → RolesPage-B9rRzciI.js.map} +1 -1
  147. package/dist/chunks/{RolesPage-Cb8joqdJ.js → RolesPage-BN8_zMOC.js} +2 -2
  148. package/dist/chunks/{RolesPage-Cb8joqdJ.js.map → RolesPage-BN8_zMOC.js.map} +1 -1
  149. package/dist/chunks/{SlaConfigPage-B86McKM6.js → SlaConfigPage-B7kZNig4.js} +2 -2
  150. package/dist/chunks/{SlaConfigPage-B86McKM6.js.map → SlaConfigPage-B7kZNig4.js.map} +1 -1
  151. package/dist/chunks/{SlaConfigPage-BY7gvYU6.js → SlaConfigPage-okvZfA_K.js} +2 -2
  152. package/dist/chunks/{SlaConfigPage-BY7gvYU6.js.map → SlaConfigPage-okvZfA_K.js.map} +1 -1
  153. package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js → SupportPermissionsPage-DGAPqJbl.js} +2 -2
  154. package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js.map → SupportPermissionsPage-DGAPqJbl.js.map} +1 -1
  155. package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js → SupportPermissionsPage-Dg_wLOme.js} +2 -2
  156. package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js.map → SupportPermissionsPage-Dg_wLOme.js.map} +1 -1
  157. package/dist/chunks/{TemplatesPage-BDguJ401.js → TemplatesPage-DT9fhlAU.js} +2 -2
  158. package/dist/chunks/{TemplatesPage-BDguJ401.js.map → TemplatesPage-DT9fhlAU.js.map} +1 -1
  159. package/dist/chunks/{TemplatesPage-DdnGgioU.js → TemplatesPage-DiEk538p.js} +2 -2
  160. package/dist/chunks/{TemplatesPage-DdnGgioU.js.map → TemplatesPage-DiEk538p.js.map} +1 -1
  161. package/dist/chunks/{TenantCard-ffwWsgFQ.js → TenantCard-BbSYk9_Z.js} +2 -2
  162. package/dist/chunks/{TenantCard-ffwWsgFQ.js.map → TenantCard-BbSYk9_Z.js.map} +1 -1
  163. package/dist/chunks/{TenantCard-CUjb6og9.js → TenantCard-CEkiKxcZ.js} +2 -2
  164. package/dist/chunks/{TenantCard-CUjb6og9.js.map → TenantCard-CEkiKxcZ.js.map} +1 -1
  165. package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js → TenantScopeSelector-BWfYxvEa.js} +2 -2
  166. package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js.map → TenantScopeSelector-BWfYxvEa.js.map} +1 -1
  167. package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js → TenantScopeSelector-D-BKgQPV.js} +2 -2
  168. package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js.map → TenantScopeSelector-D-BKgQPV.js.map} +1 -1
  169. package/dist/chunks/{TicketDetailPage-GOh9GX7E.js → TicketDetailPage-C1mNS9Up.js} +2 -2
  170. package/dist/chunks/{TicketDetailPage-GOh9GX7E.js.map → TicketDetailPage-C1mNS9Up.js.map} +1 -1
  171. package/dist/chunks/{TicketDetailPage-Du8WMyqf.js → TicketDetailPage-ieVDRh42.js} +2 -2
  172. package/dist/chunks/{TicketDetailPage-Du8WMyqf.js.map → TicketDetailPage-ieVDRh42.js.map} +1 -1
  173. package/dist/chunks/{TicketsPage-Bqd6moQy.js → TicketsPage-CnuWsnIW.js} +2 -2
  174. package/dist/chunks/{TicketsPage-Bqd6moQy.js.map → TicketsPage-CnuWsnIW.js.map} +1 -1
  175. package/dist/chunks/{TicketsPage-WdU4Bb7M.js → TicketsPage-jjyY15_D.js} +2 -2
  176. package/dist/chunks/{TicketsPage-WdU4Bb7M.js.map → TicketsPage-jjyY15_D.js.map} +1 -1
  177. package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js → UserCreateTicketPage-B8Tvf-ag.js} +2 -2
  178. package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js.map → UserCreateTicketPage-B8Tvf-ag.js.map} +1 -1
  179. package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js → UserCreateTicketPage-DnOsDlfO.js} +2 -2
  180. package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js.map → UserCreateTicketPage-DnOsDlfO.js.map} +1 -1
  181. package/dist/chunks/{UserDashboardPage-BP5WeXPS.js → UserDashboardPage-BrtkJ-NB.js} +2 -2
  182. package/dist/chunks/{UserDashboardPage-BP5WeXPS.js.map → UserDashboardPage-BrtkJ-NB.js.map} +1 -1
  183. package/dist/chunks/{UserDashboardPage-B53C8fUq.js → UserDashboardPage-KLB5CQP5.js} +2 -2
  184. package/dist/chunks/{UserDashboardPage-B53C8fUq.js.map → UserDashboardPage-KLB5CQP5.js.map} +1 -1
  185. package/dist/chunks/{UserDetailPage-B110bmGX.js → UserDetailPage-U7smBQoF.js} +5 -5
  186. package/dist/chunks/{UserDetailPage-B110bmGX.js.map → UserDetailPage-U7smBQoF.js.map} +1 -1
  187. package/dist/chunks/{UserDetailPage-CV2VCE46.js → UserDetailPage-_J6lcKAU.js} +2 -2
  188. package/dist/chunks/{UserDetailPage-CV2VCE46.js.map → UserDetailPage-_J6lcKAU.js.map} +1 -1
  189. package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js → UserTicketDetailPage-CWoYQgH-.js} +2 -2
  190. package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js.map → UserTicketDetailPage-CWoYQgH-.js.map} +1 -1
  191. package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js → UserTicketDetailPage-DkufSlvZ.js} +2 -2
  192. package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js.map → UserTicketDetailPage-DkufSlvZ.js.map} +1 -1
  193. package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js → UsersGroupsPage-C38s2-Rq.js} +3 -3
  194. package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js.map → UsersGroupsPage-C38s2-Rq.js.map} +1 -1
  195. package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js → UsersGroupsPage-Dq3rAteo.js} +2 -2
  196. package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js.map → UsersGroupsPage-Dq3rAteo.js.map} +1 -1
  197. package/dist/chunks/{UsersPage-Bg7033pp.js → UsersPage-B5C5KEUR.js} +2 -2
  198. package/dist/chunks/{UsersPage-Bg7033pp.js.map → UsersPage-B5C5KEUR.js.map} +1 -1
  199. package/dist/chunks/{UsersPage-TYAfwPY1.js → UsersPage-CXC9Hvq6.js} +2 -2
  200. package/dist/chunks/{UsersPage-TYAfwPY1.js.map → UsersPage-CXC9Hvq6.js.map} +1 -1
  201. package/dist/chunks/{accessRequestsApi-DZeDvzwv.js → accessRequestsApi-B-4TJ5_U.js} +2 -2
  202. package/dist/chunks/{accessRequestsApi-DZeDvzwv.js.map → accessRequestsApi-B-4TJ5_U.js.map} +1 -1
  203. package/dist/chunks/{accessRequestsApi-ZXFPCid2.js → accessRequestsApi-DZSfThpd.js} +2 -2
  204. package/dist/chunks/{accessRequestsApi-ZXFPCid2.js.map → accessRequestsApi-DZSfThpd.js.map} +1 -1
  205. package/dist/chunks/{aiApi-CsH8DXgs.js → aiApi-B20Teu2v.js} +2 -2
  206. package/dist/chunks/{aiApi-CsH8DXgs.js.map → aiApi-B20Teu2v.js.map} +1 -1
  207. package/dist/chunks/{aiApi-CVPzFTXa.js → aiApi-DMGz-RPM.js} +2 -2
  208. package/dist/chunks/{aiApi-CVPzFTXa.js.map → aiApi-DMGz-RPM.js.map} +1 -1
  209. package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js → applicationAnalyticsApi-Bwa75Fzd.js} +2 -2
  210. package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js.map → applicationAnalyticsApi-Bwa75Fzd.js.map} +1 -1
  211. package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js → applicationAnalyticsApi-CLBqRPfN.js} +2 -2
  212. package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js.map → applicationAnalyticsApi-CLBqRPfN.js.map} +1 -1
  213. package/dist/chunks/{groupsApi-BgCk2fsp.js → groupsApi-QzXI-5xu.js} +2 -2
  214. package/dist/chunks/{groupsApi-BgCk2fsp.js.map → groupsApi-QzXI-5xu.js.map} +1 -1
  215. package/dist/chunks/{groupsApi-BIbG665N.js → groupsApi-hB9kSWEd.js} +2 -2
  216. package/dist/chunks/{groupsApi-BIbG665N.js.map → groupsApi-hB9kSWEd.js.map} +1 -1
  217. package/dist/chunks/{index-Cb3LotuT.js → index--NGcBYUu.js} +3 -3
  218. package/dist/chunks/{index-Cb3LotuT.js.map → index--NGcBYUu.js.map} +1 -1
  219. package/dist/chunks/{index-C33zcyF4.js → index--aPwOFjF.js} +2 -2
  220. package/dist/chunks/{index-C33zcyF4.js.map → index--aPwOFjF.js.map} +1 -1
  221. package/dist/chunks/{index-sMr9qND_.js → index-0VrOtwP0.js} +2 -2
  222. package/dist/chunks/{index-sMr9qND_.js.map → index-0VrOtwP0.js.map} +1 -1
  223. package/dist/chunks/{index-DDKetfKq.js → index-37U271aw.js} +2 -2
  224. package/dist/chunks/{index-DDKetfKq.js.map → index-37U271aw.js.map} +1 -1
  225. package/dist/chunks/{index-B9fS7ir6.js → index-B7qZTuQ-.js} +2 -2
  226. package/dist/chunks/{index-B9fS7ir6.js.map → index-B7qZTuQ-.js.map} +1 -1
  227. package/dist/chunks/{index-CdjBY7L8.js → index-Bedzmqr-.js} +2 -2
  228. package/dist/chunks/{index-CdjBY7L8.js.map → index-Bedzmqr-.js.map} +1 -1
  229. package/dist/chunks/{index-CHG_O1fS.js → index-Betxo5g5.js} +2 -2
  230. package/dist/chunks/{index-CHG_O1fS.js.map → index-Betxo5g5.js.map} +1 -1
  231. package/dist/chunks/{index-jiGu-H8x.js → index-BmaJz475.js} +2 -2
  232. package/dist/chunks/{index-jiGu-H8x.js.map → index-BmaJz475.js.map} +1 -1
  233. package/dist/chunks/{index-C53JoVNk.js → index-Buhqag3v.js} +2 -2
  234. package/dist/chunks/{index-C53JoVNk.js.map → index-Buhqag3v.js.map} +1 -1
  235. package/dist/chunks/{index-DO0Rw7hX.js → index-C3VxlfKq.js} +2 -2
  236. package/dist/chunks/{index-DO0Rw7hX.js.map → index-C3VxlfKq.js.map} +1 -1
  237. package/dist/chunks/{index-CSQ60fpG.js → index-CgpRo8Oe.js} +2 -2
  238. package/dist/chunks/{index-CSQ60fpG.js.map → index-CgpRo8Oe.js.map} +1 -1
  239. package/dist/chunks/{index-B-e-ELsf.js → index-DOY0w8Iu.js} +8 -8
  240. package/dist/chunks/{index-B-e-ELsf.js.map → index-DOY0w8Iu.js.map} +1 -1
  241. package/dist/chunks/{index-D2REDIRX.js → index-DwuvIOrQ.js} +2 -2
  242. package/dist/chunks/{index-D2REDIRX.js.map → index-DwuvIOrQ.js.map} +1 -1
  243. package/dist/chunks/{index-DCcl7Qof.js → index-DzedSLdI.js} +2 -2
  244. package/dist/chunks/{index-DCcl7Qof.js.map → index-DzedSLdI.js.map} +1 -1
  245. package/dist/chunks/{index-2wUhd9Lu.js → index-IgLVXPg8.js} +10 -10
  246. package/dist/chunks/index-IgLVXPg8.js.map +1 -0
  247. package/dist/chunks/{index-CwSaRXXg.js → index-lpIzhufD.js} +1916 -1900
  248. package/dist/chunks/index-lpIzhufD.js.map +1 -0
  249. package/dist/chunks/{index-Cuwn2q-f.js → index-mLUKwbGl.js} +4 -4
  250. package/dist/chunks/{index-Cuwn2q-f.js.map → index-mLUKwbGl.js.map} +1 -1
  251. package/dist/chunks/{index-B0mk2tNY.js → index-tO6MMIFB.js} +2 -2
  252. package/dist/chunks/{index-B0mk2tNY.js.map → index-tO6MMIFB.js.map} +1 -1
  253. package/dist/chunks/{tenantIconMap-BpNANQ5s.js → tenantIconMap-BQD9byc8.js} +2 -2
  254. package/dist/chunks/{tenantIconMap-BpNANQ5s.js.map → tenantIconMap-BQD9byc8.js.map} +1 -1
  255. package/dist/chunks/{tenantIconMap-DtdUgvJO.js → tenantIconMap-CTMuSt18.js} +2 -2
  256. package/dist/chunks/{tenantIconMap-DtdUgvJO.js.map → tenantIconMap-CTMuSt18.js.map} +1 -1
  257. package/dist/chunks/{ticketingApi-Bu4rKwLl.js → ticketingApi-BNIdox5t.js} +2 -2
  258. package/dist/chunks/{ticketingApi-Bu4rKwLl.js.map → ticketingApi-BNIdox5t.js.map} +1 -1
  259. package/dist/chunks/{ticketingApi-r4Avm9iS.js → ticketingApi-J0vC_t7r.js} +2 -2
  260. package/dist/chunks/{ticketingApi-r4Avm9iS.js.map → ticketingApi-J0vC_t7r.js.map} +1 -1
  261. package/dist/chunks/{useAccessRequests-B9bF4swg.js → useAccessRequests-DCNNLnxk.js} +3 -3
  262. package/dist/chunks/{useAccessRequests-B9bF4swg.js.map → useAccessRequests-DCNNLnxk.js.map} +1 -1
  263. package/dist/chunks/{useAccessRequests-JyPUX3Om.js → useAccessRequests-DT7X4FAK.js} +2 -2
  264. package/dist/chunks/{useAccessRequests-JyPUX3Om.js.map → useAccessRequests-DT7X4FAK.js.map} +1 -1
  265. package/dist/chunks/{useUserAccessRequests-DjPQenC2.js → useUserAccessRequests-BYbmG4c7.js} +2 -2
  266. package/dist/chunks/{useUserAccessRequests-DjPQenC2.js.map → useUserAccessRequests-BYbmG4c7.js.map} +1 -1
  267. package/dist/chunks/{useUserAccessRequests-BB6FHW14.js → useUserAccessRequests-CylKxRN6.js} +2 -2
  268. package/dist/chunks/{useUserAccessRequests-BB6FHW14.js.map → useUserAccessRequests-CylKxRN6.js.map} +1 -1
  269. package/dist/hooks/useCollapsibleState.d.ts +5 -2
  270. package/dist/hooks/useCollapsibleState.d.ts.map +1 -1
  271. package/dist/i18n/config.d.ts +1 -0
  272. package/dist/i18n/config.d.ts.map +1 -1
  273. package/dist/main.d.ts +0 -1
  274. package/dist/main.d.ts.map +1 -1
  275. package/dist/smartstack.cjs +1 -1
  276. package/dist/smartstack.js +1 -1
  277. package/dist/utils/permissions.d.ts.map +1 -1
  278. package/package.json +1 -1
  279. package/dist/chunks/index-2wUhd9Lu.js.map +0 -1
  280. package/dist/chunks/index-CwSaRXXg.js.map +0 -1
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),B=require("react-router-dom"),E=require("react-i18next"),i=require("lucide-react"),A=require("./index-2wUhd9Lu.js"),Z=require("./useTabNavigation-BVtbCTd5.js"),F=require("./ConfirmModal-CYWRiVoD.js");function X({action:a,navRoute:r,hideIfNoPermission:l=!1,customPermission:t,tooltipPosition:s="top",disabledMessage:d,children:c,disabled:h,className:u="",...b}){const{hasPermission:g}=A.useAuth(),{t:j}=E.useTranslation("common"),f=t??`${r}.${a}`,x=g(f);if(!x&&l)return null;const m=x?void 0:d??j(`permissions.no${Y(a)}Permission`),p=!x||h,w=e.jsx("button",{...b,disabled:p,className:`${u} ${p?"cursor-not-allowed opacity-50":""}`,"aria-disabled":p,children:c});return m?e.jsx(A.Tooltip,{content:m,position:s,variant:"error",disabled:!1,children:w}):w}function Y(a){return a.charAt(0).toUpperCase()+a.slice(1)}const ee=()=>{const a=B.useNavigate(),{t:r}=E.useTranslation("admin"),{currentTenant:l,isGlobalView:t}=A.useTenant(),[s,d]=o.useState([]),[c,h]=o.useState(!0),[u,b]=o.useState(null),[g,j]=o.useState("table"),[f,x]=o.useState(""),[m,p]=o.useState("all"),w=o.useCallback(async()=>{try{h(!0);const n=await A.adminApi.externalApps.getAll({search:f||void 0,isActive:m==="all"?void 0:m==="active"});d(n),b(null)}catch(n){b(n instanceof Error?n.message:"Failed to load external applications")}finally{h(!1)}},[l?.id,t,f,m]);o.useEffect(()=>{w()},[w]);const N=o.useMemo(()=>s.filter(n=>{const S=n.name.toLowerCase().includes(f.toLowerCase())||n.clientId.toLowerCase().includes(f.toLowerCase()),C=m==="all"||m==="active"&&n.isActive||m==="inactive"&&!n.isActive;return S&&C}),[s,f,m]),D=n=>{a(`/api/accounts/${n}`)},T=n=>n?new Date(n).toLocaleDateString():r("externalApps.list.never");return c?e.jsx("div",{className:"flex h-96 items-center justify-center",children:e.jsx(i.Loader2,{className:"h-8 w-8 animate-spin text-[var(--color-primary-600)]"})}):u?e.jsx("div",{className:"rounded-lg border border-[var(--error-border)] bg-[var(--error-bg)] p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.AlertTriangle,{className:"h-5 w-5 text-[var(--error-text)]"}),e.jsx("p",{className:"text-[var(--error-text)]",children:u})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(A.Breadcrumb,{items:[{label:r("externalApps.navigation.api"),href:"/api"},{label:r("externalApps.title")}]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-[var(--text-primary)]",children:r("externalApps.list.heading")}),e.jsx("p",{className:"mt-2 text-[var(--text-secondary)]",children:r("externalApps.list.description")})]}),e.jsxs(X,{action:"create",navRoute:"api.accounts",hideIfNoPermission:!0,onClick:()=>a("/api/accounts/create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:[e.jsx(i.Plus,{className:"w-4 h-4"}),r("externalApps.list.create")]})]}),e.jsxs("div",{className:"space-y-4 rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(i.Search,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:r("externalApps.list.search"),value:f,onChange:n=>x(n.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] py-2 pl-10 pr-4 text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--color-primary-600)] focus:outline-none"})]}),e.jsxs("select",{value:m,onChange:n=>p(n.target.value),className:"rounded-[var(--radius-input)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-primary-600)] focus:outline-none",children:[e.jsx("option",{value:"all",children:r("externalApps.list.allStatus")}),e.jsx("option",{value:"active",children:r("externalApps.list.active")}),e.jsx("option",{value:"inactive",children:r("externalApps.list.inactive")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>j("cards"),className:`rounded-lg p-2 transition-all ${g==="cards"?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,title:r("externalApps.list.cardView"),children:e.jsx(i.LayoutGrid,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>j("table"),className:`rounded-lg p-2 transition-all ${g==="table"?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,title:r("externalApps.list.tableView"),children:e.jsx(i.LayoutList,{className:"h-5 w-5"})}),e.jsx("span",{className:"ml-auto text-sm text-[var(--text-tertiary)]",children:r("externalApps.list.count",{count:N.length})})]})]}),N.length===0&&e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-12 text-center",children:e.jsx("p",{className:"text-[var(--text-secondary)]",children:r("externalApps.list.noResults")})}),N.length>0&&g==="cards"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:N.map(n=>e.jsxs("button",{type:"button",onClick:()=>D(n.id),className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-5 cursor-pointer hover:shadow-md transition-shadow text-left w-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-lg bg-[var(--bg-secondary)] p-2",children:e.jsx(i.Plug,{className:"h-5 w-5 text-[var(--color-accent-600)]"})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:n.name})})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[e.jsx("div",{className:`h-2 w-2 rounded-full ${n.isActive?"bg-[var(--success-text)]":"bg-[var(--warning-text)]"}`}),e.jsx("span",{className:n.isActive?"text-[var(--success-text)]":"text-[var(--warning-text)]",children:n.isActive?r("externalApps.list.active"):r("externalApps.list.inactive")})]})]}),n.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3 line-clamp-2",children:n.description}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)]",children:[r("externalApps.list.columns.lastAuth"),": ",T(n.lastAuthenticatedAt)]})]},n.id))}),N.length>0&&g!=="cards"&&e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:r("externalApps.list.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:r("externalApps.list.columns.status")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.lastAuth")}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.authCount")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.created")}),e.jsx("th",{className:"w-24 px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:N.map(n=>e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors cursor-pointer group",onClick:()=>D(n.id),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(i.Plug,{className:"h-4 w-4 text-[var(--color-accent-600)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-[var(--color-accent-600)] transition-colors",children:n.name}),n.description&&e.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-tertiary)] line-clamp-1",children:n.description})]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"inline-flex items-center gap-2 rounded-full px-2.5 py-0.5 text-xs font-medium",children:n.isActive?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.list.active")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-[var(--warning-text)]"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:r("externalApps.list.inactive")})]})})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:T(n.lastAuthenticatedAt)}),e.jsx("td",{className:"px-4 py-3 text-sm text-right text-[var(--text-secondary)] hidden lg:table-cell",children:n.authenticationCount}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:T(n.createdAt)}),e.jsx("td",{className:"px-4 py-3",onClick:S=>S.stopPropagation(),children:e.jsx("button",{onClick:()=>D(n.id),className:"inline-flex items-center justify-center rounded-lg bg-[var(--color-primary-600)] p-2 text-white transition-all hover:shadow-md",children:e.jsx("span",{className:"text-xs font-medium",children:r("externalApps.list.view")})})})]},n.id))})]})})]})},te=()=>{const a=B.useNavigate(),{t:r}=E.useTranslation("admin"),[l,t]=o.useState(!1),[s,d]=o.useState(null),[c,h]=o.useState(null),[u,b]=o.useState(null),[g,j]=o.useState({name:"",description:"",allowedIpAddresses:"",tokenExpirationMinutes:60}),f=async(m,p)=>{try{await navigator.clipboard.writeText(m),b(p)}catch{b(null)}setTimeout(()=>b(null),3e3)},x=async m=>{m.preventDefault();try{t(!0),d(null);const p=await A.adminApi.externalApps.create({name:g.name,description:g.description||void 0,allowedIpAddresses:g.allowedIpAddresses||void 0,tokenExpirationMinutes:g.tokenExpirationMinutes});h({id:p.id,clientId:p.clientId,clientSecret:p.clientSecret})}catch(p){d(p instanceof Error?p.message:"Failed to create external application")}finally{t(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(A.Breadcrumb,{items:[{label:r("externalApps.navigation.api"),href:"/api"},{label:r("externalApps.title"),href:"/api/accounts/list"},{label:r("externalApps.create.title")}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>a("/api/accounts/list"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors","aria-label":r("externalApps.create.back"),children:e.jsx(i.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:r("externalApps.create.title")}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r("externalApps.create.description")})]})]}),s&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)]",children:s}),c&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.AlertTriangle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--warning-text)] mb-2",children:r("externalApps.create.secretWarning")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"Client ID"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("pre",{className:"flex-1 p-2 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto",children:c.clientId}),e.jsx("button",{onClick:()=>f(c.clientId,"clientId"),className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm font-medium text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:u==="clientId"?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.create.secretCopied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),r("externalApps.create.copySecret")]})})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"Client Secret"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("pre",{className:"flex-1 p-2 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto",children:c.clientSecret}),e.jsx("button",{onClick:()=>f(c.clientSecret,"clientSecret"),className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm font-medium text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:u==="clientSecret"?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.create.secretCopied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),r("externalApps.create.copySecret")]})})]})]})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx("button",{onClick:()=>a(`/api/accounts/${c.id}?tab=keys`),className:"px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:r("externalApps.create.viewApp")})})]})]})}),!c&&e.jsxs("form",{onSubmit:x,className:"space-y-6 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:[r("externalApps.create.name")," *"]}),e.jsx("input",{type:"text",value:g.name,onChange:m=>j(p=>({...p,name:m.target.value})),placeholder:r("externalApps.create.namePlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.tokenExpirationMinutes")}),e.jsx("input",{type:"number",value:g.tokenExpirationMinutes,onChange:m=>j(p=>({...p,tokenExpirationMinutes:parseInt(m.target.value)||60})),min:1,max:1440,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.appDescription")}),e.jsx("textarea",{value:g.description,onChange:m=>j(p=>({...p,description:m.target.value})),placeholder:r("externalApps.create.descriptionPlaceholder"),rows:2,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.allowedIpAddresses")}),e.jsx("input",{type:"text",value:g.allowedIpAddresses,onChange:m=>j(p=>({...p,allowedIpAddresses:m.target.value})),placeholder:r("externalApps.create.allowedIpAddressesPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>a("/api/accounts/list"),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",children:r("common.cancel")}),e.jsxs("button",{type:"submit",disabled:l,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[l?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Plus,{className:"w-4 h-4"}),r("externalApps.create.submit")]})]})]})]})};function se({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.accounts.update"),[h,u]=o.useState(!1),[b,g]=o.useState({name:a.name,description:a.description||"",allowedIpAddresses:a.allowedIpAddresses||"",tokenExpirationMinutes:a.tokenExpirationMinutes});o.useEffect(()=>{g({name:a.name,description:a.description||"",allowedIpAddresses:a.allowedIpAddresses||"",tokenExpirationMinutes:a.tokenExpirationMinutes})},[a]);const j=async x=>{x.preventDefault();try{u(!0);const m={name:b.name,description:b.description||void 0,allowedIpAddresses:b.allowedIpAddresses||void 0,tokenExpirationMinutes:b.tokenExpirationMinutes};await A.adminApi.externalApps.update(a.id,m),r(s("externalApps.detail.success.updated")),t()}catch(m){l(m instanceof Error?m.message:"Failed to update")}finally{u(!1)}},f=x=>x?new Date(x).toLocaleString():"—";return e.jsxs("form",{onSubmit:j,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.name")}),e.jsx("input",{type:"text",value:b.name,onChange:x=>g(m=>({...m,name:x.target.value})),disabled:!c,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`,required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.tokenExpirationMinutes")}),e.jsx("input",{type:"number",value:b.tokenExpirationMinutes,onChange:x=>g(m=>({...m,tokenExpirationMinutes:parseInt(x.target.value)||60})),disabled:!c,min:1,max:1440,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.description")}),e.jsx("textarea",{value:b.description,onChange:x=>g(m=>({...m,description:x.target.value})),disabled:!c,rows:3,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.allowedIpAddresses")}),e.jsx("input",{type:"text",value:b.allowedIpAddresses,onChange:x=>g(m=>({...m,allowedIpAddresses:x.target.value})),disabled:!c,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-tertiary)]",children:s("externalApps.info.allowedIpAddressesHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.clientId")}),e.jsx("input",{type:"text",value:a.clientId,disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.secretPrefix")}),e.jsx("input",{type:"text",value:a.secretPrefix,disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.createdAt")}),e.jsx("input",{type:"text",value:f(a.createdAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.createdBy")}),e.jsx("input",{type:"text",value:a.createdBy||"—",disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.updatedAt")}),e.jsx("input",{type:"text",value:f(a.updatedAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.lastAuthenticatedAt")}),e.jsx("input",{type:"text",value:f(a.lastAuthenticatedAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]})]}),c&&e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{type:"submit",disabled:h,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[h?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Save,{className:"w-4 h-4"}),s("externalApps.info.save")]})})]})}function ae({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.accounts.execute"),[h,u]=o.useState(!1),[b,g]=o.useState(null),[j,f]=o.useState(null),[x,m]=o.useState(null),[p,w]=o.useState(null),[N,D]=o.useState(!0),T=o.useCallback(async()=>{try{D(!0);const y=await A.adminApi.externalApps.getKeyUsage(a.id);w(y)}catch{}finally{D(!1)}},[a.id]);o.useEffect(()=>{T()},[T]);const n=async y=>{try{u(!0);const R=await A.adminApi.externalApps.rotateSecret(a.id,y);f({value:R.clientSecret,slot:y}),g(null),r(s("externalApps.keys.generateSuccess")),t(),T()}catch(R){l(R instanceof Error?R.message:"Failed")}finally{u(!1)}},S=async()=>{try{u(!0),await A.adminApi.externalApps.revokeSecondarySecret(a.id),g(null),f(null),r(s("externalApps.keys.deleteSuccess")),t(),T()}catch(y){l(y instanceof Error?y.message:"Failed")}finally{u(!1)}},C=async(y,R)=>{try{await navigator.clipboard.writeText(y),m(R)}catch{m(null)}setTimeout(()=>m(null),3e3)},P=y=>y?new Date(y).toLocaleString():s("externalApps.keys.never"),v=[];a.secretPrefix&&v.push({slot:"Primary",prefix:a.secretPrefix,createdAt:a.primarySecretCreatedAt,usage:p?.primary??null}),a.secondarySecretPrefix&&v.push({slot:"Secondary",prefix:a.secondarySecretPrefix,createdAt:a.secondarySecretCreatedAt,usage:p?.secondary??null});const U=!a.secondarySecretPrefix&&c;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2",children:[e.jsx(i.Shield,{className:"w-5 h-5"}),s("externalApps.keys.credentials")]}),e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:[e.jsx("label",{className:"text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider mb-2 block",children:s("externalApps.keys.clientId")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 font-mono text-sm text-[var(--text-primary)] bg-[var(--bg-primary)] px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] break-all",children:a.clientId}),e.jsxs("button",{onClick:()=>C(a.clientId,"clientId"),className:"flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] transition-colors flex-shrink-0",title:s("externalApps.keys.copy"),children:[x==="clientId"?e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(i.Copy,{className:"w-4 h-4"}),s(x==="clientId"?"externalApps.keys.copied":"externalApps.keys.copy")]})]})]})]}),j&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border-2 border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.AlertTriangle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--warning-text)] mb-2",children:s("externalApps.keys.newSecretWarning")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("pre",{className:"flex-1 p-3 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto whitespace-pre-wrap break-all",children:j.value}),e.jsxs("button",{onClick:()=>C(j.value,"newSecret"),className:"flex-shrink-0 flex items-center gap-1.5 px-4 py-2.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white text-sm font-medium hover:bg-[var(--color-accent-700)] transition-colors",children:[x==="newSecret"?e.jsx(i.CheckCircle,{className:"w-4 h-4"}):e.jsx(i.Copy,{className:"w-4 h-4"}),s(x==="newSecret"?"externalApps.keys.copied":"externalApps.keys.copy")]})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(i.Key,{className:"w-5 h-5"}),s("externalApps.keys.title")]}),U&&e.jsxs("button",{onClick:()=>g({type:"generate",slot:"Secondary"}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-[var(--radius-button)] text-xs font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(i.Plus,{className:"w-3.5 h-3.5"}),s("externalApps.keys.addSecret")]})]}),v.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-tertiary)]",children:[e.jsx(i.Key,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:s("externalApps.keys.noKeys")})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left py-2 pr-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.secret")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.prefix")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.created")}),e.jsx("th",{className:"text-right py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.uses")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.lastUsed")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.lastCaller")}),c&&e.jsx("th",{className:"text-right py-2 pl-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.actions")})]})}),e.jsx("tbody",{children:v.map((y,R)=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] last:border-0",children:[e.jsx("td",{className:"py-3 pr-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Key,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:s("externalApps.keys.secretName",{n:R+1})})]})}),e.jsx("td",{className:"py-3 px-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("code",{className:"font-mono text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] px-2 py-1 rounded",children:[y.prefix,"••••••••"]}),e.jsx("button",{onClick:()=>y.prefix&&C(y.prefix,`prefix-${y.slot}`),className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",title:s("externalApps.keys.copy"),children:x===`prefix-${y.slot}`?e.jsx(i.CheckCircle,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(i.Copy,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"py-3 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:P(y.createdAt)}),e.jsxs("td",{className:"py-3 px-3 text-right",children:[N&&e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)] ml-auto"}),!N&&y.usage&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:y.usage.totalUses}),y.usage.totalUses>0&&e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["(",e.jsx("span",{className:"text-[var(--success-text)]",children:y.usage.successfulUses}),y.usage.failedUses>0&&e.jsxs(e.Fragment,{children:[" / ",e.jsx("span",{className:"text-[var(--error-text)]",children:y.usage.failedUses})]}),")"]})]}),!N&&!y.usage&&e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"0"})]}),e.jsx("td",{className:"py-3 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:N?e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)]"}):P(y.usage?.lastUsedAt)}),e.jsxs("td",{className:"py-3 px-3",children:[N&&e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)]"}),!N&&y.usage?.topCallers?.[0]&&e.jsx("span",{className:"text-[var(--text-secondary)] text-xs truncate max-w-[200px] block",title:y.usage.topCallers[0].userAgent,children:y.usage.topCallers[0].userAgent}),!N&&!y.usage?.topCallers?.[0]&&e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"—"})]}),c&&e.jsx("td",{className:"py-3 pl-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsxs("button",{onClick:()=>g({type:"regenerate",slot:y.slot}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",title:s("externalApps.keys.regenerate"),children:[e.jsx(i.RefreshCw,{className:"w-3.5 h-3.5"}),s("externalApps.keys.regenerate")]}),y.slot==="Secondary"&&e.jsxs("button",{onClick:()=>g({type:"delete",slot:"Secondary"}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs font-medium text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",title:s("externalApps.keys.deleteKey"),children:[e.jsx(i.Trash2,{className:"w-3.5 h-3.5"}),s("externalApps.keys.deleteKey")]})]})})]},y.slot))})]})})]}),e.jsx(F.ConfirmModal,{isOpen:!!b&&(b.type==="regenerate"||b.type==="generate"),title:b?.type==="generate"?s("externalApps.keys.addSecret"):s("externalApps.keys.regenerate"),message:b?.type==="generate"?s("externalApps.keys.confirmGenerate"):s("externalApps.keys.confirmRegenerate"),variant:"warning",loading:h,onConfirm:()=>b&&n(b.slot),onCancel:()=>g(null)}),e.jsx(F.ConfirmModal,{isOpen:b?.type==="delete",title:s("externalApps.keys.deleteKey"),message:s("externalApps.keys.confirmDelete"),variant:"danger",loading:h,onConfirm:S,onCancel:()=>g(null)})]})}function re({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.permissions.assign"),[h,u]=o.useState(!1),[b,g]=o.useState([]),[j,f]=o.useState([]),[x,m]=o.useState(""),[p,w]=o.useState(""),[N,D]=o.useState(!1),[T,n]=o.useState(null);o.useEffect(()=>{h&&(A.adminApi.roles.getServiceAssignable().then(g).catch(()=>{}),A.adminApi.tenants.getAll({pageSize:200}).then(v=>f(v.items)).catch(()=>{}))},[h]);const S=async()=>{if(x)try{D(!0),await A.adminApi.externalApps.assignRole(a.id,{roleId:x,tenantId:p||void 0}),m(""),w(""),u(!1),r(s("externalApps.detail.success.roleAssigned")),t()}catch(v){l(v instanceof Error?v.message:"Failed to assign role")}finally{D(!1)}},C=async()=>{if(T)try{D(!0),await A.adminApi.externalApps.removeRole(a.id,T.roleId,T.tenantId??void 0),n(null),r(s("externalApps.detail.success.roleRemoved")),t()}catch(v){l(v instanceof Error?v.message:"Failed to remove role")}finally{D(!1)}},P=v=>v?new Date(v).toLocaleString():"—";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(i.Shield,{className:"w-5 h-5"}),s("externalApps.roles.title")]}),c&&e.jsxs("button",{onClick:()=>u(v=>!v),className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:[e.jsx(i.Plus,{className:"w-4 h-4"}),s("externalApps.roles.assignRole")]})]}),h&&c&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] border border-[var(--color-accent-300)] bg-[var(--accent-bg)]",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("externalApps.roles.selectRole")}),e.jsxs("select",{value:x,onChange:v=>m(v.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-accent-600)] focus:outline-none",children:[e.jsx("option",{value:"",children:s("externalApps.roles.selectRole")}),b.map(v=>e.jsx("option",{value:v.id,children:v.name},v.id))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("externalApps.roles.selectTenant")}),e.jsxs("select",{value:p,onChange:v=>w(v.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-accent-600)] focus:outline-none",children:[e.jsx("option",{value:"",children:s("externalApps.roles.global")}),j.map(v=>e.jsx("option",{value:v.id,children:v.name},v.id))]})]}),e.jsxs("button",{onClick:S,disabled:!x||N,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[N?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Plus,{className:"w-4 h-4"}),s("externalApps.roles.assignRole")]})]})}),!a.roles||a.roles.length===0?e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-8 text-center",children:e.jsx("p",{className:"text-[var(--text-tertiary)]",children:s("externalApps.roles.noRoles")})}):e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.roles.columns.role")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:s("externalApps.roles.columns.scope")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:s("externalApps.roles.columns.assignedAt")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:s("externalApps.roles.columns.assignedBy")}),c&&e.jsx("th",{className:"w-20 px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.roles.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:(a.roles??[]).map(v=>e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-[var(--text-primary)]",children:v.roleName}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden md:table-cell",children:v.isGlobal?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:s("externalApps.roles.global")}):v.tenantName||v.tenantId}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:P(v.assignedAt)}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:v.assignedBy||"—"}),c&&e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>n(v),className:"p-1.5 rounded-[var(--radius-button)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",title:s("externalApps.roles.remove"),children:e.jsx(i.Trash2,{className:"w-4 h-4"})})})]},`${v.roleId}-${v.tenantId||"global"}`))})]})}),e.jsx(F.ConfirmModal,{isOpen:!!T,title:s("externalApps.roles.remove"),message:s("externalApps.roles.confirmRemove",{role:T?.roleName}),variant:"danger",loading:N,onConfirm:C,onCancel:()=>n(null)})]})}const ne={blue:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",neutral:"bg-[var(--bg-secondary)] text-[var(--text-primary)] border-[var(--border-color)]"};function ie(a){if(!a)return null;try{const r=JSON.parse(a);return{message:r.message,requiredPermissions:r.requiredPermissions,requireAll:r.requireAll,raw:a}}catch{return{message:a,raw:a}}}const le=({app:a})=>{const{t:r}=E.useTranslation("admin"),[l,t]=o.useState(null),[s,d]=o.useState(null),[c,h]=o.useState(!0),[u,b]=o.useState(null),[g,j]=o.useState(1),[f,x]=o.useState(null),m=20,p=o.useCallback(async()=>{try{h(!0);const[n,S]=await Promise.all([A.adminApi.externalApps.getUsageStats(a.id,30),A.adminApi.externalApps.getAuditLogs(a.id,g,m)]);t(n),d(S)}catch{b(r("externalApps.audit.loadError"))}finally{h(!1)}},[a.id,g]);if(o.useEffect(()=>{p()},[p]),c&&!l)return e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsx(i.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})});if(u)return e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] text-center",children:u});if(!l)return e.jsx("p",{className:"text-[var(--text-secondary)] text-center py-8",children:r("externalApps.audit.noData")});const w=l.totalRequests>0?Math.round(l.successfulRequests/l.totalRequests*100):0,N=Math.max(...l.dailyUsage.map(n=>n.success+n.failed),1),D=[{label:r("externalApps.audit.totalRequests"),value:l.totalRequests,color:"blue"},{label:r("externalApps.audit.successfulRequests"),value:l.successfulRequests,color:"green"},{label:r("externalApps.audit.failedRequests"),value:l.failedRequests,color:"red"},{label:r("externalApps.audit.successRate"),value:`${w}%`,color:"neutral"}],T=n=>{x(S=>S===n?null:n)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:D.map(n=>e.jsxs("div",{className:`p-4 text-center rounded-[var(--radius-card)] border ${ne[n.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:n.value}),e.jsx("div",{className:"text-sm opacity-80",children:n.label})]},n.label))}),l.dailyUsage.length>0&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-4",children:r("externalApps.audit.dailyUsage",{days:30})}),e.jsx("div",{className:"flex items-end gap-1 h-32",children:l.dailyUsage.map(n=>{const S=n.success+n.failed,C=S/N*100,P=S>0?n.success/S*100:0;return e.jsx("div",{className:"flex-1 min-w-[4px] flex flex-col justify-end",title:`${new Date(n.date).toLocaleDateString()}: ${n.success} ${r("externalApps.audit.success")} / ${n.failed} ${r("externalApps.audit.failure")}`,children:e.jsxs("div",{className:"w-full rounded-t-sm overflow-hidden",style:{height:`${C}%`},children:[e.jsx("div",{className:"w-full bg-[var(--success-text)]",style:{height:`${P}%`}}),e.jsx("div",{className:"w-full bg-[var(--error-text)]",style:{height:`${100-P}%`}})]})},n.date)})}),e.jsx("div",{className:"flex justify-between text-xs text-[var(--text-tertiary)] mt-2",children:l.dailyUsage.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:new Date(l.dailyUsage[0].date).toLocaleDateString()}),e.jsx("span",{children:new Date(l.dailyUsage.at(-1).date).toLocaleDateString()})]})}),e.jsxs("div",{className:"flex gap-4 mt-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm bg-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:r("externalApps.audit.success")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm bg-[var(--error-text)]"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:r("externalApps.audit.failure")})]})]})]}),l.topIpAddresses.length>0&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-3",children:r("externalApps.audit.topIps")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.ip")}),e.jsx("th",{className:"text-right py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.requestCount")}),e.jsx("th",{className:"text-right py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.lastSeen")})]})}),e.jsx("tbody",{children:l.topIpAddresses.map(n=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] last:border-0",children:[e.jsx("td",{className:"py-2 px-3 font-mono text-[var(--text-primary)]",children:n.ipAddress}),e.jsx("td",{className:"py-2 px-3 text-right text-[var(--text-primary)]",children:n.requestCount}),e.jsx("td",{className:"py-2 px-3 text-right text-[var(--text-secondary)]",children:new Date(n.lastSeenAt).toLocaleString()})]},n.ipAddress))})]})})]}),s&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-3",children:r("externalApps.audit.title")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"w-8"}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.date")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.ip")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.action")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.endpoint")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.status")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.duration")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.error")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.userAgent")})]})}),e.jsxs("tbody",{children:[s.items.map(n=>{const S=f===n.id,C=ie(n.errorMessage),P=!!(n.errorMessage||n.userAgent||n.keyUsed);return e.jsxs(o.Fragment,{children:[e.jsxs("tr",{className:`border-b border-[var(--border-color)] last:border-0 ${P?"cursor-pointer hover:bg-[var(--bg-hover)]":""} ${S?"bg-[var(--bg-hover)]":""}`,onClick:()=>P&&T(n.id),children:[e.jsx("td",{className:"py-2 px-1 text-center text-[var(--text-tertiary)]",children:P&&(S?e.jsx(i.ChevronUp,{className:"w-4 h-4 inline"}):e.jsx(i.ChevronDown,{className:"w-4 h-4 inline"}))}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)] whitespace-nowrap",children:new Date(n.createdAt).toLocaleString()}),e.jsx("td",{className:"py-2 px-3 font-mono text-[var(--text-primary)]",children:n.ipAddress}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)]",children:n.action}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)]",children:n.endpointCode?e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium font-mono bg-[var(--bg-secondary)] text-[var(--text-primary)] border border-[var(--border-color)]",children:n.endpointCode}):"-"}),e.jsx("td",{className:"py-2 px-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium ${n.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:n.success?r("externalApps.audit.success"):r("externalApps.audit.failure")})}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:n.durationMs!=null?`${n.durationMs} ms`:"-"}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)]",children:n.errorCode?e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--error-bg)] text-[var(--error-text)]",children:n.errorCode}):"-"}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)] max-w-[200px] truncate",title:n.userAgent??"",children:n.userAgent??"-"})]}),S&&P&&e.jsx("tr",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsx("td",{colSpan:9,className:"py-3 px-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[C&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] font-medium",children:[e.jsx(i.AlertTriangle,{className:"w-4 h-4"}),r("externalApps.audit.columns.error")]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-3 space-y-2",children:[C.message&&e.jsx("div",{className:"text-[var(--error-text)] font-medium",children:C.message}),(C.requiredPermissions?.length??0)>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx(i.Shield,{className:"w-3 h-3"}),r("externalApps.audit.requiredPermissions"),C.requireAll!=null&&e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["(",C.requireAll?r("externalApps.audit.requireAll"):r("externalApps.audit.requireAny"),")"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:C.requiredPermissions?.map(v=>e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-mono bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:v},v))})]}),!C.requiredPermissions&&C.raw&&C.raw!==C.message&&e.jsx("pre",{className:"text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap break-all max-h-32 overflow-auto",children:C.raw})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.userAgent&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] font-medium mb-1",children:[e.jsx(i.Globe,{className:"w-4 h-4"}),r("externalApps.audit.columns.userAgent")]}),e.jsx("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-3",children:e.jsx("span",{className:"text-xs font-mono text-[var(--text-primary)] break-all",children:n.userAgent})})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs",children:[n.clientId&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[r("externalApps.audit.callingApp"),": "]}),e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:a.name}),e.jsxs("span",{className:"text-[var(--text-tertiary)] ml-1",children:["(",n.clientId,")"]})]}),n.keyUsed&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[r("externalApps.audit.keyUsed"),": "]}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.keyUsed})]}),n.durationMs!=null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(i.Clock,{className:"w-3 h-3 text-[var(--text-tertiary)]"}),e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[n.durationMs," ms"]})]})]})]})]})})})]},n.id)}),s.items.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"py-8 text-center text-[var(--text-secondary)]",children:r("externalApps.audit.noData")})})]})]})}),s.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[s.totalCount," ",r("externalApps.audit.totalRequests").toLowerCase()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>j(n=>Math.max(1,n-1)),disabled:!s.hasPreviousPage||c,className:"p-1.5 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-50",children:e.jsx(i.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[g," / ",s.totalPages]}),e.jsx("button",{onClick:()=>j(n=>n+1),disabled:!s.hasNextPage||c,className:"p-1.5 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-50",children:e.jsx(i.ChevronRight,{className:"w-4 h-4"})})]})]})]})]})},ce=(a,r,l,t,s)=>{const d=r.toLowerCase();return a.filter(c=>{if(d&&!c.name.toLowerCase().includes(d)&&!c.routeTemplate.toLowerCase().includes(d)&&!(c.description??"").toLowerCase().includes(d)||l&&c.accessType!==l)return!1;if(t){const h=s.get(c.id)?.isEnabled??!1;if(t==="enabled"&&!h||t==="disabled"&&h)return!1}return!0})};function oe({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.permissions.assign"),[h,u]=o.useState([]),[b,g]=o.useState(new Map),[j,f]=o.useState(!0),[x,m]=o.useState(null),[p,w]=o.useState(!1),[N,D]=o.useState(!1),[T,n]=o.useState(""),[S,C]=o.useState(""),[P,v]=o.useState(""),[U,y]=o.useState(!1),[R,q]=o.useState(!1),[L,z]=o.useState(""),[k,W]=o.useState(""),$=o.useCallback(async()=>{try{f(!0);const[I,M]=await Promise.all([A.adminApi.externalApps.getApiEndpoints(),A.adminApi.externalApps.getAppApiAccess(a.id)]);u(I);const O=new Map;M.forEach(H=>O.set(H.dataApiEndpointId,H)),g(O)}catch(I){l(I instanceof Error?I.message:"Failed to load export data")}finally{f(!1)}},[a.id,l]);o.useEffect(()=>{$()},[$]);const V=I=>{const M=b.get(I.id);m(I),y(M?.isEnabled??!1),q(!1),z(M?.rateLimitPerMinute?.toString()??""),W(M?.maxPageSize?.toString()??""),w(!0)},_=()=>{w(!1),m(null)},Q=async()=>{if(x)try{D(!0);const I=x.accessType==="Write"?R:U;await A.adminApi.externalApps.updateApiAccess(a.id,x.id,{isEnabled:I,rateLimitPerMinute:L?parseInt(L):void 0,maxPageSize:k?parseInt(k):void 0}),r(s("externalApps.exports.success.saved")),await $(),t(),_()}catch(I){l(I instanceof Error?I.message:"Failed to save configuration")}finally{D(!1)}},G=o.useMemo(()=>ce(h,T,S,P,b),[h,T,S,P,b]);return j?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(i.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Database,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:s("externalApps.exports.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:s("externalApps.exports.description")}),h.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(i.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:T,onChange:I=>n(I.target.value),placeholder:s("externalApps.exports.search"),className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]"})]}),e.jsxs("select",{value:S,onChange:I=>C(I.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)]",children:[e.jsx("option",{value:"",children:s("externalApps.exports.allTypes")}),e.jsx("option",{value:"Read",children:s("externalApps.exports.accessTypeRead")}),e.jsx("option",{value:"Write",children:s("externalApps.exports.accessTypeWrite")})]}),e.jsxs("select",{value:P,onChange:I=>v(I.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)]",children:[e.jsx("option",{value:"",children:s("externalApps.exports.allStatuses")}),e.jsx("option",{value:"enabled",children:s("externalApps.exports.enabled")}),e.jsx("option",{value:"disabled",children:s("externalApps.exports.disabled")})]})]}),h.length===0&&e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(i.AlertCircle,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s("externalApps.exports.noEndpoints")]}),h.length>0&&G.length===0&&e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(i.Search,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s("externalApps.exports.noResults")]}),h.length>0&&G.length>0&&e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-1 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)] text-left",children:[e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.name")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.route")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.accessType")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.status")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)] text-right",children:s("externalApps.exports.columns.requests")}),e.jsx("th",{className:"pb-3 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.lastAccessed")})]})}),e.jsx("tbody",{children:G.map(I=>{const M=b.get(I.id),O=M?.isEnabled??!1,H=x?.id===I.id&&p;return e.jsx(de,{endpoint:I,isSelected:H,isEnabled:O,access:M,onOpen:V},I.id)})})]})}),p&&x&&e.jsx(pe,{endpoint:x,isEnabled:b.get(x.id)?.isEnabled??!1,readEnabled:U,writeEnabled:R,editRateLimit:L,editMaxPageSize:k,canManage:c,saving:N,onReadEnabledChange:y,onWriteEnabledChange:q,onRateLimitChange:z,onMaxPageSizeChange:W,onSave:Q,onClose:_,accessMap:b})]})]})}function de({endpoint:a,isSelected:r,isEnabled:l,access:t,onOpen:s}){const{t:d}=E.useTranslation("admin");return e.jsxs("tr",{onClick:()=>s(a),className:`border-b border-[var(--border-color)] cursor-pointer transition-colors ${r?"bg-[var(--color-accent-500)]/5":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsxs("td",{className:"py-3 pr-4",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:a.name}),a.description&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 line-clamp-1",children:a.description})]}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("code",{className:"text-xs text-[var(--text-tertiary)]",children:a.routeTemplate})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`inline-flex px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${a.accessType==="Write"?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--info-bg)] text-[var(--info-text)]"}`,children:a.accessType==="Write"?d("externalApps.exports.accessTypeWrite"):d("externalApps.exports.accessTypeRead")})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-full text-xs font-medium ${l?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"}`,children:d(l?"externalApps.exports.enabled":"externalApps.exports.disabled")})}),e.jsx("td",{className:"py-3 pr-4 text-right",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(i.Activity,{className:"w-3 h-3"}),t?.totalRequestCount??0]})}),e.jsx("td",{className:"py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(i.Clock,{className:"w-3 h-3"}),t?.lastAccessedAt?new Date(t.lastAccessedAt).toLocaleDateString():d("externalApps.exports.never")]})})]})}function pe({endpoint:a,isEnabled:r,readEnabled:l,writeEnabled:t,editRateLimit:s,editMaxPageSize:d,canManage:c,saving:h,onReadEnabledChange:u,onWriteEnabledChange:b,onRateLimitChange:g,onMaxPageSizeChange:j,onSave:f,onClose:x,accessMap:m}){const{t:p}=E.useTranslation("admin"),w=m.get(a.id);return e.jsxs("div",{className:"w-96 shrink-0 border-l border-[var(--border-color)] bg-[var(--bg-secondary)] rounded-lg overflow-hidden shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] truncate pr-2",children:a.name}),e.jsx("button",{onClick:x,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:e.jsx(i.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-4 space-y-5 overflow-y-auto max-h-[calc(100vh-280px)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold uppercase ${a.accessType==="Write"?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--info-bg)] text-[var(--info-text)]"}`,children:a.accessType==="Write"?p("externalApps.exports.accessTypeWrite"):p("externalApps.exports.accessTypeRead")}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:a.entityType})]}),e.jsx("code",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] block",children:a.routeTemplate}),a.description&&e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:a.description})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.Shield,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionPermissions")]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.BookOpen,{className:"w-4 h-4 text-[var(--info-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:p("externalApps.exports.readAccess")})]}),c?e.jsx("button",{type:"button",onClick:()=>u(!l),disabled:a.accessType==="Write",className:"disabled:opacity-40",children:l&&a.accessType!=="Write"?e.jsx(i.ToggleRight,{className:"w-8 h-5 text-[var(--success-text)]"}):e.jsx(i.ToggleLeft,{className:"w-8 h-5 text-[var(--text-tertiary)]"})}):e.jsx("span",{className:`text-xs font-medium ${l?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:p(l?"externalApps.exports.enabled":"externalApps.exports.disabled")})]}),e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border bg-[var(--bg-primary)] ${a.accessType==="Write"?"border-[var(--border-color)]":"border-[var(--border-color)] opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.PenLine,{className:"w-4 h-4 text-[var(--warning-text)]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:p("externalApps.exports.writeAccess")}),a.accessType!=="Write"&&e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-0.5",children:p("externalApps.exports.writeNotAvailable")})]})]}),c?e.jsx("button",{type:"button",onClick:()=>a.accessType==="Write"&&b(!t),disabled:a.accessType!=="Write",className:"disabled:opacity-40",children:t&&a.accessType==="Write"?e.jsx(i.ToggleRight,{className:"w-8 h-5 text-[var(--success-text)]"}):e.jsx(i.ToggleLeft,{className:"w-8 h-5 text-[var(--text-tertiary)]"})}):e.jsx("span",{className:"text-xs font-medium text-[var(--text-tertiary)]",children:p("externalApps.exports.disabled")})]}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)] px-1",children:[e.jsxs("span",{className:"font-medium",children:[p("externalApps.exports.requiredPermission"),":"]}),e.jsx("code",{className:"px-1 py-0.5 rounded bg-[var(--bg-tertiary)]",children:a.requiredPermission})]})]}),c&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.Gauge,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionLimits")]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-1",children:p("externalApps.exports.drawer.rateLimit")}),e.jsx("input",{type:"number",min:"1",value:s,onChange:N=>g(N.target.value),className:"w-full px-3 py-1.5 text-sm rounded border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]",placeholder:a.defaultRateLimitPerMinute.toString()}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1",children:p("externalApps.exports.drawer.rateLimitHelp",{default:a.defaultRateLimitPerMinute})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-1",children:p("externalApps.exports.drawer.maxPageSize")}),e.jsx("input",{type:"number",min:"1",max:"10000",value:d,onChange:N=>j(N.target.value),className:"w-full px-3 py-1.5 text-sm rounded border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]",placeholder:a.defaultMaxPageSize.toString()}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1",children:p("externalApps.exports.drawer.maxPageSizeHelp",{default:a.defaultMaxPageSize})})]})]})]}),w&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.BarChart3,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionStats")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-center",children:[e.jsx("div",{className:"text-lg font-bold text-[var(--text-primary)]",children:w.totalRequestCount.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] uppercase tracking-wide",children:p("externalApps.exports.drawer.totalRequests")})]}),e.jsxs("div",{className:"p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-center",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:w.lastAccessedAt?new Date(w.lastAccessedAt).toLocaleDateString():"—"}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] uppercase tracking-wide",children:p("externalApps.exports.drawer.lastAccessed")})]})]})]})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 p-4 border-t border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("button",{onClick:f,disabled:h,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white text-sm font-medium hover:bg-[var(--color-accent-700)] disabled:opacity-50 transition-colors",children:[h?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Save,{className:"w-4 h-4"}),p("externalApps.exports.drawer.save")]}),e.jsx("button",{onClick:x,disabled:h,className:"px-4 py-2 rounded-lg border border-[var(--border-color)] text-[var(--text-secondary)] text-sm font-medium hover:bg-[var(--bg-hover)] disabled:opacity-50 transition-colors",children:p("externalApps.exports.drawer.cancel")})]})]})}const K=[{code:"users",route:"/api/v1/export/users",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - scope l'export aux utilisateurs de ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC - entites creees ou modifiees apres cette date"},{name:"isActive",type:"bool?",default:"null",description:"Filtre par statut actif/inactif"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"email",type:"string",description:"Adresse email"},{name:"firstName",type:"string?",description:"Prenom"},{name:"lastName",type:"string?",description:"Nom de famille"},{name:"displayName",type:"string?",description:"Nom affiche"},{name:"isActive",type:"boolean",description:"Compte actif"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"roles",type:"string[]",description:"Noms des roles attribues"},{name:"tenantIds",type:"UUID[]",description:"IDs des tenants associes"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"tenants",route:"/api/v1/export/tenants",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant a exporter"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"name",type:"string",description:"Nom du tenant"},{name:"slug",type:"string",description:"Slug URL-friendly"},{name:"type",type:"string",description:"Type de tenant"},{name:"status",type:"string",description:"Statut (Active, Suspended, etc.)"},{name:"description",type:"string?",description:"Description"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"memberCount",type:"int",description:"Nombre de membres"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"roles",route:"/api/v1/export/roles",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - exporte les roles assignes dans ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"name",type:"string",description:"Nom du role"},{name:"shortName",type:"string?",description:"Nom court"},{name:"code",type:"string?",description:"Code technique"},{name:"category",type:"string",description:"Categorie (Global, Admin, Manager, Contributor, Viewer, Custom)"},{name:"description",type:"string?",description:"Description du role"},{name:"isSystem",type:"boolean",description:"Role systeme (non modifiable)"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"permissions",type:"string[]",description:"Codes des permissions attribuees"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"tickets",route:"/api/v1/export/tickets",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - exporte les tickets de ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 500)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"title",type:"string",description:"Titre du ticket"},{name:"type",type:"string",description:"Type (Bug, Feature, Support, etc.)"},{name:"status",type:"string",description:"Statut (Open, InProgress, Resolved, Closed)"},{name:"priority",type:"string",description:"Priorite (Low, Medium, High, Critical)"},{name:"assignedToUserId",type:"UUID?",description:"ID utilisateur assigne"},{name:"createdByUserId",type:"UUID",description:"ID createur"},{name:"tenantId",type:"UUID?",description:"ID tenant associe"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"resolvedAt",type:"DateTime?",description:"Date de resolution (UTC)"},{name:"closedAt",type:"DateTime?",description:"Date de fermeture (UTC)"}],defaultRateLimit:30,defaultMaxPageSize:500,notes:"Rate limit reduit a 30 req/min. Page size max 500."},{code:"navigation",route:"/api/v1/export/navigation",method:"GET",paginated:!1,params:[],responseFields:[{name:"id",type:"UUID",description:"Identifiant de l'application"},{name:"code",type:"string",description:"Code technique de l'application"},{name:"label",type:"string",description:"Libelle affiche"},{name:"modules",type:"object[]",description:"Liste des modules (chacun: id, code, label)"}],defaultRateLimit:60,defaultMaxPageSize:1e3,notes:"Endpoint NON pagine. Retourne directement un tableau JSON (pas d'envelope de pagination). Contient la structure de navigation : applications avec leurs modules."}];function xe({app:a}){const{t:r}=E.useTranslation("admin"),[l,t]=o.useState(new Set),[s,d]=o.useState(!1),c=j=>{t(f=>{const x=new Set(f);return x.has(j)?x.delete(j):x.add(j),x})},h=()=>{t(new Set(K.map(j=>j.code)))},u=()=>{t(new Set)},b=o.useMemo(()=>l.size===0?"":ve(a,l),[a,l]),g=async()=>{if(b)try{await navigator.clipboard.writeText(b),d(!0),setTimeout(()=>d(!1),3e3)}catch{}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ue,{description:r("externalApps.prompt.description"),subdescription:r("externalApps.prompt.subdescription")}),e.jsx(me,{selectedEndpoints:l,onSelectAll:h,onDeselectAll:u,onToggleEndpoint:c}),l.size>0&&e.jsx(he,{selectedEndpoints:l,generatedPrompt:b,copied:s,onCopy:g}),l.size===0&&e.jsxs("div",{className:"text-center py-12 text-[var(--text-tertiary)]",children:[e.jsx(i.Check,{className:"w-12 h-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:r("externalApps.prompt.emptyState")})]})]})}function ue({description:a,subdescription:r}){return e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.Info,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[var(--info-text)]",children:a}),e.jsx("p",{className:"text-xs text-[var(--info-text)] opacity-80 mt-1",children:r})]})]})})}function me({selectedEndpoints:a,onSelectAll:r,onDeselectAll:l,onToggleEndpoint:t}){const{t:s}=E.useTranslation("admin");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:s("externalApps.prompt.selectEndpoints")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r,className:"text-xs text-[var(--color-accent-600)] hover:underline",children:s("externalApps.prompt.selectAll")}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"|"}),e.jsx("button",{onClick:l,className:"text-xs text-[var(--text-tertiary)] hover:underline",children:s("externalApps.prompt.deselectAll")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:K.map(d=>{const c=a.has(d.code);return e.jsxs("button",{onClick:()=>t(d.code),className:`flex items-start gap-3 p-4 rounded-[var(--radius-card)] border text-left transition-colors ${c?"border-[var(--color-accent-600)] bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-600)]/10":"border-[var(--border-color)] bg-[var(--bg-card)] hover:bg-[var(--bg-hover)]"}`,children:[c?e.jsx(i.CheckSquare,{className:"w-5 h-5 text-[var(--color-accent-600)] flex-shrink-0 mt-0.5"}):e.jsx(i.Square,{className:"w-5 h-5 text-[var(--text-tertiary)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-[var(--text-primary)]",children:s(`externalApps.prompt.endpoints.${d.code}.name`)}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 font-mono",children:[d.method," ",d.route]}),e.jsxs("div",{className:"text-xs text-[var(--text-secondary)] mt-1",children:[d.responseFields.length," ",s("externalApps.prompt.fields"),!d.paginated&&e.jsx("span",{className:"ml-2 text-[var(--warning-text)]",children:s("externalApps.prompt.nonPaginated")})]})]})]},d.code)})})]})}function he({selectedEndpoints:a,generatedPrompt:r,copied:l,onCopy:t}){const{t:s}=E.useTranslation("admin");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[s("externalApps.prompt.generatedPrompt"),e.jsxs("span",{className:"ml-2 text-sm font-normal text-[var(--text-tertiary)]",children:["(",a.size," ",a.size===1?s("externalApps.prompt.endpointSingular"):s("externalApps.prompt.endpointPlural"),")"]})]}),e.jsx("button",{onClick:t,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors text-sm font-medium",children:l?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4"}),s("externalApps.prompt.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),s("externalApps.prompt.copyPrompt")]})})]}),e.jsx("div",{className:"relative",children:e.jsx("pre",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words overflow-x-auto max-h-[600px] overflow-y-auto leading-relaxed",children:r})})]})}function ve(a,r){const l=K.filter(d=>r.has(d.code)),t=[];t.push("## Contexte"),t.push(""),t.push("Tu dois implementer un client HTTP qui consomme l'API DataExport de SmartStack en mode **machine-to-machine** (M2M). Il n'y a aucune interaction utilisateur : ton application s'authentifie avec un `clientId` et un `clientSecret`, obtient un token JWT, puis appelle les endpoints d'export de donnees."),t.push(""),t.push(`Client ID de cette application : \`${a.clientId}\``),t.push(""),t.push("---"),t.push(""),t.push("## 1. Authentification (HMAC-JWT Assertion)"),t.push(""),t.push("L'authentification se fait en 2 etapes :"),t.push(""),t.push("### Etape 1 : Creer une assertion JWT signee HMAC-SHA256"),t.push(""),t.push("Ton application doit generer un JWT **signe avec le `clientSecret`** (HMAC-SHA256) :"),t.push(""),t.push("```"),t.push('Header: { "alg": "HS256", "typ": "JWT" }'),t.push("Payload: {"),t.push(` "sub": "${a.clientId}", // ton clientId`),t.push(' "iat": <timestamp-unix-actuel>, // timestamp Unix actuel'),t.push(' "exp": <timestamp-unix + 300>, // expiration (max 5 min apres iat)'),t.push(' "jti": "<uuid-unique>" // nonce anti-replay'),t.push("}"),t.push("Signature: HMAC-SHA256(header.payload, Base64Decode(clientSecret))"),t.push("```"),t.push(""),t.push("**Important** : Le `clientSecret` est encode en Base64. Tu dois le **decoder** avant de l'utiliser comme cle HMAC."),t.push(""),t.push("### Etape 2 : Echanger l'assertion contre un access token"),t.push(""),t.push("```http"),t.push("POST {baseUrl}/api/auth/external-app/token"),t.push("Content-Type: application/json"),t.push(""),t.push("{"),t.push(' "assertion": "<jwt-assertion-de-etape-1>"'),t.push("}"),t.push("```"),t.push(""),t.push("**Reponse succes (200)** :"),t.push("```json"),t.push("{"),t.push(' "accessToken": "eyJhbGciOiJIUz...",'),t.push(' "expiresAt": "2026-02-25T11:00:00Z",'),t.push(' "permissions": ["administration.users.read", ...]'),t.push("}"),t.push("```"),t.push(""),t.push("### Erreurs d'authentification"),t.push(""),t.push("| HTTP | errorCode | Cause |"),t.push("|------|-----------|-------|"),t.push("| 401 | `invalid_assertion` | JWT mal forme ou invalide |"),t.push("| 401 | `missing_client_id` | Claim `sub` absent du JWT |"),t.push("| 401 | `unknown_client` | ClientId inconnu |"),t.push("| 401 | `app_inactive` | Application desactivee |"),t.push("| 401 | `ip_blocked` | IP pas dans la whitelist |"),t.push("| 401 | `invalid_signature` | Signature HMAC invalide |"),t.push(""),t.push("### Regles de gestion du token"),t.push(""),t.push("- Cache le token et renouvelle-le 5 min avant `expiresAt`"),t.push("- N'appelle PAS `/token` a chaque requete"),t.push(""),t.push("---"),t.push(""),t.push("## 2. Isolation par tenant (OBLIGATOIRE)"),t.push(""),t.push("**Tous les endpoints (sauf Navigation) necessitent le parametre `tenantId`** (UUID) en query string."),t.push("Ce parametre scope l'export aux donnees du tenant specifie. Sans ce parametre, l'API retourne une erreur 400."),t.push(""),t.push("Si ton application doit synchroniser plusieurs tenants, appelle chaque endpoint une fois par tenant."),t.push(""),t.push("---"),t.push(""),t.push(`## 3. Endpoints a implementer (${l.length})`),t.push("");for(const d of l){if(t.push(`### ${d.code.charAt(0).toUpperCase()+d.code.slice(1)} Export`),t.push(""),t.push("```http"),t.push(`${d.method} {baseUrl}${d.route}`),t.push("Authorization: Bearer <accessToken>"),t.push("```"),t.push(""),d.params.length>0){t.push("**Parametres (query string)** :"),t.push(""),t.push("| Parametre | Type | Defaut | Description |"),t.push("|-----------|------|--------|-------------|");for(const c of d.params)t.push(`| \`${c.name}\` | ${c.type} | ${c.default} | ${c.description} |`);t.push("")}else t.push("**Aucun parametre** - appel direct sans query string."),t.push("");if(d.paginated){t.push("**Reponse (paginee)** :"),t.push("```json"),t.push("{"),t.push(' "items": ['),t.push(" {");for(let c=0;c<d.responseFields.length;c++){const h=d.responseFields[c],u=c<d.responseFields.length-1?",":"";t.push(` "${h.name}": ${J(h.type)}${u} // ${h.type} - ${h.description}`)}t.push(" }"),t.push(" ],"),t.push(' "page": 1,'),t.push(' "pageSize": 100,'),t.push(' "totalCount": 250,'),t.push(' "totalPages": 3,'),t.push(' "hasMore": true'),t.push("}"),t.push("```")}else{t.push("**Reponse (tableau direct, NON pagine)** :"),t.push("```json"),t.push("["),t.push(" {");for(let c=0;c<d.responseFields.length;c++){const h=d.responseFields[c],u=c<d.responseFields.length-1?",":"";t.push(` "${h.name}": ${J(h.type)}${u} // ${h.type} - ${h.description}`)}t.push(" }"),t.push("]"),t.push("```")}t.push(""),t.push(`**Rate limit** : ${d.defaultRateLimit} requetes/minute | Page size max : ${d.defaultMaxPageSize}`),d.notes&&t.push(`**Note** : ${d.notes}`),t.push("")}t.push("---"),t.push("");const s=l.some(d=>d.paginated);return s&&(t.push("## 4. Pagination"),t.push(""),t.push("Pour parcourir toutes les pages : boucle tant que `hasMore === true`, en incrementant `page`."),t.push("Les resultats sont tries par `createdAt ASC` (ordre stable)."),t.push(""),t.push("---"),t.push("")),s&&(t.push("## 5. Synchronisation incrementale"),t.push(""),t.push("Utilise `modifiedSince` pour ne recuperer que les changements :"),t.push("1. Premiere synchro : appelle sans `modifiedSince` (recupere tout)"),t.push("2. Stocke `DateTime.UtcNow` du debut de la synchro"),t.push("3. Synchros suivantes : passe `modifiedSince=<timestamp-stocke>`"),t.push(""),t.push("Le filtre retourne les entites ou `UpdatedAt >= modifiedSince OR CreatedAt >= modifiedSince`."),t.push(""),t.push("---"),t.push("")),t.push("## 6. Rate Limiting"),t.push(""),t.push("| Aspect | Valeur |"),t.push("|--------|--------|"),t.push("| Algorithme | Fenetre fixe de 1 minute |"),t.push("| Cle de partition | {clientId}:{endpointCode} (independant par endpoint) |"),t.push(""),t.push("Quand tu depasses la limite :"),t.push("```"),t.push("HTTP/1.1 429 Too Many Requests"),t.push("Retry-After: 42"),t.push("```"),t.push("Lis le header `Retry-After` et attends. Implemente un backoff exponentiel."),t.push(""),t.push("---"),t.push(""),t.push("## 7. Gestion des erreurs"),t.push(""),t.push("| HTTP | Action |"),t.push("|------|--------|"),t.push("| 200 | Traite les donnees |"),t.push("| 400 | tenantId manquant ou invalide |"),t.push("| 401 | Renouvelle le token et relance |"),t.push("| 403 | Acces export non accorde - contacte l'admin |"),t.push("| 404 | Tenant non trouve - verifie le tenantId |"),t.push("| 429 | Attends `Retry-After` secondes |"),t.push("| 500 | Retry avec backoff exponentiel |"),t.push(""),t.push("---"),t.push(""),t.push("## 8. Checklist d'implementation"),t.push(""),t.push("### 8.1 Configuration"),t.push("```"),t.push("SMARTSTACK_BASE_URL=https://smartstack.example.com"),t.push(`SMARTSTACK_CLIENT_ID=${a.clientId}`),t.push("SMARTSTACK_CLIENT_SECRET=<base64-encoded-secret>"),t.push("```"),t.push("Ne hardcode JAMAIS le clientId/clientSecret. Utilise des variables d'environnement ou un vault."),t.push(""),t.push("### 8.2 Service d'authentification"),t.push("```"),t.push("SmartStackAuthService:"),t.push(" - generateAssertion() → JWT HMAC-SHA256 signe avec le secret decode du Base64"),t.push(" - getAccessToken() → POST /api/auth/external-app/token"),t.push(" - cachedToken / expiresAt → cache le token, renouvelle 5 min avant expiration"),t.push("```"),t.push(""),t.push("### 8.3 Client HTTP generique"),t.push("```"),t.push("SmartStackExportClient:"),t.push(" - fetchExport(endpointCode, tenantId, page?, pageSize?, modifiedSince?, extraParams?)"),t.push(" → GET /api/v1/export/{endpointCode}?tenantId={tenantId}"),t.push(" - fetchAllPages(endpointCode, tenantId, pageSize?, modifiedSince?)"),t.push(" → boucle automatique sur toutes les pages"),t.push(" - Gere 401 (retry token), 429 (Retry-After), 5xx (backoff)"),t.push("```"),t.push(""),t.push("### 8.4 Synchroniseur incremental"),t.push("```"),t.push("SmartStackSyncService:"),t.push(` - endpoints: [${l.map(d=>`"${d.code}"`).join(", ")}]`),t.push(" - tenantIds: [<liste des tenantIds a synchroniser>]"),t.push(" - syncAll() → pour chaque tenant, pour chaque endpoint, appelle syncEndpoint()"),t.push(" - syncEndpoint(code, tenantId):"),t.push(" 1. Lit le dernier timestamp de synchro (par endpoint + tenant)"),t.push(" 2. Appelle fetchAllPages(code, tenantId, modifiedSince)"),t.push(" 3. Upsert les donnees (INSERT si nouveau, UPDATE si existant, par `id`)"),t.push(" 4. Sauve le timestamp"),t.push("```"),t.push(""),t.push("### 8.5 Securite"),t.push(""),t.push("- Stocke le clientSecret dans un vault (Azure Key Vault, etc.)"),t.push("- L'assertion JWT a une duree courte (5 min max)"),t.push("- Ne log jamais le token d'acces"),t.push("- Toutes les requetes sont auditees cote SmartStack (IP, User-Agent)"),t.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),B=require("react-router-dom"),E=require("react-i18next"),i=require("lucide-react"),A=require("./index-IgLVXPg8.js"),Z=require("./useTabNavigation-BVtbCTd5.js"),F=require("./ConfirmModal-CYWRiVoD.js");function X({action:a,navRoute:r,hideIfNoPermission:l=!1,customPermission:t,tooltipPosition:s="top",disabledMessage:d,children:c,disabled:h,className:u="",...b}){const{hasPermission:g}=A.useAuth(),{t:j}=E.useTranslation("common"),f=t??`${r}.${a}`,x=g(f);if(!x&&l)return null;const m=x?void 0:d??j(`permissions.no${Y(a)}Permission`),p=!x||h,w=e.jsx("button",{...b,disabled:p,className:`${u} ${p?"cursor-not-allowed opacity-50":""}`,"aria-disabled":p,children:c});return m?e.jsx(A.Tooltip,{content:m,position:s,variant:"error",disabled:!1,children:w}):w}function Y(a){return a.charAt(0).toUpperCase()+a.slice(1)}const ee=()=>{const a=B.useNavigate(),{t:r}=E.useTranslation("admin"),{currentTenant:l,isGlobalView:t}=A.useTenant(),[s,d]=o.useState([]),[c,h]=o.useState(!0),[u,b]=o.useState(null),[g,j]=o.useState("table"),[f,x]=o.useState(""),[m,p]=o.useState("all"),w=o.useCallback(async()=>{try{h(!0);const n=await A.adminApi.externalApps.getAll({search:f||void 0,isActive:m==="all"?void 0:m==="active"});d(n),b(null)}catch(n){b(n instanceof Error?n.message:"Failed to load external applications")}finally{h(!1)}},[l?.id,t,f,m]);o.useEffect(()=>{w()},[w]);const N=o.useMemo(()=>s.filter(n=>{const S=n.name.toLowerCase().includes(f.toLowerCase())||n.clientId.toLowerCase().includes(f.toLowerCase()),C=m==="all"||m==="active"&&n.isActive||m==="inactive"&&!n.isActive;return S&&C}),[s,f,m]),D=n=>{a(`/api/accounts/${n}`)},T=n=>n?new Date(n).toLocaleDateString():r("externalApps.list.never");return c?e.jsx("div",{className:"flex h-96 items-center justify-center",children:e.jsx(i.Loader2,{className:"h-8 w-8 animate-spin text-[var(--color-primary-600)]"})}):u?e.jsx("div",{className:"rounded-lg border border-[var(--error-border)] bg-[var(--error-bg)] p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.AlertTriangle,{className:"h-5 w-5 text-[var(--error-text)]"}),e.jsx("p",{className:"text-[var(--error-text)]",children:u})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(A.Breadcrumb,{items:[{label:r("externalApps.navigation.api"),href:"/api"},{label:r("externalApps.title")}]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-[var(--text-primary)]",children:r("externalApps.list.heading")}),e.jsx("p",{className:"mt-2 text-[var(--text-secondary)]",children:r("externalApps.list.description")})]}),e.jsxs(X,{action:"create",navRoute:"api.accounts",hideIfNoPermission:!0,onClick:()=>a("/api/accounts/create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:[e.jsx(i.Plus,{className:"w-4 h-4"}),r("externalApps.list.create")]})]}),e.jsxs("div",{className:"space-y-4 rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(i.Search,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:r("externalApps.list.search"),value:f,onChange:n=>x(n.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] py-2 pl-10 pr-4 text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:border-[var(--color-primary-600)] focus:outline-none"})]}),e.jsxs("select",{value:m,onChange:n=>p(n.target.value),className:"rounded-[var(--radius-input)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-primary-600)] focus:outline-none",children:[e.jsx("option",{value:"all",children:r("externalApps.list.allStatus")}),e.jsx("option",{value:"active",children:r("externalApps.list.active")}),e.jsx("option",{value:"inactive",children:r("externalApps.list.inactive")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>j("cards"),className:`rounded-lg p-2 transition-all ${g==="cards"?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,title:r("externalApps.list.cardView"),children:e.jsx(i.LayoutGrid,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>j("table"),className:`rounded-lg p-2 transition-all ${g==="table"?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,title:r("externalApps.list.tableView"),children:e.jsx(i.LayoutList,{className:"h-5 w-5"})}),e.jsx("span",{className:"ml-auto text-sm text-[var(--text-tertiary)]",children:r("externalApps.list.count",{count:N.length})})]})]}),N.length===0&&e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-12 text-center",children:e.jsx("p",{className:"text-[var(--text-secondary)]",children:r("externalApps.list.noResults")})}),N.length>0&&g==="cards"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:N.map(n=>e.jsxs("button",{type:"button",onClick:()=>D(n.id),className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-5 cursor-pointer hover:shadow-md transition-shadow text-left w-full",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-lg bg-[var(--bg-secondary)] p-2",children:e.jsx(i.Plug,{className:"h-5 w-5 text-[var(--color-accent-600)]"})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:n.name})})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[e.jsx("div",{className:`h-2 w-2 rounded-full ${n.isActive?"bg-[var(--success-text)]":"bg-[var(--warning-text)]"}`}),e.jsx("span",{className:n.isActive?"text-[var(--success-text)]":"text-[var(--warning-text)]",children:n.isActive?r("externalApps.list.active"):r("externalApps.list.inactive")})]})]}),n.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3 line-clamp-2",children:n.description}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)]",children:[r("externalApps.list.columns.lastAuth"),": ",T(n.lastAuthenticatedAt)]})]},n.id))}),N.length>0&&g!=="cards"&&e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:r("externalApps.list.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:r("externalApps.list.columns.status")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.lastAuth")}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.authCount")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:r("externalApps.list.columns.created")}),e.jsx("th",{className:"w-24 px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:N.map(n=>e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors cursor-pointer group",onClick:()=>D(n.id),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(i.Plug,{className:"h-4 w-4 text-[var(--color-accent-600)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-[var(--color-accent-600)] transition-colors",children:n.name}),n.description&&e.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-tertiary)] line-clamp-1",children:n.description})]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"inline-flex items-center gap-2 rounded-full px-2.5 py-0.5 text-xs font-medium",children:n.isActive?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.list.active")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-[var(--warning-text)]"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:r("externalApps.list.inactive")})]})})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:T(n.lastAuthenticatedAt)}),e.jsx("td",{className:"px-4 py-3 text-sm text-right text-[var(--text-secondary)] hidden lg:table-cell",children:n.authenticationCount}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:T(n.createdAt)}),e.jsx("td",{className:"px-4 py-3",onClick:S=>S.stopPropagation(),children:e.jsx("button",{onClick:()=>D(n.id),className:"inline-flex items-center justify-center rounded-lg bg-[var(--color-primary-600)] p-2 text-white transition-all hover:shadow-md",children:e.jsx("span",{className:"text-xs font-medium",children:r("externalApps.list.view")})})})]},n.id))})]})})]})},te=()=>{const a=B.useNavigate(),{t:r}=E.useTranslation("admin"),[l,t]=o.useState(!1),[s,d]=o.useState(null),[c,h]=o.useState(null),[u,b]=o.useState(null),[g,j]=o.useState({name:"",description:"",allowedIpAddresses:"",tokenExpirationMinutes:60}),f=async(m,p)=>{try{await navigator.clipboard.writeText(m),b(p)}catch{b(null)}setTimeout(()=>b(null),3e3)},x=async m=>{m.preventDefault();try{t(!0),d(null);const p=await A.adminApi.externalApps.create({name:g.name,description:g.description||void 0,allowedIpAddresses:g.allowedIpAddresses||void 0,tokenExpirationMinutes:g.tokenExpirationMinutes});h({id:p.id,clientId:p.clientId,clientSecret:p.clientSecret})}catch(p){d(p instanceof Error?p.message:"Failed to create external application")}finally{t(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(A.Breadcrumb,{items:[{label:r("externalApps.navigation.api"),href:"/api"},{label:r("externalApps.title"),href:"/api/accounts/list"},{label:r("externalApps.create.title")}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>a("/api/accounts/list"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors","aria-label":r("externalApps.create.back"),children:e.jsx(i.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:r("externalApps.create.title")}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r("externalApps.create.description")})]})]}),s&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)]",children:s}),c&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.AlertTriangle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--warning-text)] mb-2",children:r("externalApps.create.secretWarning")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"Client ID"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("pre",{className:"flex-1 p-2 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto",children:c.clientId}),e.jsx("button",{onClick:()=>f(c.clientId,"clientId"),className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm font-medium text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:u==="clientId"?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.create.secretCopied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),r("externalApps.create.copySecret")]})})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"Client Secret"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("pre",{className:"flex-1 p-2 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto",children:c.clientSecret}),e.jsx("button",{onClick:()=>f(c.clientSecret,"clientSecret"),className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm font-medium text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:u==="clientSecret"?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--success-text)]",children:r("externalApps.create.secretCopied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),r("externalApps.create.copySecret")]})})]})]})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx("button",{onClick:()=>a(`/api/accounts/${c.id}?tab=keys`),className:"px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:r("externalApps.create.viewApp")})})]})]})}),!c&&e.jsxs("form",{onSubmit:x,className:"space-y-6 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:[r("externalApps.create.name")," *"]}),e.jsx("input",{type:"text",value:g.name,onChange:m=>j(p=>({...p,name:m.target.value})),placeholder:r("externalApps.create.namePlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.tokenExpirationMinutes")}),e.jsx("input",{type:"number",value:g.tokenExpirationMinutes,onChange:m=>j(p=>({...p,tokenExpirationMinutes:parseInt(m.target.value)||60})),min:1,max:1440,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.appDescription")}),e.jsx("textarea",{value:g.description,onChange:m=>j(p=>({...p,description:m.target.value})),placeholder:r("externalApps.create.descriptionPlaceholder"),rows:2,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:r("externalApps.create.allowedIpAddresses")}),e.jsx("input",{type:"text",value:g.allowedIpAddresses,onChange:m=>j(p=>({...p,allowedIpAddresses:m.target.value})),placeholder:r("externalApps.create.allowedIpAddressesPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>a("/api/accounts/list"),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",children:r("common.cancel")}),e.jsxs("button",{type:"submit",disabled:l,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[l?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Plus,{className:"w-4 h-4"}),r("externalApps.create.submit")]})]})]})]})};function se({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.accounts.update"),[h,u]=o.useState(!1),[b,g]=o.useState({name:a.name,description:a.description||"",allowedIpAddresses:a.allowedIpAddresses||"",tokenExpirationMinutes:a.tokenExpirationMinutes});o.useEffect(()=>{g({name:a.name,description:a.description||"",allowedIpAddresses:a.allowedIpAddresses||"",tokenExpirationMinutes:a.tokenExpirationMinutes})},[a]);const j=async x=>{x.preventDefault();try{u(!0);const m={name:b.name,description:b.description||void 0,allowedIpAddresses:b.allowedIpAddresses||void 0,tokenExpirationMinutes:b.tokenExpirationMinutes};await A.adminApi.externalApps.update(a.id,m),r(s("externalApps.detail.success.updated")),t()}catch(m){l(m instanceof Error?m.message:"Failed to update")}finally{u(!1)}},f=x=>x?new Date(x).toLocaleString():"—";return e.jsxs("form",{onSubmit:j,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.name")}),e.jsx("input",{type:"text",value:b.name,onChange:x=>g(m=>({...m,name:x.target.value})),disabled:!c,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`,required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.tokenExpirationMinutes")}),e.jsx("input",{type:"number",value:b.tokenExpirationMinutes,onChange:x=>g(m=>({...m,tokenExpirationMinutes:parseInt(x.target.value)||60})),disabled:!c,min:1,max:1440,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.description")}),e.jsx("textarea",{value:b.description,onChange:x=>g(m=>({...m,description:x.target.value})),disabled:!c,rows:3,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.allowedIpAddresses")}),e.jsx("input",{type:"text",value:b.allowedIpAddresses,onChange:x=>g(m=>({...m,allowedIpAddresses:x.target.value})),disabled:!c,className:`w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] text-[var(--text-primary)] ${c?"bg-[var(--bg-primary)] focus:ring-2 focus:ring-[var(--color-accent-600)] focus:border-transparent":"bg-[var(--bg-tertiary)] cursor-not-allowed text-[var(--text-muted)]"}`}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-tertiary)]",children:s("externalApps.info.allowedIpAddressesHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.clientId")}),e.jsx("input",{type:"text",value:a.clientId,disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.secretPrefix")}),e.jsx("input",{type:"text",value:a.secretPrefix,disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.createdAt")}),e.jsx("input",{type:"text",value:f(a.createdAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.createdBy")}),e.jsx("input",{type:"text",value:a.createdBy||"—",disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.updatedAt")}),e.jsx("input",{type:"text",value:f(a.updatedAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-2",children:s("externalApps.info.lastAuthenticatedAt")}),e.jsx("input",{type:"text",value:f(a.lastAuthenticatedAt),disabled:!0,className:"w-full px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] border border-[var(--border-color)] text-[var(--text-muted)] cursor-not-allowed"})]})]}),c&&e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{type:"submit",disabled:h,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[h?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Save,{className:"w-4 h-4"}),s("externalApps.info.save")]})})]})}function ae({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.accounts.execute"),[h,u]=o.useState(!1),[b,g]=o.useState(null),[j,f]=o.useState(null),[x,m]=o.useState(null),[p,w]=o.useState(null),[N,D]=o.useState(!0),T=o.useCallback(async()=>{try{D(!0);const y=await A.adminApi.externalApps.getKeyUsage(a.id);w(y)}catch{}finally{D(!1)}},[a.id]);o.useEffect(()=>{T()},[T]);const n=async y=>{try{u(!0);const R=await A.adminApi.externalApps.rotateSecret(a.id,y);f({value:R.clientSecret,slot:y}),g(null),r(s("externalApps.keys.generateSuccess")),t(),T()}catch(R){l(R instanceof Error?R.message:"Failed")}finally{u(!1)}},S=async()=>{try{u(!0),await A.adminApi.externalApps.revokeSecondarySecret(a.id),g(null),f(null),r(s("externalApps.keys.deleteSuccess")),t(),T()}catch(y){l(y instanceof Error?y.message:"Failed")}finally{u(!1)}},C=async(y,R)=>{try{await navigator.clipboard.writeText(y),m(R)}catch{m(null)}setTimeout(()=>m(null),3e3)},P=y=>y?new Date(y).toLocaleString():s("externalApps.keys.never"),v=[];a.secretPrefix&&v.push({slot:"Primary",prefix:a.secretPrefix,createdAt:a.primarySecretCreatedAt,usage:p?.primary??null}),a.secondarySecretPrefix&&v.push({slot:"Secondary",prefix:a.secondarySecretPrefix,createdAt:a.secondarySecretCreatedAt,usage:p?.secondary??null});const U=!a.secondarySecretPrefix&&c;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2",children:[e.jsx(i.Shield,{className:"w-5 h-5"}),s("externalApps.keys.credentials")]}),e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:[e.jsx("label",{className:"text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider mb-2 block",children:s("externalApps.keys.clientId")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 font-mono text-sm text-[var(--text-primary)] bg-[var(--bg-primary)] px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] break-all",children:a.clientId}),e.jsxs("button",{onClick:()=>C(a.clientId,"clientId"),className:"flex items-center gap-1.5 px-3 py-2 rounded-[var(--radius-button)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] transition-colors flex-shrink-0",title:s("externalApps.keys.copy"),children:[x==="clientId"?e.jsx(i.CheckCircle,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(i.Copy,{className:"w-4 h-4"}),s(x==="clientId"?"externalApps.keys.copied":"externalApps.keys.copy")]})]})]})]}),j&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border-2 border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.AlertTriangle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--warning-text)] mb-2",children:s("externalApps.keys.newSecretWarning")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("pre",{className:"flex-1 p-3 bg-[var(--bg-primary)] rounded-[var(--radius-input)] border border-[var(--border-color)] text-sm font-mono text-[var(--text-primary)] overflow-x-auto whitespace-pre-wrap break-all",children:j.value}),e.jsxs("button",{onClick:()=>C(j.value,"newSecret"),className:"flex-shrink-0 flex items-center gap-1.5 px-4 py-2.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white text-sm font-medium hover:bg-[var(--color-accent-700)] transition-colors",children:[x==="newSecret"?e.jsx(i.CheckCircle,{className:"w-4 h-4"}):e.jsx(i.Copy,{className:"w-4 h-4"}),s(x==="newSecret"?"externalApps.keys.copied":"externalApps.keys.copy")]})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(i.Key,{className:"w-5 h-5"}),s("externalApps.keys.title")]}),U&&e.jsxs("button",{onClick:()=>g({type:"generate",slot:"Secondary"}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-[var(--radius-button)] text-xs font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(i.Plus,{className:"w-3.5 h-3.5"}),s("externalApps.keys.addSecret")]})]}),v.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-tertiary)]",children:[e.jsx(i.Key,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:s("externalApps.keys.noKeys")})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left py-2 pr-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.secret")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.prefix")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.created")}),e.jsx("th",{className:"text-right py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.uses")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.lastUsed")}),e.jsx("th",{className:"text-left py-2 px-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.lastCaller")}),c&&e.jsx("th",{className:"text-right py-2 pl-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.keys.columns.actions")})]})}),e.jsx("tbody",{children:v.map((y,R)=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] last:border-0",children:[e.jsx("td",{className:"py-3 pr-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Key,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:s("externalApps.keys.secretName",{n:R+1})})]})}),e.jsx("td",{className:"py-3 px-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("code",{className:"font-mono text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] px-2 py-1 rounded",children:[y.prefix,"••••••••"]}),e.jsx("button",{onClick:()=>y.prefix&&C(y.prefix,`prefix-${y.slot}`),className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",title:s("externalApps.keys.copy"),children:x===`prefix-${y.slot}`?e.jsx(i.CheckCircle,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(i.Copy,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"py-3 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:P(y.createdAt)}),e.jsxs("td",{className:"py-3 px-3 text-right",children:[N&&e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)] ml-auto"}),!N&&y.usage&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:y.usage.totalUses}),y.usage.totalUses>0&&e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["(",e.jsx("span",{className:"text-[var(--success-text)]",children:y.usage.successfulUses}),y.usage.failedUses>0&&e.jsxs(e.Fragment,{children:[" / ",e.jsx("span",{className:"text-[var(--error-text)]",children:y.usage.failedUses})]}),")"]})]}),!N&&!y.usage&&e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"0"})]}),e.jsx("td",{className:"py-3 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:N?e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)]"}):P(y.usage?.lastUsedAt)}),e.jsxs("td",{className:"py-3 px-3",children:[N&&e.jsx(i.Loader2,{className:"w-3 h-3 animate-spin text-[var(--text-tertiary)]"}),!N&&y.usage?.topCallers?.[0]&&e.jsx("span",{className:"text-[var(--text-secondary)] text-xs truncate max-w-[200px] block",title:y.usage.topCallers[0].userAgent,children:y.usage.topCallers[0].userAgent}),!N&&!y.usage?.topCallers?.[0]&&e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"—"})]}),c&&e.jsx("td",{className:"py-3 pl-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsxs("button",{onClick:()=>g({type:"regenerate",slot:y.slot}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",title:s("externalApps.keys.regenerate"),children:[e.jsx(i.RefreshCw,{className:"w-3.5 h-3.5"}),s("externalApps.keys.regenerate")]}),y.slot==="Secondary"&&e.jsxs("button",{onClick:()=>g({type:"delete",slot:"Secondary"}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs font-medium text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",title:s("externalApps.keys.deleteKey"),children:[e.jsx(i.Trash2,{className:"w-3.5 h-3.5"}),s("externalApps.keys.deleteKey")]})]})})]},y.slot))})]})})]}),e.jsx(F.ConfirmModal,{isOpen:!!b&&(b.type==="regenerate"||b.type==="generate"),title:b?.type==="generate"?s("externalApps.keys.addSecret"):s("externalApps.keys.regenerate"),message:b?.type==="generate"?s("externalApps.keys.confirmGenerate"):s("externalApps.keys.confirmRegenerate"),variant:"warning",loading:h,onConfirm:()=>b&&n(b.slot),onCancel:()=>g(null)}),e.jsx(F.ConfirmModal,{isOpen:b?.type==="delete",title:s("externalApps.keys.deleteKey"),message:s("externalApps.keys.confirmDelete"),variant:"danger",loading:h,onConfirm:S,onCancel:()=>g(null)})]})}function re({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.permissions.assign"),[h,u]=o.useState(!1),[b,g]=o.useState([]),[j,f]=o.useState([]),[x,m]=o.useState(""),[p,w]=o.useState(""),[N,D]=o.useState(!1),[T,n]=o.useState(null);o.useEffect(()=>{h&&(A.adminApi.roles.getServiceAssignable().then(g).catch(()=>{}),A.adminApi.tenants.getAll({pageSize:200}).then(v=>f(v.items)).catch(()=>{}))},[h]);const S=async()=>{if(x)try{D(!0),await A.adminApi.externalApps.assignRole(a.id,{roleId:x,tenantId:p||void 0}),m(""),w(""),u(!1),r(s("externalApps.detail.success.roleAssigned")),t()}catch(v){l(v instanceof Error?v.message:"Failed to assign role")}finally{D(!1)}},C=async()=>{if(T)try{D(!0),await A.adminApi.externalApps.removeRole(a.id,T.roleId,T.tenantId??void 0),n(null),r(s("externalApps.detail.success.roleRemoved")),t()}catch(v){l(v instanceof Error?v.message:"Failed to remove role")}finally{D(!1)}},P=v=>v?new Date(v).toLocaleString():"—";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(i.Shield,{className:"w-5 h-5"}),s("externalApps.roles.title")]}),c&&e.jsxs("button",{onClick:()=>u(v=>!v),className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:[e.jsx(i.Plus,{className:"w-4 h-4"}),s("externalApps.roles.assignRole")]})]}),h&&c&&e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] border border-[var(--color-accent-300)] bg-[var(--accent-bg)]",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("externalApps.roles.selectRole")}),e.jsxs("select",{value:x,onChange:v=>m(v.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-accent-600)] focus:outline-none",children:[e.jsx("option",{value:"",children:s("externalApps.roles.selectRole")}),b.map(v=>e.jsx("option",{value:v.id,children:v.name},v.id))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("externalApps.roles.selectTenant")}),e.jsxs("select",{value:p,onChange:v=>w(v.target.value),className:"w-full rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-accent-600)] focus:outline-none",children:[e.jsx("option",{value:"",children:s("externalApps.roles.global")}),j.map(v=>e.jsx("option",{value:v.id,children:v.name},v.id))]})]}),e.jsxs("button",{onClick:S,disabled:!x||N,className:"flex items-center gap-2 px-6 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50",children:[N?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Plus,{className:"w-4 h-4"}),s("externalApps.roles.assignRole")]})]})}),!a.roles||a.roles.length===0?e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-8 text-center",children:e.jsx("p",{className:"text-[var(--text-tertiary)]",children:s("externalApps.roles.noRoles")})}):e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.roles.columns.role")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:s("externalApps.roles.columns.scope")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:s("externalApps.roles.columns.assignedAt")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:s("externalApps.roles.columns.assignedBy")}),c&&e.jsx("th",{className:"w-20 px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:s("externalApps.roles.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:(a.roles??[]).map(v=>e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-[var(--text-primary)]",children:v.roleName}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden md:table-cell",children:v.isGlobal?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:s("externalApps.roles.global")}):v.tenantName||v.tenantId}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:P(v.assignedAt)}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden lg:table-cell",children:v.assignedBy||"—"}),c&&e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>n(v),className:"p-1.5 rounded-[var(--radius-button)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",title:s("externalApps.roles.remove"),children:e.jsx(i.Trash2,{className:"w-4 h-4"})})})]},`${v.roleId}-${v.tenantId||"global"}`))})]})}),e.jsx(F.ConfirmModal,{isOpen:!!T,title:s("externalApps.roles.remove"),message:s("externalApps.roles.confirmRemove",{role:T?.roleName}),variant:"danger",loading:N,onConfirm:C,onCancel:()=>n(null)})]})}const ne={blue:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",neutral:"bg-[var(--bg-secondary)] text-[var(--text-primary)] border-[var(--border-color)]"};function ie(a){if(!a)return null;try{const r=JSON.parse(a);return{message:r.message,requiredPermissions:r.requiredPermissions,requireAll:r.requireAll,raw:a}}catch{return{message:a,raw:a}}}const le=({app:a})=>{const{t:r}=E.useTranslation("admin"),[l,t]=o.useState(null),[s,d]=o.useState(null),[c,h]=o.useState(!0),[u,b]=o.useState(null),[g,j]=o.useState(1),[f,x]=o.useState(null),m=20,p=o.useCallback(async()=>{try{h(!0);const[n,S]=await Promise.all([A.adminApi.externalApps.getUsageStats(a.id,30),A.adminApi.externalApps.getAuditLogs(a.id,g,m)]);t(n),d(S)}catch{b(r("externalApps.audit.loadError"))}finally{h(!1)}},[a.id,g]);if(o.useEffect(()=>{p()},[p]),c&&!l)return e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsx(i.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})});if(u)return e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] text-center",children:u});if(!l)return e.jsx("p",{className:"text-[var(--text-secondary)] text-center py-8",children:r("externalApps.audit.noData")});const w=l.totalRequests>0?Math.round(l.successfulRequests/l.totalRequests*100):0,N=Math.max(...l.dailyUsage.map(n=>n.success+n.failed),1),D=[{label:r("externalApps.audit.totalRequests"),value:l.totalRequests,color:"blue"},{label:r("externalApps.audit.successfulRequests"),value:l.successfulRequests,color:"green"},{label:r("externalApps.audit.failedRequests"),value:l.failedRequests,color:"red"},{label:r("externalApps.audit.successRate"),value:`${w}%`,color:"neutral"}],T=n=>{x(S=>S===n?null:n)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:D.map(n=>e.jsxs("div",{className:`p-4 text-center rounded-[var(--radius-card)] border ${ne[n.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:n.value}),e.jsx("div",{className:"text-sm opacity-80",children:n.label})]},n.label))}),l.dailyUsage.length>0&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-4",children:r("externalApps.audit.dailyUsage",{days:30})}),e.jsx("div",{className:"flex items-end gap-1 h-32",children:l.dailyUsage.map(n=>{const S=n.success+n.failed,C=S/N*100,P=S>0?n.success/S*100:0;return e.jsx("div",{className:"flex-1 min-w-[4px] flex flex-col justify-end",title:`${new Date(n.date).toLocaleDateString()}: ${n.success} ${r("externalApps.audit.success")} / ${n.failed} ${r("externalApps.audit.failure")}`,children:e.jsxs("div",{className:"w-full rounded-t-sm overflow-hidden",style:{height:`${C}%`},children:[e.jsx("div",{className:"w-full bg-[var(--success-text)]",style:{height:`${P}%`}}),e.jsx("div",{className:"w-full bg-[var(--error-text)]",style:{height:`${100-P}%`}})]})},n.date)})}),e.jsx("div",{className:"flex justify-between text-xs text-[var(--text-tertiary)] mt-2",children:l.dailyUsage.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:new Date(l.dailyUsage[0].date).toLocaleDateString()}),e.jsx("span",{children:new Date(l.dailyUsage.at(-1).date).toLocaleDateString()})]})}),e.jsxs("div",{className:"flex gap-4 mt-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm bg-[var(--success-text)]"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:r("externalApps.audit.success")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm bg-[var(--error-text)]"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:r("externalApps.audit.failure")})]})]})]}),l.topIpAddresses.length>0&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-3",children:r("externalApps.audit.topIps")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.ip")}),e.jsx("th",{className:"text-right py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.requestCount")}),e.jsx("th",{className:"text-right py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.lastSeen")})]})}),e.jsx("tbody",{children:l.topIpAddresses.map(n=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] last:border-0",children:[e.jsx("td",{className:"py-2 px-3 font-mono text-[var(--text-primary)]",children:n.ipAddress}),e.jsx("td",{className:"py-2 px-3 text-right text-[var(--text-primary)]",children:n.requestCount}),e.jsx("td",{className:"py-2 px-3 text-right text-[var(--text-secondary)]",children:new Date(n.lastSeenAt).toLocaleString()})]},n.ipAddress))})]})})]}),s&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-3",children:r("externalApps.audit.title")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"w-8"}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.date")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.ip")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.action")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.endpoint")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.status")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.duration")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.error")}),e.jsx("th",{className:"text-left py-2 px-3 text-[var(--text-secondary)] font-medium",children:r("externalApps.audit.columns.userAgent")})]})}),e.jsxs("tbody",{children:[s.items.map(n=>{const S=f===n.id,C=ie(n.errorMessage),P=!!(n.errorMessage||n.userAgent||n.keyUsed);return e.jsxs(o.Fragment,{children:[e.jsxs("tr",{className:`border-b border-[var(--border-color)] last:border-0 ${P?"cursor-pointer hover:bg-[var(--bg-hover)]":""} ${S?"bg-[var(--bg-hover)]":""}`,onClick:()=>P&&T(n.id),children:[e.jsx("td",{className:"py-2 px-1 text-center text-[var(--text-tertiary)]",children:P&&(S?e.jsx(i.ChevronUp,{className:"w-4 h-4 inline"}):e.jsx(i.ChevronDown,{className:"w-4 h-4 inline"}))}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)] whitespace-nowrap",children:new Date(n.createdAt).toLocaleString()}),e.jsx("td",{className:"py-2 px-3 font-mono text-[var(--text-primary)]",children:n.ipAddress}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)]",children:n.action}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-primary)]",children:n.endpointCode?e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium font-mono bg-[var(--bg-secondary)] text-[var(--text-primary)] border border-[var(--border-color)]",children:n.endpointCode}):"-"}),e.jsx("td",{className:"py-2 px-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium ${n.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:n.success?r("externalApps.audit.success"):r("externalApps.audit.failure")})}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)] whitespace-nowrap",children:n.durationMs!=null?`${n.durationMs} ms`:"-"}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)]",children:n.errorCode?e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--error-bg)] text-[var(--error-text)]",children:n.errorCode}):"-"}),e.jsx("td",{className:"py-2 px-3 text-[var(--text-secondary)] max-w-[200px] truncate",title:n.userAgent??"",children:n.userAgent??"-"})]}),S&&P&&e.jsx("tr",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsx("td",{colSpan:9,className:"py-3 px-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[C&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] font-medium",children:[e.jsx(i.AlertTriangle,{className:"w-4 h-4"}),r("externalApps.audit.columns.error")]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-3 space-y-2",children:[C.message&&e.jsx("div",{className:"text-[var(--error-text)] font-medium",children:C.message}),(C.requiredPermissions?.length??0)>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx(i.Shield,{className:"w-3 h-3"}),r("externalApps.audit.requiredPermissions"),C.requireAll!=null&&e.jsxs("span",{className:"text-[var(--text-tertiary)]",children:["(",C.requireAll?r("externalApps.audit.requireAll"):r("externalApps.audit.requireAny"),")"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:C.requiredPermissions?.map(v=>e.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-mono bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:v},v))})]}),!C.requiredPermissions&&C.raw&&C.raw!==C.message&&e.jsx("pre",{className:"text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap break-all max-h-32 overflow-auto",children:C.raw})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.userAgent&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] font-medium mb-1",children:[e.jsx(i.Globe,{className:"w-4 h-4"}),r("externalApps.audit.columns.userAgent")]}),e.jsx("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-3",children:e.jsx("span",{className:"text-xs font-mono text-[var(--text-primary)] break-all",children:n.userAgent})})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs",children:[n.clientId&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[r("externalApps.audit.callingApp"),": "]}),e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:a.name}),e.jsxs("span",{className:"text-[var(--text-tertiary)] ml-1",children:["(",n.clientId,")"]})]}),n.keyUsed&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[r("externalApps.audit.keyUsed"),": "]}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.keyUsed})]}),n.durationMs!=null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(i.Clock,{className:"w-3 h-3 text-[var(--text-tertiary)]"}),e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[n.durationMs," ms"]})]})]})]})]})})})]},n.id)}),s.items.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"py-8 text-center text-[var(--text-secondary)]",children:r("externalApps.audit.noData")})})]})]})}),s.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[s.totalCount," ",r("externalApps.audit.totalRequests").toLowerCase()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>j(n=>Math.max(1,n-1)),disabled:!s.hasPreviousPage||c,className:"p-1.5 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-50",children:e.jsx(i.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[g," / ",s.totalPages]}),e.jsx("button",{onClick:()=>j(n=>n+1),disabled:!s.hasNextPage||c,className:"p-1.5 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-50",children:e.jsx(i.ChevronRight,{className:"w-4 h-4"})})]})]})]})]})},ce=(a,r,l,t,s)=>{const d=r.toLowerCase();return a.filter(c=>{if(d&&!c.name.toLowerCase().includes(d)&&!c.routeTemplate.toLowerCase().includes(d)&&!(c.description??"").toLowerCase().includes(d)||l&&c.accessType!==l)return!1;if(t){const h=s.get(c.id)?.isEnabled??!1;if(t==="enabled"&&!h||t==="disabled"&&h)return!1}return!0})};function oe({app:a,onUpdated:r,onError:l,onRefresh:t}){const{t:s}=E.useTranslation("admin"),{hasPermission:d}=A.useAuth(),c=d("api.permissions.assign"),[h,u]=o.useState([]),[b,g]=o.useState(new Map),[j,f]=o.useState(!0),[x,m]=o.useState(null),[p,w]=o.useState(!1),[N,D]=o.useState(!1),[T,n]=o.useState(""),[S,C]=o.useState(""),[P,v]=o.useState(""),[U,y]=o.useState(!1),[R,q]=o.useState(!1),[L,z]=o.useState(""),[k,W]=o.useState(""),$=o.useCallback(async()=>{try{f(!0);const[I,M]=await Promise.all([A.adminApi.externalApps.getApiEndpoints(),A.adminApi.externalApps.getAppApiAccess(a.id)]);u(I);const O=new Map;M.forEach(H=>O.set(H.dataApiEndpointId,H)),g(O)}catch(I){l(I instanceof Error?I.message:"Failed to load export data")}finally{f(!1)}},[a.id,l]);o.useEffect(()=>{$()},[$]);const V=I=>{const M=b.get(I.id);m(I),y(M?.isEnabled??!1),q(!1),z(M?.rateLimitPerMinute?.toString()??""),W(M?.maxPageSize?.toString()??""),w(!0)},_=()=>{w(!1),m(null)},Q=async()=>{if(x)try{D(!0);const I=x.accessType==="Write"?R:U;await A.adminApi.externalApps.updateApiAccess(a.id,x.id,{isEnabled:I,rateLimitPerMinute:L?parseInt(L):void 0,maxPageSize:k?parseInt(k):void 0}),r(s("externalApps.exports.success.saved")),await $(),t(),_()}catch(I){l(I instanceof Error?I.message:"Failed to save configuration")}finally{D(!1)}},G=o.useMemo(()=>ce(h,T,S,P,b),[h,T,S,P,b]);return j?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(i.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Database,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:s("externalApps.exports.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:s("externalApps.exports.description")}),h.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(i.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:T,onChange:I=>n(I.target.value),placeholder:s("externalApps.exports.search"),className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]"})]}),e.jsxs("select",{value:S,onChange:I=>C(I.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)]",children:[e.jsx("option",{value:"",children:s("externalApps.exports.allTypes")}),e.jsx("option",{value:"Read",children:s("externalApps.exports.accessTypeRead")}),e.jsx("option",{value:"Write",children:s("externalApps.exports.accessTypeWrite")})]}),e.jsxs("select",{value:P,onChange:I=>v(I.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)]",children:[e.jsx("option",{value:"",children:s("externalApps.exports.allStatuses")}),e.jsx("option",{value:"enabled",children:s("externalApps.exports.enabled")}),e.jsx("option",{value:"disabled",children:s("externalApps.exports.disabled")})]})]}),h.length===0&&e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(i.AlertCircle,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s("externalApps.exports.noEndpoints")]}),h.length>0&&G.length===0&&e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(i.Search,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s("externalApps.exports.noResults")]}),h.length>0&&G.length>0&&e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-1 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)] text-left",children:[e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.name")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.route")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.accessType")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.status")}),e.jsx("th",{className:"pb-3 pr-4 font-medium text-[var(--text-secondary)] text-right",children:s("externalApps.exports.columns.requests")}),e.jsx("th",{className:"pb-3 font-medium text-[var(--text-secondary)]",children:s("externalApps.exports.columns.lastAccessed")})]})}),e.jsx("tbody",{children:G.map(I=>{const M=b.get(I.id),O=M?.isEnabled??!1,H=x?.id===I.id&&p;return e.jsx(de,{endpoint:I,isSelected:H,isEnabled:O,access:M,onOpen:V},I.id)})})]})}),p&&x&&e.jsx(pe,{endpoint:x,isEnabled:b.get(x.id)?.isEnabled??!1,readEnabled:U,writeEnabled:R,editRateLimit:L,editMaxPageSize:k,canManage:c,saving:N,onReadEnabledChange:y,onWriteEnabledChange:q,onRateLimitChange:z,onMaxPageSizeChange:W,onSave:Q,onClose:_,accessMap:b})]})]})}function de({endpoint:a,isSelected:r,isEnabled:l,access:t,onOpen:s}){const{t:d}=E.useTranslation("admin");return e.jsxs("tr",{onClick:()=>s(a),className:`border-b border-[var(--border-color)] cursor-pointer transition-colors ${r?"bg-[var(--color-accent-500)]/5":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsxs("td",{className:"py-3 pr-4",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:a.name}),a.description&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 line-clamp-1",children:a.description})]}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("code",{className:"text-xs text-[var(--text-tertiary)]",children:a.routeTemplate})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`inline-flex px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${a.accessType==="Write"?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--info-bg)] text-[var(--info-text)]"}`,children:a.accessType==="Write"?d("externalApps.exports.accessTypeWrite"):d("externalApps.exports.accessTypeRead")})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-full text-xs font-medium ${l?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"}`,children:d(l?"externalApps.exports.enabled":"externalApps.exports.disabled")})}),e.jsx("td",{className:"py-3 pr-4 text-right",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(i.Activity,{className:"w-3 h-3"}),t?.totalRequestCount??0]})}),e.jsx("td",{className:"py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(i.Clock,{className:"w-3 h-3"}),t?.lastAccessedAt?new Date(t.lastAccessedAt).toLocaleDateString():d("externalApps.exports.never")]})})]})}function pe({endpoint:a,isEnabled:r,readEnabled:l,writeEnabled:t,editRateLimit:s,editMaxPageSize:d,canManage:c,saving:h,onReadEnabledChange:u,onWriteEnabledChange:b,onRateLimitChange:g,onMaxPageSizeChange:j,onSave:f,onClose:x,accessMap:m}){const{t:p}=E.useTranslation("admin"),w=m.get(a.id);return e.jsxs("div",{className:"w-96 shrink-0 border-l border-[var(--border-color)] bg-[var(--bg-secondary)] rounded-lg overflow-hidden shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] truncate pr-2",children:a.name}),e.jsx("button",{onClick:x,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:e.jsx(i.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-4 space-y-5 overflow-y-auto max-h-[calc(100vh-280px)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold uppercase ${a.accessType==="Write"?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--info-bg)] text-[var(--info-text)]"}`,children:a.accessType==="Write"?p("externalApps.exports.accessTypeWrite"):p("externalApps.exports.accessTypeRead")}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:a.entityType})]}),e.jsx("code",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] block",children:a.routeTemplate}),a.description&&e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:a.description})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.Shield,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionPermissions")]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.BookOpen,{className:"w-4 h-4 text-[var(--info-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:p("externalApps.exports.readAccess")})]}),c?e.jsx("button",{type:"button",onClick:()=>u(!l),disabled:a.accessType==="Write",className:"disabled:opacity-40",children:l&&a.accessType!=="Write"?e.jsx(i.ToggleRight,{className:"w-8 h-5 text-[var(--success-text)]"}):e.jsx(i.ToggleLeft,{className:"w-8 h-5 text-[var(--text-tertiary)]"})}):e.jsx("span",{className:`text-xs font-medium ${l?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:p(l?"externalApps.exports.enabled":"externalApps.exports.disabled")})]}),e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border bg-[var(--bg-primary)] ${a.accessType==="Write"?"border-[var(--border-color)]":"border-[var(--border-color)] opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.PenLine,{className:"w-4 h-4 text-[var(--warning-text)]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:p("externalApps.exports.writeAccess")}),a.accessType!=="Write"&&e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-0.5",children:p("externalApps.exports.writeNotAvailable")})]})]}),c?e.jsx("button",{type:"button",onClick:()=>a.accessType==="Write"&&b(!t),disabled:a.accessType!=="Write",className:"disabled:opacity-40",children:t&&a.accessType==="Write"?e.jsx(i.ToggleRight,{className:"w-8 h-5 text-[var(--success-text)]"}):e.jsx(i.ToggleLeft,{className:"w-8 h-5 text-[var(--text-tertiary)]"})}):e.jsx("span",{className:"text-xs font-medium text-[var(--text-tertiary)]",children:p("externalApps.exports.disabled")})]}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)] px-1",children:[e.jsxs("span",{className:"font-medium",children:[p("externalApps.exports.requiredPermission"),":"]}),e.jsx("code",{className:"px-1 py-0.5 rounded bg-[var(--bg-tertiary)]",children:a.requiredPermission})]})]}),c&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.Gauge,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionLimits")]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-1",children:p("externalApps.exports.drawer.rateLimit")}),e.jsx("input",{type:"number",min:"1",value:s,onChange:N=>g(N.target.value),className:"w-full px-3 py-1.5 text-sm rounded border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]",placeholder:a.defaultRateLimitPerMinute.toString()}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1",children:p("externalApps.exports.drawer.rateLimitHelp",{default:a.defaultRateLimitPerMinute})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-1",children:p("externalApps.exports.drawer.maxPageSize")}),e.jsx("input",{type:"number",min:"1",max:"10000",value:d,onChange:N=>j(N.target.value),className:"w-full px-3 py-1.5 text-sm rounded border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)]",placeholder:a.defaultMaxPageSize.toString()}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1",children:p("externalApps.exports.drawer.maxPageSizeHelp",{default:a.defaultMaxPageSize})})]})]})]}),w&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--text-primary)]",children:[e.jsx(i.BarChart3,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),p("externalApps.exports.drawer.sectionStats")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-center",children:[e.jsx("div",{className:"text-lg font-bold text-[var(--text-primary)]",children:w.totalRequestCount.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] uppercase tracking-wide",children:p("externalApps.exports.drawer.totalRequests")})]}),e.jsxs("div",{className:"p-3 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-center",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:w.lastAccessedAt?new Date(w.lastAccessedAt).toLocaleDateString():"—"}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] uppercase tracking-wide",children:p("externalApps.exports.drawer.lastAccessed")})]})]})]})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 p-4 border-t border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsxs("button",{onClick:f,disabled:h,className:"flex-1 inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white text-sm font-medium hover:bg-[var(--color-accent-700)] disabled:opacity-50 transition-colors",children:[h?e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(i.Save,{className:"w-4 h-4"}),p("externalApps.exports.drawer.save")]}),e.jsx("button",{onClick:x,disabled:h,className:"px-4 py-2 rounded-lg border border-[var(--border-color)] text-[var(--text-secondary)] text-sm font-medium hover:bg-[var(--bg-hover)] disabled:opacity-50 transition-colors",children:p("externalApps.exports.drawer.cancel")})]})]})}const K=[{code:"users",route:"/api/v1/export/users",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - scope l'export aux utilisateurs de ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC - entites creees ou modifiees apres cette date"},{name:"isActive",type:"bool?",default:"null",description:"Filtre par statut actif/inactif"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"email",type:"string",description:"Adresse email"},{name:"firstName",type:"string?",description:"Prenom"},{name:"lastName",type:"string?",description:"Nom de famille"},{name:"displayName",type:"string?",description:"Nom affiche"},{name:"isActive",type:"boolean",description:"Compte actif"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"roles",type:"string[]",description:"Noms des roles attribues"},{name:"tenantIds",type:"UUID[]",description:"IDs des tenants associes"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"tenants",route:"/api/v1/export/tenants",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant a exporter"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"name",type:"string",description:"Nom du tenant"},{name:"slug",type:"string",description:"Slug URL-friendly"},{name:"type",type:"string",description:"Type de tenant"},{name:"status",type:"string",description:"Statut (Active, Suspended, etc.)"},{name:"description",type:"string?",description:"Description"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"memberCount",type:"int",description:"Nombre de membres"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"roles",route:"/api/v1/export/roles",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - exporte les roles assignes dans ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 1000)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"name",type:"string",description:"Nom du role"},{name:"shortName",type:"string?",description:"Nom court"},{name:"code",type:"string?",description:"Code technique"},{name:"category",type:"string",description:"Categorie (Global, Admin, Manager, Contributor, Viewer, Custom)"},{name:"description",type:"string?",description:"Description du role"},{name:"isSystem",type:"boolean",description:"Role systeme (non modifiable)"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"permissions",type:"string[]",description:"Codes des permissions attribuees"}],defaultRateLimit:60,defaultMaxPageSize:1e3},{code:"tickets",route:"/api/v1/export/tickets",method:"GET",paginated:!0,params:[{name:"tenantId",type:"UUID",default:"(requis)",description:"ID du tenant - exporte les tickets de ce tenant"},{name:"page",type:"int",default:"1",description:"Numero de page (commence a 1)"},{name:"pageSize",type:"int",default:"100",description:"Elements par page (max 500)"},{name:"modifiedSince",type:"DateTime?",default:"null",description:"Filtre incremental UTC"}],responseFields:[{name:"id",type:"UUID",description:"Identifiant unique"},{name:"title",type:"string",description:"Titre du ticket"},{name:"type",type:"string",description:"Type (Bug, Feature, Support, etc.)"},{name:"status",type:"string",description:"Statut (Open, InProgress, Resolved, Closed)"},{name:"priority",type:"string",description:"Priorite (Low, Medium, High, Critical)"},{name:"assignedToUserId",type:"UUID?",description:"ID utilisateur assigne"},{name:"createdByUserId",type:"UUID",description:"ID createur"},{name:"tenantId",type:"UUID?",description:"ID tenant associe"},{name:"createdAt",type:"DateTime",description:"Date de creation (UTC)"},{name:"updatedAt",type:"DateTime?",description:"Date de derniere modification (UTC)"},{name:"resolvedAt",type:"DateTime?",description:"Date de resolution (UTC)"},{name:"closedAt",type:"DateTime?",description:"Date de fermeture (UTC)"}],defaultRateLimit:30,defaultMaxPageSize:500,notes:"Rate limit reduit a 30 req/min. Page size max 500."},{code:"navigation",route:"/api/v1/export/navigation",method:"GET",paginated:!1,params:[],responseFields:[{name:"id",type:"UUID",description:"Identifiant de l'application"},{name:"code",type:"string",description:"Code technique de l'application"},{name:"label",type:"string",description:"Libelle affiche"},{name:"modules",type:"object[]",description:"Liste des modules (chacun: id, code, label)"}],defaultRateLimit:60,defaultMaxPageSize:1e3,notes:"Endpoint NON pagine. Retourne directement un tableau JSON (pas d'envelope de pagination). Contient la structure de navigation : applications avec leurs modules."}];function xe({app:a}){const{t:r}=E.useTranslation("admin"),[l,t]=o.useState(new Set),[s,d]=o.useState(!1),c=j=>{t(f=>{const x=new Set(f);return x.has(j)?x.delete(j):x.add(j),x})},h=()=>{t(new Set(K.map(j=>j.code)))},u=()=>{t(new Set)},b=o.useMemo(()=>l.size===0?"":ve(a,l),[a,l]),g=async()=>{if(b)try{await navigator.clipboard.writeText(b),d(!0),setTimeout(()=>d(!1),3e3)}catch{}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ue,{description:r("externalApps.prompt.description"),subdescription:r("externalApps.prompt.subdescription")}),e.jsx(me,{selectedEndpoints:l,onSelectAll:h,onDeselectAll:u,onToggleEndpoint:c}),l.size>0&&e.jsx(he,{selectedEndpoints:l,generatedPrompt:b,copied:s,onCopy:g}),l.size===0&&e.jsxs("div",{className:"text-center py-12 text-[var(--text-tertiary)]",children:[e.jsx(i.Check,{className:"w-12 h-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:r("externalApps.prompt.emptyState")})]})]})}function ue({description:a,subdescription:r}){return e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(i.Info,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[var(--info-text)]",children:a}),e.jsx("p",{className:"text-xs text-[var(--info-text)] opacity-80 mt-1",children:r})]})]})})}function me({selectedEndpoints:a,onSelectAll:r,onDeselectAll:l,onToggleEndpoint:t}){const{t:s}=E.useTranslation("admin");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:s("externalApps.prompt.selectEndpoints")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r,className:"text-xs text-[var(--color-accent-600)] hover:underline",children:s("externalApps.prompt.selectAll")}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"|"}),e.jsx("button",{onClick:l,className:"text-xs text-[var(--text-tertiary)] hover:underline",children:s("externalApps.prompt.deselectAll")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:K.map(d=>{const c=a.has(d.code);return e.jsxs("button",{onClick:()=>t(d.code),className:`flex items-start gap-3 p-4 rounded-[var(--radius-card)] border text-left transition-colors ${c?"border-[var(--color-accent-600)] bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-600)]/10":"border-[var(--border-color)] bg-[var(--bg-card)] hover:bg-[var(--bg-hover)]"}`,children:[c?e.jsx(i.CheckSquare,{className:"w-5 h-5 text-[var(--color-accent-600)] flex-shrink-0 mt-0.5"}):e.jsx(i.Square,{className:"w-5 h-5 text-[var(--text-tertiary)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-[var(--text-primary)]",children:s(`externalApps.prompt.endpoints.${d.code}.name`)}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 font-mono",children:[d.method," ",d.route]}),e.jsxs("div",{className:"text-xs text-[var(--text-secondary)] mt-1",children:[d.responseFields.length," ",s("externalApps.prompt.fields"),!d.paginated&&e.jsx("span",{className:"ml-2 text-[var(--warning-text)]",children:s("externalApps.prompt.nonPaginated")})]})]})]},d.code)})})]})}function he({selectedEndpoints:a,generatedPrompt:r,copied:l,onCopy:t}){const{t:s}=E.useTranslation("admin");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[s("externalApps.prompt.generatedPrompt"),e.jsxs("span",{className:"ml-2 text-sm font-normal text-[var(--text-tertiary)]",children:["(",a.size," ",a.size===1?s("externalApps.prompt.endpointSingular"):s("externalApps.prompt.endpointPlural"),")"]})]}),e.jsx("button",{onClick:t,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors text-sm font-medium",children:l?e.jsxs(e.Fragment,{children:[e.jsx(i.CheckCircle,{className:"w-4 h-4"}),s("externalApps.prompt.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(i.Copy,{className:"w-4 h-4"}),s("externalApps.prompt.copyPrompt")]})})]}),e.jsx("div",{className:"relative",children:e.jsx("pre",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words overflow-x-auto max-h-[600px] overflow-y-auto leading-relaxed",children:r})})]})}function ve(a,r){const l=K.filter(d=>r.has(d.code)),t=[];t.push("## Contexte"),t.push(""),t.push("Tu dois implementer un client HTTP qui consomme l'API DataExport de SmartStack en mode **machine-to-machine** (M2M). Il n'y a aucune interaction utilisateur : ton application s'authentifie avec un `clientId` et un `clientSecret`, obtient un token JWT, puis appelle les endpoints d'export de donnees."),t.push(""),t.push(`Client ID de cette application : \`${a.clientId}\``),t.push(""),t.push("---"),t.push(""),t.push("## 1. Authentification (HMAC-JWT Assertion)"),t.push(""),t.push("L'authentification se fait en 2 etapes :"),t.push(""),t.push("### Etape 1 : Creer une assertion JWT signee HMAC-SHA256"),t.push(""),t.push("Ton application doit generer un JWT **signe avec le `clientSecret`** (HMAC-SHA256) :"),t.push(""),t.push("```"),t.push('Header: { "alg": "HS256", "typ": "JWT" }'),t.push("Payload: {"),t.push(` "sub": "${a.clientId}", // ton clientId`),t.push(' "iat": <timestamp-unix-actuel>, // timestamp Unix actuel'),t.push(' "exp": <timestamp-unix + 300>, // expiration (max 5 min apres iat)'),t.push(' "jti": "<uuid-unique>" // nonce anti-replay'),t.push("}"),t.push("Signature: HMAC-SHA256(header.payload, Base64Decode(clientSecret))"),t.push("```"),t.push(""),t.push("**Important** : Le `clientSecret` est encode en Base64. Tu dois le **decoder** avant de l'utiliser comme cle HMAC."),t.push(""),t.push("### Etape 2 : Echanger l'assertion contre un access token"),t.push(""),t.push("```http"),t.push("POST {baseUrl}/api/auth/external-app/token"),t.push("Content-Type: application/json"),t.push(""),t.push("{"),t.push(' "assertion": "<jwt-assertion-de-etape-1>"'),t.push("}"),t.push("```"),t.push(""),t.push("**Reponse succes (200)** :"),t.push("```json"),t.push("{"),t.push(' "accessToken": "eyJhbGciOiJIUz...",'),t.push(' "expiresAt": "2026-02-25T11:00:00Z",'),t.push(' "permissions": ["administration.users.read", ...]'),t.push("}"),t.push("```"),t.push(""),t.push("### Erreurs d'authentification"),t.push(""),t.push("| HTTP | errorCode | Cause |"),t.push("|------|-----------|-------|"),t.push("| 401 | `invalid_assertion` | JWT mal forme ou invalide |"),t.push("| 401 | `missing_client_id` | Claim `sub` absent du JWT |"),t.push("| 401 | `unknown_client` | ClientId inconnu |"),t.push("| 401 | `app_inactive` | Application desactivee |"),t.push("| 401 | `ip_blocked` | IP pas dans la whitelist |"),t.push("| 401 | `invalid_signature` | Signature HMAC invalide |"),t.push(""),t.push("### Regles de gestion du token"),t.push(""),t.push("- Cache le token et renouvelle-le 5 min avant `expiresAt`"),t.push("- N'appelle PAS `/token` a chaque requete"),t.push(""),t.push("---"),t.push(""),t.push("## 2. Isolation par tenant (OBLIGATOIRE)"),t.push(""),t.push("**Tous les endpoints (sauf Navigation) necessitent le parametre `tenantId`** (UUID) en query string."),t.push("Ce parametre scope l'export aux donnees du tenant specifie. Sans ce parametre, l'API retourne une erreur 400."),t.push(""),t.push("Si ton application doit synchroniser plusieurs tenants, appelle chaque endpoint une fois par tenant."),t.push(""),t.push("---"),t.push(""),t.push(`## 3. Endpoints a implementer (${l.length})`),t.push("");for(const d of l){if(t.push(`### ${d.code.charAt(0).toUpperCase()+d.code.slice(1)} Export`),t.push(""),t.push("```http"),t.push(`${d.method} {baseUrl}${d.route}`),t.push("Authorization: Bearer <accessToken>"),t.push("```"),t.push(""),d.params.length>0){t.push("**Parametres (query string)** :"),t.push(""),t.push("| Parametre | Type | Defaut | Description |"),t.push("|-----------|------|--------|-------------|");for(const c of d.params)t.push(`| \`${c.name}\` | ${c.type} | ${c.default} | ${c.description} |`);t.push("")}else t.push("**Aucun parametre** - appel direct sans query string."),t.push("");if(d.paginated){t.push("**Reponse (paginee)** :"),t.push("```json"),t.push("{"),t.push(' "items": ['),t.push(" {");for(let c=0;c<d.responseFields.length;c++){const h=d.responseFields[c],u=c<d.responseFields.length-1?",":"";t.push(` "${h.name}": ${J(h.type)}${u} // ${h.type} - ${h.description}`)}t.push(" }"),t.push(" ],"),t.push(' "page": 1,'),t.push(' "pageSize": 100,'),t.push(' "totalCount": 250,'),t.push(' "totalPages": 3,'),t.push(' "hasMore": true'),t.push("}"),t.push("```")}else{t.push("**Reponse (tableau direct, NON pagine)** :"),t.push("```json"),t.push("["),t.push(" {");for(let c=0;c<d.responseFields.length;c++){const h=d.responseFields[c],u=c<d.responseFields.length-1?",":"";t.push(` "${h.name}": ${J(h.type)}${u} // ${h.type} - ${h.description}`)}t.push(" }"),t.push("]"),t.push("```")}t.push(""),t.push(`**Rate limit** : ${d.defaultRateLimit} requetes/minute | Page size max : ${d.defaultMaxPageSize}`),d.notes&&t.push(`**Note** : ${d.notes}`),t.push("")}t.push("---"),t.push("");const s=l.some(d=>d.paginated);return s&&(t.push("## 4. Pagination"),t.push(""),t.push("Pour parcourir toutes les pages : boucle tant que `hasMore === true`, en incrementant `page`."),t.push("Les resultats sont tries par `createdAt ASC` (ordre stable)."),t.push(""),t.push("---"),t.push("")),s&&(t.push("## 5. Synchronisation incrementale"),t.push(""),t.push("Utilise `modifiedSince` pour ne recuperer que les changements :"),t.push("1. Premiere synchro : appelle sans `modifiedSince` (recupere tout)"),t.push("2. Stocke `DateTime.UtcNow` du debut de la synchro"),t.push("3. Synchros suivantes : passe `modifiedSince=<timestamp-stocke>`"),t.push(""),t.push("Le filtre retourne les entites ou `UpdatedAt >= modifiedSince OR CreatedAt >= modifiedSince`."),t.push(""),t.push("---"),t.push("")),t.push("## 6. Rate Limiting"),t.push(""),t.push("| Aspect | Valeur |"),t.push("|--------|--------|"),t.push("| Algorithme | Fenetre fixe de 1 minute |"),t.push("| Cle de partition | {clientId}:{endpointCode} (independant par endpoint) |"),t.push(""),t.push("Quand tu depasses la limite :"),t.push("```"),t.push("HTTP/1.1 429 Too Many Requests"),t.push("Retry-After: 42"),t.push("```"),t.push("Lis le header `Retry-After` et attends. Implemente un backoff exponentiel."),t.push(""),t.push("---"),t.push(""),t.push("## 7. Gestion des erreurs"),t.push(""),t.push("| HTTP | Action |"),t.push("|------|--------|"),t.push("| 200 | Traite les donnees |"),t.push("| 400 | tenantId manquant ou invalide |"),t.push("| 401 | Renouvelle le token et relance |"),t.push("| 403 | Acces export non accorde - contacte l'admin |"),t.push("| 404 | Tenant non trouve - verifie le tenantId |"),t.push("| 429 | Attends `Retry-After` secondes |"),t.push("| 500 | Retry avec backoff exponentiel |"),t.push(""),t.push("---"),t.push(""),t.push("## 8. Checklist d'implementation"),t.push(""),t.push("### 8.1 Configuration"),t.push("```"),t.push("SMARTSTACK_BASE_URL=https://smartstack.example.com"),t.push(`SMARTSTACK_CLIENT_ID=${a.clientId}`),t.push("SMARTSTACK_CLIENT_SECRET=<base64-encoded-secret>"),t.push("```"),t.push("Ne hardcode JAMAIS le clientId/clientSecret. Utilise des variables d'environnement ou un vault."),t.push(""),t.push("### 8.2 Service d'authentification"),t.push("```"),t.push("SmartStackAuthService:"),t.push(" - generateAssertion() → JWT HMAC-SHA256 signe avec le secret decode du Base64"),t.push(" - getAccessToken() → POST /api/auth/external-app/token"),t.push(" - cachedToken / expiresAt → cache le token, renouvelle 5 min avant expiration"),t.push("```"),t.push(""),t.push("### 8.3 Client HTTP generique"),t.push("```"),t.push("SmartStackExportClient:"),t.push(" - fetchExport(endpointCode, tenantId, page?, pageSize?, modifiedSince?, extraParams?)"),t.push(" → GET /api/v1/export/{endpointCode}?tenantId={tenantId}"),t.push(" - fetchAllPages(endpointCode, tenantId, pageSize?, modifiedSince?)"),t.push(" → boucle automatique sur toutes les pages"),t.push(" - Gere 401 (retry token), 429 (Retry-After), 5xx (backoff)"),t.push("```"),t.push(""),t.push("### 8.4 Synchroniseur incremental"),t.push("```"),t.push("SmartStackSyncService:"),t.push(` - endpoints: [${l.map(d=>`"${d.code}"`).join(", ")}]`),t.push(" - tenantIds: [<liste des tenantIds a synchroniser>]"),t.push(" - syncAll() → pour chaque tenant, pour chaque endpoint, appelle syncEndpoint()"),t.push(" - syncEndpoint(code, tenantId):"),t.push(" 1. Lit le dernier timestamp de synchro (par endpoint + tenant)"),t.push(" 2. Appelle fetchAllPages(code, tenantId, modifiedSince)"),t.push(" 3. Upsert les donnees (INSERT si nouveau, UPDATE si existant, par `id`)"),t.push(" 4. Sauve le timestamp"),t.push("```"),t.push(""),t.push("### 8.5 Securite"),t.push(""),t.push("- Stocke le clientSecret dans un vault (Azure Key Vault, etc.)"),t.push("- L'assertion JWT a une duree courte (5 min max)"),t.push("- Ne log jamais le token d'acces"),t.push("- Toutes les requetes sont auditees cote SmartStack (IP, User-Agent)"),t.join(`
2
2
  `)}function J(a){switch(a){case"UUID":return'"3fa85f64-5717-4562-b3fc-2c963f66afa6"';case"UUID?":return"null";case"string":return'"..."';case"string?":return'"..."';case"boolean":return"true";case"int":return"0";case"DateTime":return'"2026-01-15T10:30:00Z"';case"DateTime?":return"null";case"string[]":return'["item1", "item2"]';case"UUID[]":return'["uuid1", "uuid2"]';case"object[]":return'[{"id": "...", "code": "...", "label": "..."}]';default:return'"..."'}}const be=["info","keys","roles","exports","prompt","audit"];function ge(){const{id:a}=B.useParams(),r=B.useNavigate(),{t:l}=E.useTranslation("admin"),{hasPermission:t}=A.useAuth(),{currentTenant:s,isGlobalView:d}=A.useTenant(),{activeTab:c,setActiveTab:h}=Z.useTabNavigation("info",be),[u,b]=o.useState(null),[g,j]=o.useState(!0),[f,x]=o.useState(null),[m,p]=o.useState(null),[w,N]=o.useState(!1),[D,T]=o.useState(!1),[n,S]=o.useState(!1),C=t("api.accounts.delete"),P=t("api.accounts.update"),v=o.useRef(!1),U=o.useCallback(async()=>{if(a)try{v.current||j(!0);const k=await A.adminApi.externalApps.getById(a);b(k),x(null),v.current=!0}catch(k){x(k instanceof Error?k.message:"Failed to load external application")}finally{j(!1)}},[a,s?.id,d]);o.useEffect(()=>{U()},[U]);const y=async()=>{if(!(!u||!a))try{N(!0),u.isActive?(await A.adminApi.externalApps.deactivate(a),p(l("externalApps.detail.success.deactivated"))):(await A.adminApi.externalApps.activate(a),p(l("externalApps.detail.success.activated"))),T(!1),await U()}catch(k){x(k instanceof Error?k.message:"Failed to toggle status")}finally{N(!1)}},R=async()=>{if(a)try{N(!0),await A.adminApi.externalApps.delete(a),S(!1),r("/api/accounts/list")}catch(k){x(k instanceof Error?k.message:"Failed to delete"),S(!1)}finally{N(!1)}},q=k=>{p(k),x(null),setTimeout(()=>p(null),5e3)},L=k=>{x(k),p(null)};if(g)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(i.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(f&&!u)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx(i.AlertCircle,{className:"w-12 h-12 text-[var(--error-text)] mx-auto mb-4"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:f||l("externalApps.detail.notFound")}),e.jsx("button",{onClick:()=>r("/api/accounts/list"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)]",children:l("externalApps.detail.backToList")})]});if(!u)return null;const z=[{id:"info",label:l("externalApps.detail.tabs.info"),icon:i.Settings},{id:"keys",label:l("externalApps.detail.tabs.keys"),icon:i.Key},{id:"roles",label:l("externalApps.detail.tabs.roles"),icon:i.Shield},{id:"exports",label:l("externalApps.detail.tabs.exports"),icon:i.Database},{id:"prompt",label:l("externalApps.detail.tabs.prompt"),icon:i.Terminal},{id:"audit",label:l("externalApps.detail.tabs.audit"),icon:i.FileText}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx(A.Breadcrumb,{items:[{label:l("externalApps.navigation.api"),href:"/api"},{label:l("externalApps.title"),href:"/api/accounts/list"},{label:u.name}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>r("/api/accounts/list"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors","aria-label":l("externalApps.detail.backToList"),children:e.jsx(i.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:u.name}),u.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:u.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-[var(--radius-badge)] text-sm font-medium ${u.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]"}`,children:u.isActive?l("externalApps.list.active"):l("externalApps.list.inactive")}),P&&e.jsxs("button",{onClick:()=>u.isActive?T(!0):y(),disabled:w,className:`inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${u.isActive?"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)] hover:bg-[var(--error-border)]":"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)] hover:bg-[var(--success-border)]"} disabled:opacity-50`,children:[w&&e.jsx(i.Loader2,{className:"w-4 h-4 animate-spin"}),!w&&u.isActive&&e.jsx(i.PowerOff,{className:"w-4 h-4"}),!w&&!u.isActive&&e.jsx(i.Power,{className:"w-4 h-4"}),u.isActive?l("externalApps.detail.deactivate"):l("externalApps.detail.activate")]}),C&&e.jsxs("button",{onClick:()=>S(!0),disabled:w,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)] hover:bg-[var(--error-border)] disabled:opacity-50",children:[e.jsx(i.Trash2,{className:"w-4 h-4"}),l("externalApps.detail.delete")]})]})]}),f&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(i.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),f]}),m&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(i.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),m]}),e.jsx("div",{className:"flex gap-1 p-1 overflow-x-auto bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",role:"tablist","aria-label":l("externalApps.detail.tabs.label"),children:z.map(k=>{const W=k.icon,$=c===k.id;return e.jsxs("button",{role:"tab","aria-selected":$,"aria-controls":`tabpanel-${k.id}`,onClick:()=>h(k.id),className:`flex items-center gap-2 px-4 py-2 whitespace-nowrap rounded-[var(--radius-button)] font-medium transition-colors ${$?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(W,{className:"w-4 h-4"}),k.label]},k.id)})}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",role:"tabpanel",id:`tabpanel-${c}`,"aria-labelledby":c,children:[c==="info"&&e.jsx(se,{app:u,onUpdated:q,onError:L,onRefresh:U}),c==="keys"&&e.jsx(ae,{app:u,onUpdated:q,onError:L,onRefresh:U}),c==="roles"&&e.jsx(re,{app:u,onUpdated:q,onError:L,onRefresh:U}),c==="exports"&&e.jsx(oe,{app:u,onUpdated:q,onError:L,onRefresh:U}),c==="prompt"&&e.jsx(xe,{app:u}),c==="audit"&&e.jsx(le,{app:u})]}),e.jsx(F.ConfirmModal,{isOpen:D,title:l("externalApps.detail.deactivate"),message:l("externalApps.detail.confirmDeactivate",{name:u.name}),variant:"warning",loading:w,onConfirm:y,onCancel:()=>T(!1)}),e.jsx(F.ConfirmModal,{isOpen:n,title:l("externalApps.detail.delete"),message:l("externalApps.detail.confirmDelete",{name:u.name}),variant:"danger",loading:w,onConfirm:R,onCancel:()=>S(!1)})]})}exports.ExternalAppCreatePage=te;exports.ExternalAppDetailPage=ge;exports.ExternalAppsListPage=ee;
3
- //# sourceMappingURL=index-B0mk2tNY.js.map
3
+ //# sourceMappingURL=index-tO6MMIFB.js.map