@atlashub/smartstack 3.28.0 → 3.30.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 (320) hide show
  1. package/dist/chunks/{AgentSkillsPage-ChykpPZx.js → AgentSkillsPage-CVq3qZoe.js} +2 -2
  2. package/dist/chunks/{AgentSkillsPage-ChykpPZx.js.map → AgentSkillsPage-CVq3qZoe.js.map} +1 -1
  3. package/dist/chunks/{AgentSkillsPage-ABpqnnyK.js → AgentSkillsPage-DJb49NMA.js} +2 -2
  4. package/dist/chunks/{AgentSkillsPage-ABpqnnyK.js.map → AgentSkillsPage-DJb49NMA.js.map} +1 -1
  5. package/dist/chunks/{AgentWorkloadPage-BltzNlXI.js → AgentWorkloadPage-D_nk3gKj.js} +2 -2
  6. package/dist/chunks/{AgentWorkloadPage-BltzNlXI.js.map → AgentWorkloadPage-D_nk3gKj.js.map} +1 -1
  7. package/dist/chunks/{AgentWorkloadPage-BI5QWJyQ.js → AgentWorkloadPage-oHEi-sFh.js} +2 -2
  8. package/dist/chunks/{AgentWorkloadPage-BI5QWJyQ.js.map → AgentWorkloadPage-oHEi-sFh.js.map} +1 -1
  9. package/dist/chunks/{ApiCatalogDetailPage-BaheZKBq.js → ApiCatalogDetailPage-Cr0q2HnB.js} +3 -3
  10. package/dist/chunks/{ApiCatalogDetailPage-BaheZKBq.js.map → ApiCatalogDetailPage-Cr0q2HnB.js.map} +1 -1
  11. package/dist/chunks/{ApiCatalogDetailPage-CsRxlHwO.js → ApiCatalogDetailPage-DX8buBkV.js} +2 -2
  12. package/dist/chunks/{ApiCatalogDetailPage-CsRxlHwO.js.map → ApiCatalogDetailPage-DX8buBkV.js.map} +1 -1
  13. package/dist/chunks/{ApiCatalogPage-CqmmHpQ4.js → ApiCatalogPage-DN7sazvI.js} +2 -2
  14. package/dist/chunks/{ApiCatalogPage-CqmmHpQ4.js.map → ApiCatalogPage-DN7sazvI.js.map} +1 -1
  15. package/dist/chunks/{ApiCatalogPage-B0yIz8-U.js → ApiCatalogPage-DqboIzZE.js} +2 -2
  16. package/dist/chunks/{ApiCatalogPage-B0yIz8-U.js.map → ApiCatalogPage-DqboIzZE.js.map} +1 -1
  17. package/dist/chunks/{ApplicationDetailPage-CngD5JSN.js → ApplicationDetailPage--9YwwS5A.js} +2 -2
  18. package/dist/chunks/{ApplicationDetailPage-CngD5JSN.js.map → ApplicationDetailPage--9YwwS5A.js.map} +1 -1
  19. package/dist/chunks/{ApplicationDetailPage-CdT6KNd7.js → ApplicationDetailPage-CCNjr64K.js} +4 -4
  20. package/dist/chunks/{ApplicationDetailPage-CdT6KNd7.js.map → ApplicationDetailPage-CCNjr64K.js.map} +1 -1
  21. package/dist/chunks/{ApplicationsDashboardPage-DHmnjk2O.js → ApplicationsDashboardPage-BSsHN3Yj.js} +2 -2
  22. package/dist/chunks/{ApplicationsDashboardPage-DHmnjk2O.js.map → ApplicationsDashboardPage-BSsHN3Yj.js.map} +1 -1
  23. package/dist/chunks/{ApplicationsDashboardPage-1V4iQ6eY.js → ApplicationsDashboardPage-Bs-Xgca4.js} +3 -3
  24. package/dist/chunks/{ApplicationsDashboardPage-1V4iQ6eY.js.map → ApplicationsDashboardPage-Bs-Xgca4.js.map} +1 -1
  25. package/dist/chunks/{ApplicationsGridPage-Bo3NDnBF.js → ApplicationsGridPage-DDysNWJ5.js} +2 -2
  26. package/dist/chunks/{ApplicationsGridPage-Bo3NDnBF.js.map → ApplicationsGridPage-DDysNWJ5.js.map} +1 -1
  27. package/dist/chunks/{ApplicationsGridPage-CiMJFlB_.js → ApplicationsGridPage-s1WEzOXS.js} +2 -2
  28. package/dist/chunks/{ApplicationsGridPage-CiMJFlB_.js.map → ApplicationsGridPage-s1WEzOXS.js.map} +1 -1
  29. package/dist/chunks/{ApplicationsListPage-L2_S23aN.js → ApplicationsListPage-B3CSMiV0.js} +2 -2
  30. package/dist/chunks/{ApplicationsListPage-L2_S23aN.js.map → ApplicationsListPage-B3CSMiV0.js.map} +1 -1
  31. package/dist/chunks/{ApplicationsListPage-De8jQ1Cm.js → ApplicationsListPage-B6ZCecIl.js} +2 -2
  32. package/dist/chunks/{ApplicationsListPage-De8jQ1Cm.js.map → ApplicationsListPage-B6ZCecIl.js.map} +1 -1
  33. package/dist/chunks/{ApplicationsPage-DBq7_Sm8.js → ApplicationsPage-BBaiBM--.js} +2 -2
  34. package/dist/chunks/{ApplicationsPage-DBq7_Sm8.js.map → ApplicationsPage-BBaiBM--.js.map} +1 -1
  35. package/dist/chunks/{ApplicationsPage-CiNI-b0R.js → ApplicationsPage-ztPwoAGt.js} +4 -4
  36. package/dist/chunks/{ApplicationsPage-CiNI-b0R.js.map → ApplicationsPage-ztPwoAGt.js.map} +1 -1
  37. package/dist/chunks/{AssignmentRulesPage-DFsO4ZES.js → AssignmentRulesPage-CK4L4rBO.js} +2 -2
  38. package/dist/chunks/{AssignmentRulesPage-DFsO4ZES.js.map → AssignmentRulesPage-CK4L4rBO.js.map} +1 -1
  39. package/dist/chunks/{AssignmentRulesPage-C8rfUsMB.js → AssignmentRulesPage-DFSVFFXr.js} +2 -2
  40. package/dist/chunks/{AssignmentRulesPage-C8rfUsMB.js.map → AssignmentRulesPage-DFSVFFXr.js.map} +1 -1
  41. package/dist/chunks/{AssignmentsPage-78C_EBsw.js → AssignmentsPage-Bp7oQD7Q.js} +2 -2
  42. package/dist/chunks/{AssignmentsPage-78C_EBsw.js.map → AssignmentsPage-Bp7oQD7Q.js.map} +1 -1
  43. package/dist/chunks/{AssignmentsPage-COCikISI.js → AssignmentsPage-JCLpyg94.js} +2 -2
  44. package/dist/chunks/{AssignmentsPage-COCikISI.js.map → AssignmentsPage-JCLpyg94.js.map} +1 -1
  45. package/dist/chunks/{AuthCallbackPage-DqT6ueVi.js → AuthCallbackPage-Bl9xlJ3h.js} +2 -2
  46. package/dist/chunks/{AuthCallbackPage-DqT6ueVi.js.map → AuthCallbackPage-Bl9xlJ3h.js.map} +1 -1
  47. package/dist/chunks/{AuthCallbackPage-BF4bkTnR.js → AuthCallbackPage-CzMHz4jy.js} +2 -2
  48. package/dist/chunks/{AuthCallbackPage-BF4bkTnR.js.map → AuthCallbackPage-CzMHz4jy.js.map} +1 -1
  49. package/dist/chunks/{ConfirmEmailPage-Bh_K5qJn.js → ConfirmEmailPage-D_8T1vqV.js} +2 -2
  50. package/dist/chunks/{ConfirmEmailPage-Bh_K5qJn.js.map → ConfirmEmailPage-D_8T1vqV.js.map} +1 -1
  51. package/dist/chunks/{ConfirmEmailPage-DJy4idrf.js → ConfirmEmailPage-M7mJgXvn.js} +2 -2
  52. package/dist/chunks/{ConfirmEmailPage-DJy4idrf.js.map → ConfirmEmailPage-M7mJgXvn.js.map} +1 -1
  53. package/dist/chunks/{CreateSupportTicketPage-pL7jbG9o.js → CreateSupportTicketPage-BNEGavlu.js} +2 -2
  54. package/dist/chunks/{CreateSupportTicketPage-pL7jbG9o.js.map → CreateSupportTicketPage-BNEGavlu.js.map} +1 -1
  55. package/dist/chunks/{CreateSupportTicketPage-AVTwXbJd.js → CreateSupportTicketPage-C2X2mfds.js} +2 -2
  56. package/dist/chunks/{CreateSupportTicketPage-AVTwXbJd.js.map → CreateSupportTicketPage-C2X2mfds.js.map} +1 -1
  57. package/dist/chunks/{DashboardPage-DdQlTLw0.js → DashboardPage-4oy2YqvT.js} +2 -2
  58. package/dist/chunks/{DashboardPage-DdQlTLw0.js.map → DashboardPage-4oy2YqvT.js.map} +1 -1
  59. package/dist/chunks/{DashboardPage-C55mIiB6.js → DashboardPage-CO-8B8EI.js} +3 -3
  60. package/dist/chunks/{DashboardPage-C55mIiB6.js.map → DashboardPage-CO-8B8EI.js.map} +1 -1
  61. package/dist/chunks/{DashboardPage-CcCnUl7s.js → DashboardPage-CPArUG-S.js} +2 -2
  62. package/dist/chunks/{DashboardPage-CcCnUl7s.js.map → DashboardPage-CPArUG-S.js.map} +1 -1
  63. package/dist/chunks/{DashboardPage-DOitDfGV.js → DashboardPage-D5MRMxEV.js} +3 -3
  64. package/dist/chunks/{DashboardPage-DOitDfGV.js.map → DashboardPage-D5MRMxEV.js.map} +1 -1
  65. package/dist/chunks/{EscalationConfigPage-DNnZftCH.js → EscalationConfigPage-CwdnfJbJ.js} +2 -2
  66. package/dist/chunks/{EscalationConfigPage-DNnZftCH.js.map → EscalationConfigPage-CwdnfJbJ.js.map} +1 -1
  67. package/dist/chunks/{EscalationConfigPage-DRr55328.js → EscalationConfigPage-DnjLFXnL.js} +2 -2
  68. package/dist/chunks/{EscalationConfigPage-DRr55328.js.map → EscalationConfigPage-DnjLFXnL.js.map} +1 -1
  69. package/dist/chunks/{ForceChangePasswordPage-1SCOPIqK.js → ForceChangePasswordPage-ZEIfyqwE.js} +2 -2
  70. package/dist/chunks/{ForceChangePasswordPage-1SCOPIqK.js.map → ForceChangePasswordPage-ZEIfyqwE.js.map} +1 -1
  71. package/dist/chunks/{ForceChangePasswordPage-DBeG_HRO.js → ForceChangePasswordPage-sh-3h_H9.js} +2 -2
  72. package/dist/chunks/{ForceChangePasswordPage-DBeG_HRO.js.map → ForceChangePasswordPage-sh-3h_H9.js.map} +1 -1
  73. package/dist/chunks/{ForgotPasswordPage-Dlb6wKfC.js → ForgotPasswordPage-B4M6-xeM.js} +2 -2
  74. package/dist/chunks/{ForgotPasswordPage-Dlb6wKfC.js.map → ForgotPasswordPage-B4M6-xeM.js.map} +1 -1
  75. package/dist/chunks/{ForgotPasswordPage-DffYfXva.js → ForgotPasswordPage-MIu-U7p0.js} +2 -2
  76. package/dist/chunks/{ForgotPasswordPage-DffYfXva.js.map → ForgotPasswordPage-MIu-U7p0.js.map} +1 -1
  77. package/dist/chunks/{GroupDetailPage-C9nRbeHI.js → GroupDetailPage-4XK3Bs_r.js} +5 -5
  78. package/dist/chunks/{GroupDetailPage-C9nRbeHI.js.map → GroupDetailPage-4XK3Bs_r.js.map} +1 -1
  79. package/dist/chunks/{GroupDetailPage-CPPUWzXf.js → GroupDetailPage-C-kvtd2T.js} +2 -2
  80. package/dist/chunks/{GroupDetailPage-CPPUWzXf.js.map → GroupDetailPage-C-kvtd2T.js.map} +1 -1
  81. package/dist/chunks/{MyAccessRequestsPage-BAX0xwJX.js → MyAccessRequestsPage-CP41FzHi.js} +2 -2
  82. package/dist/chunks/{MyAccessRequestsPage-BAX0xwJX.js.map → MyAccessRequestsPage-CP41FzHi.js.map} +1 -1
  83. package/dist/chunks/{MyAccessRequestsPage-BMY1V631.js → MyAccessRequestsPage-DzrXTrVi.js} +2 -2
  84. package/dist/chunks/{MyAccessRequestsPage-BMY1V631.js.map → MyAccessRequestsPage-DzrXTrVi.js.map} +1 -1
  85. package/dist/chunks/{MyTenantsPage-Bbn4HxN2.js → MyTenantsPage-CZRkMbh8.js} +2 -2
  86. package/dist/chunks/{MyTenantsPage-Bbn4HxN2.js.map → MyTenantsPage-CZRkMbh8.js.map} +1 -1
  87. package/dist/chunks/{MyTenantsPage-BHtp67SD.js → MyTenantsPage-V_SwYio2.js} +3 -3
  88. package/dist/chunks/{MyTenantsPage-BHtp67SD.js.map → MyTenantsPage-V_SwYio2.js.map} +1 -1
  89. package/dist/chunks/{MyTicketsPage-BvZeiTXu.js → MyTicketsPage-DOUhaLal.js} +2 -2
  90. package/dist/chunks/{MyTicketsPage-BvZeiTXu.js.map → MyTicketsPage-DOUhaLal.js.map} +1 -1
  91. package/dist/chunks/{MyTicketsPage-D9IGVofj.js → MyTicketsPage-DnvAIeyr.js} +2 -2
  92. package/dist/chunks/{MyTicketsPage-D9IGVofj.js.map → MyTicketsPage-DnvAIeyr.js.map} +1 -1
  93. package/dist/chunks/{NavigationAppsPage-DiPBCsAF.js → NavigationAppsPage-DXvpLsbt.js} +2 -2
  94. package/dist/chunks/{NavigationAppsPage-DiPBCsAF.js.map → NavigationAppsPage-DXvpLsbt.js.map} +1 -1
  95. package/dist/chunks/{NavigationAppsPage-ChtMK1yt.js → NavigationAppsPage-DfTa4jCG.js} +2 -2
  96. package/dist/chunks/{NavigationAppsPage-ChtMK1yt.js.map → NavigationAppsPage-DfTa4jCG.js.map} +1 -1
  97. package/dist/chunks/{NotificationsPage-BxCiGzHk.js → NotificationsPage-D76MdAs-.js} +2 -2
  98. package/dist/chunks/{NotificationsPage-BxCiGzHk.js.map → NotificationsPage-D76MdAs-.js.map} +1 -1
  99. package/dist/chunks/{NotificationsPage-BCnL9oPb.js → NotificationsPage-I1yCk7tk.js} +2 -2
  100. package/dist/chunks/{NotificationsPage-BCnL9oPb.js.map → NotificationsPage-I1yCk7tk.js.map} +1 -1
  101. package/dist/chunks/{OnboardingWizardPage-CV_cxq7k.js → OnboardingWizardPage-BRUzcl1A.js} +2 -2
  102. package/dist/chunks/{OnboardingWizardPage-CV_cxq7k.js.map → OnboardingWizardPage-BRUzcl1A.js.map} +1 -1
  103. package/dist/chunks/{OnboardingWizardPage-Du-tQ2ag.js → OnboardingWizardPage-DtWUPCh3.js} +2 -2
  104. package/dist/chunks/{OnboardingWizardPage-Du-tQ2ag.js.map → OnboardingWizardPage-DtWUPCh3.js.map} +1 -1
  105. package/dist/chunks/{PermissionDetailPage-C1iuWv0G.js → PermissionDetailPage-CUNKbl7t.js} +2 -2
  106. package/dist/chunks/{PermissionDetailPage-C1iuWv0G.js.map → PermissionDetailPage-CUNKbl7t.js.map} +1 -1
  107. package/dist/chunks/{PermissionDetailPage-Ds4Jt1os.js → PermissionDetailPage-DJJGbXoX.js} +2 -2
  108. package/dist/chunks/{PermissionDetailPage-Ds4Jt1os.js.map → PermissionDetailPage-DJJGbXoX.js.map} +1 -1
  109. package/dist/chunks/{PermissionsPage-BGI2nxCn.js → PermissionsPage-B8wmawPV.js} +2 -2
  110. package/dist/chunks/{PermissionsPage-BGI2nxCn.js.map → PermissionsPage-B8wmawPV.js.map} +1 -1
  111. package/dist/chunks/{PermissionsPage-sauv7ct1.js → PermissionsPage-Dbjcctuh.js} +2 -2
  112. package/dist/chunks/{PermissionsPage-sauv7ct1.js.map → PermissionsPage-Dbjcctuh.js.map} +1 -1
  113. package/dist/chunks/{PortalDashboardPage-CQWEcghD.js → PortalDashboardPage-BeNfBZmb.js} +2 -2
  114. package/dist/chunks/{PortalDashboardPage-CQWEcghD.js.map → PortalDashboardPage-BeNfBZmb.js.map} +1 -1
  115. package/dist/chunks/{PortalDashboardPage-2kCbJw9w.js → PortalDashboardPage-zii0ll57.js} +2 -2
  116. package/dist/chunks/{PortalDashboardPage-2kCbJw9w.js.map → PortalDashboardPage-zii0ll57.js.map} +1 -1
  117. package/dist/chunks/{PreferencesPage-Bu4gaDRb.js → PreferencesPage-BCpuIGzv.js} +2 -2
  118. package/dist/chunks/{PreferencesPage-Bu4gaDRb.js.map → PreferencesPage-BCpuIGzv.js.map} +1 -1
  119. package/dist/chunks/{PreferencesPage-Dbg0bEYD.js → PreferencesPage-BmvrBaAD.js} +2 -2
  120. package/dist/chunks/{PreferencesPage-Dbg0bEYD.js.map → PreferencesPage-BmvrBaAD.js.map} +1 -1
  121. package/dist/chunks/{ProfilePage-C5QS7tsh.js → ProfilePage-eowQd59_.js} +2 -2
  122. package/dist/chunks/{ProfilePage-C5QS7tsh.js.map → ProfilePage-eowQd59_.js.map} +1 -1
  123. package/dist/chunks/{ProfilePage-DfiBhOUt.js → ProfilePage-mf5wI0-n.js} +2 -2
  124. package/dist/chunks/{ProfilePage-DfiBhOUt.js.map → ProfilePage-mf5wI0-n.js.map} +1 -1
  125. package/dist/chunks/{ReferencesManagementPage-Bs0mapj8.js → ReferencesManagementPage-8UPgkVE8.js} +3 -3
  126. package/dist/chunks/{ReferencesManagementPage-Bs0mapj8.js.map → ReferencesManagementPage-8UPgkVE8.js.map} +1 -1
  127. package/dist/chunks/{ReferencesManagementPage-C0RgHbJb.js → ReferencesManagementPage-CLsaUNqA.js} +2 -2
  128. package/dist/chunks/{ReferencesManagementPage-C0RgHbJb.js.map → ReferencesManagementPage-CLsaUNqA.js.map} +1 -1
  129. package/dist/chunks/{RegisterPage-DS1chV_A.js → RegisterPage-57X-ILDb.js} +2 -2
  130. package/dist/chunks/{RegisterPage-DS1chV_A.js.map → RegisterPage-57X-ILDb.js.map} +1 -1
  131. package/dist/chunks/{RegisterPage-DoeIiJt0.js → RegisterPage-CNyHSbqs.js} +2 -2
  132. package/dist/chunks/{RegisterPage-DoeIiJt0.js.map → RegisterPage-CNyHSbqs.js.map} +1 -1
  133. package/dist/chunks/{ResetPasswordPage-3KEk3zj5.js → ResetPasswordPage-CyV8l-Zo.js} +2 -2
  134. package/dist/chunks/{ResetPasswordPage-3KEk3zj5.js.map → ResetPasswordPage-CyV8l-Zo.js.map} +1 -1
  135. package/dist/chunks/{ResetPasswordPage-C_VQSFB5.js → ResetPasswordPage-JW8-mh_k.js} +2 -2
  136. package/dist/chunks/{ResetPasswordPage-C_VQSFB5.js.map → ResetPasswordPage-JW8-mh_k.js.map} +1 -1
  137. package/dist/chunks/{ResolutionModal-S6URD--N.js → ResolutionModal-CjwE73NX.js} +2 -2
  138. package/dist/chunks/{ResolutionModal-S6URD--N.js.map → ResolutionModal-CjwE73NX.js.map} +1 -1
  139. package/dist/chunks/{ResolutionModal-BzI1x79r.js → ResolutionModal-wddG59kg.js} +2 -2
  140. package/dist/chunks/{ResolutionModal-BzI1x79r.js.map → ResolutionModal-wddG59kg.js.map} +1 -1
  141. package/dist/chunks/{RoleDetailPage-SXK9cq_3.js → RoleDetailPage-CrioVHFI.js} +3 -3
  142. package/dist/chunks/{RoleDetailPage-SXK9cq_3.js.map → RoleDetailPage-CrioVHFI.js.map} +1 -1
  143. package/dist/chunks/{RoleDetailPage-DvEEWPKr.js → RoleDetailPage-TUOGR1ow.js} +2 -2
  144. package/dist/chunks/{RoleDetailPage-DvEEWPKr.js.map → RoleDetailPage-TUOGR1ow.js.map} +1 -1
  145. package/dist/chunks/{RolesPage-B75lCugt.js → RolesPage-CAcols3D.js} +2 -2
  146. package/dist/chunks/{RolesPage-B75lCugt.js.map → RolesPage-CAcols3D.js.map} +1 -1
  147. package/dist/chunks/{RolesPage-C5gYJxAl.js → RolesPage-sJBWaNff.js} +2 -2
  148. package/dist/chunks/{RolesPage-C5gYJxAl.js.map → RolesPage-sJBWaNff.js.map} +1 -1
  149. package/dist/chunks/{SlaConfigPage-BqXHATb6.js → SlaConfigPage-BPGRloOS.js} +2 -2
  150. package/dist/chunks/{SlaConfigPage-BqXHATb6.js.map → SlaConfigPage-BPGRloOS.js.map} +1 -1
  151. package/dist/chunks/{SlaConfigPage-DZ4P1FFW.js → SlaConfigPage-D5TRn7Ir.js} +2 -2
  152. package/dist/chunks/{SlaConfigPage-DZ4P1FFW.js.map → SlaConfigPage-D5TRn7Ir.js.map} +1 -1
  153. package/dist/chunks/{SupportPermissionsPage-B4xy_pCQ.js → SupportPermissionsPage-Dc2bWTzG.js} +2 -2
  154. package/dist/chunks/{SupportPermissionsPage-B4xy_pCQ.js.map → SupportPermissionsPage-Dc2bWTzG.js.map} +1 -1
  155. package/dist/chunks/{SupportPermissionsPage-DW7KJjYK.js → SupportPermissionsPage-UXmYLrIq.js} +2 -2
  156. package/dist/chunks/{SupportPermissionsPage-DW7KJjYK.js.map → SupportPermissionsPage-UXmYLrIq.js.map} +1 -1
  157. package/dist/chunks/{TemplatesPage-DZa0PQTE.js → TemplatesPage-dmPlqqiD.js} +2 -2
  158. package/dist/chunks/{TemplatesPage-DZa0PQTE.js.map → TemplatesPage-dmPlqqiD.js.map} +1 -1
  159. package/dist/chunks/{TemplatesPage-m5-sLJ7F.js → TemplatesPage-nTY85sNA.js} +2 -2
  160. package/dist/chunks/{TemplatesPage-m5-sLJ7F.js.map → TemplatesPage-nTY85sNA.js.map} +1 -1
  161. package/dist/chunks/{TenantCard-BJQi7Oew.js → TenantCard-BUXfstRZ.js} +2 -2
  162. package/dist/chunks/{TenantCard-BJQi7Oew.js.map → TenantCard-BUXfstRZ.js.map} +1 -1
  163. package/dist/chunks/{TenantCard-CqfifMrM.js → TenantCard-BhT-31ls.js} +2 -2
  164. package/dist/chunks/{TenantCard-CqfifMrM.js.map → TenantCard-BhT-31ls.js.map} +1 -1
  165. package/dist/chunks/{TenantScopeSelector-CdiYJvuH.js → TenantScopeSelector-3_mzBLNI.js} +2 -2
  166. package/dist/chunks/{TenantScopeSelector-CdiYJvuH.js.map → TenantScopeSelector-3_mzBLNI.js.map} +1 -1
  167. package/dist/chunks/{TenantScopeSelector-Cl5DD318.js → TenantScopeSelector-B-SRDR2R.js} +2 -2
  168. package/dist/chunks/{TenantScopeSelector-Cl5DD318.js.map → TenantScopeSelector-B-SRDR2R.js.map} +1 -1
  169. package/dist/chunks/{TicketDetailPage-BOC9rHu3.js → TicketDetailPage-B4cR3rOC.js} +2 -2
  170. package/dist/chunks/{TicketDetailPage-BOC9rHu3.js.map → TicketDetailPage-B4cR3rOC.js.map} +1 -1
  171. package/dist/chunks/{TicketDetailPage-C1UuMxD8.js → TicketDetailPage-xN3wPnFL.js} +2 -2
  172. package/dist/chunks/{TicketDetailPage-C1UuMxD8.js.map → TicketDetailPage-xN3wPnFL.js.map} +1 -1
  173. package/dist/chunks/{TicketsPage-BCgHZA-m.js → TicketsPage-CkHgXSxU.js} +2 -2
  174. package/dist/chunks/{TicketsPage-BCgHZA-m.js.map → TicketsPage-CkHgXSxU.js.map} +1 -1
  175. package/dist/chunks/{TicketsPage-BjaN4Baq.js → TicketsPage-Dwi2xpMI.js} +2 -2
  176. package/dist/chunks/{TicketsPage-BjaN4Baq.js.map → TicketsPage-Dwi2xpMI.js.map} +1 -1
  177. package/dist/chunks/{UserCreateTicketPage-ChQL1mVY.js → UserCreateTicketPage-D2a3EOey.js} +3 -3
  178. package/dist/chunks/UserCreateTicketPage-D2a3EOey.js.map +1 -0
  179. package/dist/chunks/{UserCreateTicketPage-DkjsHeV7.js → UserCreateTicketPage-bcbSLglE.js} +48 -48
  180. package/dist/chunks/UserCreateTicketPage-bcbSLglE.js.map +1 -0
  181. package/dist/chunks/{UserDashboardPage-BMYrtF3o.js → UserDashboardPage-DwnDRNoW.js} +2 -2
  182. package/dist/chunks/{UserDashboardPage-BMYrtF3o.js.map → UserDashboardPage-DwnDRNoW.js.map} +1 -1
  183. package/dist/chunks/{UserDashboardPage-81-3GJAQ.js → UserDashboardPage-ZMsx8LWw.js} +2 -2
  184. package/dist/chunks/{UserDashboardPage-81-3GJAQ.js.map → UserDashboardPage-ZMsx8LWw.js.map} +1 -1
  185. package/dist/chunks/{UserDetailPage-BMW8jAWG.js → UserDetailPage-BRFowOFL.js} +2 -2
  186. package/dist/chunks/{UserDetailPage-BMW8jAWG.js.map → UserDetailPage-BRFowOFL.js.map} +1 -1
  187. package/dist/chunks/{UserDetailPage-D6oCH2eS.js → UserDetailPage-CZyV-zsg.js} +5 -5
  188. package/dist/chunks/{UserDetailPage-D6oCH2eS.js.map → UserDetailPage-CZyV-zsg.js.map} +1 -1
  189. package/dist/chunks/{UserTicketDetailPage-ZH2BDWBt.js → UserTicketDetailPage-BstGk_BP.js} +2 -2
  190. package/dist/chunks/{UserTicketDetailPage-ZH2BDWBt.js.map → UserTicketDetailPage-BstGk_BP.js.map} +1 -1
  191. package/dist/chunks/{UserTicketDetailPage-Z_myXXJ0.js → UserTicketDetailPage-DzB_pELt.js} +2 -2
  192. package/dist/chunks/{UserTicketDetailPage-Z_myXXJ0.js.map → UserTicketDetailPage-DzB_pELt.js.map} +1 -1
  193. package/dist/chunks/{UsersGroupsPage-B8Ka6uRa.js → UsersGroupsPage-BygTv_kK.js} +3 -3
  194. package/dist/chunks/{UsersGroupsPage-B8Ka6uRa.js.map → UsersGroupsPage-BygTv_kK.js.map} +1 -1
  195. package/dist/chunks/{UsersGroupsPage-xJmGib8b.js → UsersGroupsPage-DTmhzttW.js} +2 -2
  196. package/dist/chunks/{UsersGroupsPage-xJmGib8b.js.map → UsersGroupsPage-DTmhzttW.js.map} +1 -1
  197. package/dist/chunks/{UsersPage-CQ38akZ_.js → UsersPage-DcwLyMAX.js} +2 -2
  198. package/dist/chunks/{UsersPage-CQ38akZ_.js.map → UsersPage-DcwLyMAX.js.map} +1 -1
  199. package/dist/chunks/{UsersPage-Bd2-vl39.js → UsersPage-TIqSHgHj.js} +2 -2
  200. package/dist/chunks/{UsersPage-Bd2-vl39.js.map → UsersPage-TIqSHgHj.js.map} +1 -1
  201. package/dist/chunks/{accessRequestsApi-DguOx0q0.js → accessRequestsApi-3FjMFbpa.js} +2 -2
  202. package/dist/chunks/{accessRequestsApi-DguOx0q0.js.map → accessRequestsApi-3FjMFbpa.js.map} +1 -1
  203. package/dist/chunks/{accessRequestsApi-COtWo9kC.js → accessRequestsApi-B6dsJzvH.js} +2 -2
  204. package/dist/chunks/{accessRequestsApi-COtWo9kC.js.map → accessRequestsApi-B6dsJzvH.js.map} +1 -1
  205. package/dist/chunks/{aiApi-CITiWGYX.js → aiApi-9G4wG_mT.js} +2 -2
  206. package/dist/chunks/{aiApi-CITiWGYX.js.map → aiApi-9G4wG_mT.js.map} +1 -1
  207. package/dist/chunks/{aiApi-BmZsud6O.js → aiApi-DXOdsoxr.js} +2 -2
  208. package/dist/chunks/{aiApi-BmZsud6O.js.map → aiApi-DXOdsoxr.js.map} +1 -1
  209. package/dist/chunks/{applicationAnalyticsApi-BYoEJzSN.js → applicationAnalyticsApi-D0DEp9Y-.js} +2 -2
  210. package/dist/chunks/{applicationAnalyticsApi-BYoEJzSN.js.map → applicationAnalyticsApi-D0DEp9Y-.js.map} +1 -1
  211. package/dist/chunks/{applicationAnalyticsApi-D62lc6z4.js → applicationAnalyticsApi-DhOd6idI.js} +2 -2
  212. package/dist/chunks/{applicationAnalyticsApi-D62lc6z4.js.map → applicationAnalyticsApi-DhOd6idI.js.map} +1 -1
  213. package/dist/chunks/auth-Ca2Rn6on.js +2 -0
  214. package/dist/chunks/auth-Ca2Rn6on.js.map +1 -0
  215. package/dist/chunks/auth-ClNTDOqm.js +18 -0
  216. package/dist/chunks/auth-ClNTDOqm.js.map +1 -0
  217. package/dist/chunks/auth-DECnMZjF.js +18 -0
  218. package/dist/chunks/auth-DECnMZjF.js.map +1 -0
  219. package/dist/chunks/auth-DPvxdqy4.js +18 -0
  220. package/dist/chunks/auth-DPvxdqy4.js.map +1 -0
  221. package/dist/chunks/auth-HzvnTaOm.js +2 -0
  222. package/dist/chunks/auth-HzvnTaOm.js.map +1 -0
  223. package/dist/chunks/auth-M6aNTKCH.js +2 -0
  224. package/dist/chunks/auth-M6aNTKCH.js.map +1 -0
  225. package/dist/chunks/auth-UHnAu6_e.js +2 -0
  226. package/dist/chunks/auth-UHnAu6_e.js.map +1 -0
  227. package/dist/chunks/auth-YrujJY7m.js +18 -0
  228. package/dist/chunks/auth-YrujJY7m.js.map +1 -0
  229. package/dist/chunks/{groupsApi-3CR-_g5b.js → groupsApi-Db8G2lLs.js} +2 -2
  230. package/dist/chunks/{groupsApi-3CR-_g5b.js.map → groupsApi-Db8G2lLs.js.map} +1 -1
  231. package/dist/chunks/{groupsApi-BUyBgf_N.js → groupsApi-lbxNsHFv.js} +2 -2
  232. package/dist/chunks/{groupsApi-BUyBgf_N.js.map → groupsApi-lbxNsHFv.js.map} +1 -1
  233. package/dist/chunks/{index-IJR_91Yt.js → index-BI2dc1FS.js} +2 -2
  234. package/dist/chunks/{index-IJR_91Yt.js.map → index-BI2dc1FS.js.map} +1 -1
  235. package/dist/chunks/{index-DIQ6Jmmq.js → index-Bn8HzILk.js} +4 -4
  236. package/dist/chunks/{index-DIQ6Jmmq.js.map → index-Bn8HzILk.js.map} +1 -1
  237. package/dist/chunks/{index-DA5VyW0k.js → index-CN2WRyg1.js} +2249 -2264
  238. package/dist/chunks/index-CN2WRyg1.js.map +1 -0
  239. package/dist/chunks/{index-Br2wsGE8.js → index-CTGSmYvs.js} +2 -2
  240. package/dist/chunks/{index-Br2wsGE8.js.map → index-CTGSmYvs.js.map} +1 -1
  241. package/dist/chunks/index-CUICSveU.js +2 -0
  242. package/dist/chunks/index-CUICSveU.js.map +1 -0
  243. package/dist/chunks/{index-S-X8qFYW.js → index-CgtbaFf5.js} +2 -2
  244. package/dist/chunks/{index-S-X8qFYW.js.map → index-CgtbaFf5.js.map} +1 -1
  245. package/dist/chunks/{index-_g82N2nb.js → index-D0HS542b.js} +2 -2
  246. package/dist/chunks/{index-_g82N2nb.js.map → index-D0HS542b.js.map} +1 -1
  247. package/dist/chunks/{index-BIqcvvbh.js → index-DEtq-xUL.js} +9 -8
  248. package/dist/chunks/index-DEtq-xUL.js.map +1 -0
  249. package/dist/chunks/{index-BOKR3bw6.js → index-DF93KQFR.js} +2 -2
  250. package/dist/chunks/{index-BOKR3bw6.js.map → index-DF93KQFR.js.map} +1 -1
  251. package/dist/chunks/{index-CxgEV-rT.js → index-DLekpNSE.js} +2 -2
  252. package/dist/chunks/{index-CxgEV-rT.js.map → index-DLekpNSE.js.map} +1 -1
  253. package/dist/chunks/{index-DEOBhXS_.js → index-DUS-tunb.js} +2 -2
  254. package/dist/chunks/{index-DEOBhXS_.js.map → index-DUS-tunb.js.map} +1 -1
  255. package/dist/chunks/{index-BMsjMCv9.js → index-DjC1u2hI.js} +3 -3
  256. package/dist/chunks/{index-BMsjMCv9.js.map → index-DjC1u2hI.js.map} +1 -1
  257. package/dist/chunks/{index-BxHVPJ-j.js → index-DqbVFB1H.js} +2 -2
  258. package/dist/chunks/{index-BxHVPJ-j.js.map → index-DqbVFB1H.js.map} +1 -1
  259. package/dist/chunks/{index-Djy4eIbB.js → index-DwqLhQ8S.js} +2 -2
  260. package/dist/chunks/{index-Djy4eIbB.js.map → index-DwqLhQ8S.js.map} +1 -1
  261. package/dist/chunks/{index-C1w97Ejz.js → index-HsAOBno4.js} +2 -2
  262. package/dist/chunks/{index-C1w97Ejz.js.map → index-HsAOBno4.js.map} +1 -1
  263. package/dist/chunks/{index-Czk12A3G.js → index-TiWOcC0g.js} +2 -2
  264. package/dist/chunks/{index-Czk12A3G.js.map → index-TiWOcC0g.js.map} +1 -1
  265. package/dist/chunks/{index-vXiLh35n.js → index-cAikSVW0.js} +13 -13
  266. package/dist/chunks/index-cAikSVW0.js.map +1 -0
  267. package/dist/chunks/{index-CNxx56kE.js → index-xhRXN1Jq.js} +2 -2
  268. package/dist/chunks/{index-CNxx56kE.js.map → index-xhRXN1Jq.js.map} +1 -1
  269. package/dist/chunks/{tenantIconMap-COKA97Ug.js → tenantIconMap-CHeS7oLt.js} +2 -2
  270. package/dist/chunks/{tenantIconMap-COKA97Ug.js.map → tenantIconMap-CHeS7oLt.js.map} +1 -1
  271. package/dist/chunks/{tenantIconMap-BuSQUUyZ.js → tenantIconMap-__FKj6CN.js} +2 -2
  272. package/dist/chunks/{tenantIconMap-BuSQUUyZ.js.map → tenantIconMap-__FKj6CN.js.map} +1 -1
  273. package/dist/chunks/{ticketingApi-DbREwHez.js → ticketingApi-Cj239hYB.js} +2 -2
  274. package/dist/chunks/{ticketingApi-DbREwHez.js.map → ticketingApi-Cj239hYB.js.map} +1 -1
  275. package/dist/chunks/{ticketingApi-C6EbupqP.js → ticketingApi-DF4RwD_6.js} +2 -2
  276. package/dist/chunks/{ticketingApi-C6EbupqP.js.map → ticketingApi-DF4RwD_6.js.map} +1 -1
  277. package/dist/chunks/{useAccessRequests-vucIb3_w.js → useAccessRequests-CFam8zFR.js} +3 -3
  278. package/dist/chunks/{useAccessRequests-vucIb3_w.js.map → useAccessRequests-CFam8zFR.js.map} +1 -1
  279. package/dist/chunks/{useAccessRequests-C0dY6y-4.js → useAccessRequests-CViOUwyF.js} +2 -2
  280. package/dist/chunks/{useAccessRequests-C0dY6y-4.js.map → useAccessRequests-CViOUwyF.js.map} +1 -1
  281. package/dist/chunks/{useUserAccessRequests-BBcw1Rk9.js → useUserAccessRequests-B-Cs6NX1.js} +2 -2
  282. package/dist/chunks/{useUserAccessRequests-BBcw1Rk9.js.map → useUserAccessRequests-B-Cs6NX1.js.map} +1 -1
  283. package/dist/chunks/{useUserAccessRequests-Cj0nkesW.js → useUserAccessRequests-CslSQeBJ.js} +2 -2
  284. package/dist/chunks/{useUserAccessRequests-Cj0nkesW.js.map → useUserAccessRequests-CslSQeBJ.js.map} +1 -1
  285. package/dist/contexts/AuthContext.d.ts.map +1 -1
  286. package/dist/pages/LoginPage.d.ts.map +1 -1
  287. package/dist/pages/platform/administration/tenants/TenantDetailPage.d.ts.map +1 -1
  288. package/dist/pages/platform/support/UserCreateTicketPage.d.ts.map +1 -1
  289. package/dist/services/api/apiClient.d.ts.map +1 -1
  290. package/dist/services/support/ticketDraftService.d.ts.map +1 -1
  291. package/dist/smartstack.cjs +1 -1
  292. package/dist/smartstack.js +6 -6
  293. package/dist/utils/permissions.generated.d.ts +288 -0
  294. package/dist/utils/permissions.generated.d.ts.map +1 -0
  295. package/dist/utils/uuid.d.ts +6 -0
  296. package/dist/utils/uuid.d.ts.map +1 -0
  297. package/package.json +1 -1
  298. package/dist/chunks/UserCreateTicketPage-ChQL1mVY.js.map +0 -1
  299. package/dist/chunks/UserCreateTicketPage-DkjsHeV7.js.map +0 -1
  300. package/dist/chunks/auth-B-hELPDB.js +0 -2
  301. package/dist/chunks/auth-B-hELPDB.js.map +0 -1
  302. package/dist/chunks/auth-BYaMuq7D.js +0 -16
  303. package/dist/chunks/auth-BYaMuq7D.js.map +0 -1
  304. package/dist/chunks/auth-C5zpZ9k7.js +0 -2
  305. package/dist/chunks/auth-C5zpZ9k7.js.map +0 -1
  306. package/dist/chunks/auth-CDpRMVv1.js +0 -16
  307. package/dist/chunks/auth-CDpRMVv1.js.map +0 -1
  308. package/dist/chunks/auth-CyPkCta2.js +0 -2
  309. package/dist/chunks/auth-CyPkCta2.js.map +0 -1
  310. package/dist/chunks/auth-DL47kvnl.js +0 -2
  311. package/dist/chunks/auth-DL47kvnl.js.map +0 -1
  312. package/dist/chunks/auth-Diiv90i1.js +0 -16
  313. package/dist/chunks/auth-Diiv90i1.js.map +0 -1
  314. package/dist/chunks/auth-rog9MvUr.js +0 -16
  315. package/dist/chunks/auth-rog9MvUr.js.map +0 -1
  316. package/dist/chunks/index-BIqcvvbh.js.map +0 -1
  317. package/dist/chunks/index-DA5VyW0k.js.map +0 -1
  318. package/dist/chunks/index-Dht6EQW1.js +0 -2
  319. package/dist/chunks/index-Dht6EQW1.js.map +0 -1
  320. package/dist/chunks/index-vXiLh35n.js.map +0 -1
@@ -1,5 +1,5 @@
1
- "use strict";const e=require("react/jsx-runtime"),n=require("react"),us=require("axios"),ne=require("react-i18next"),Dt=require("i18next"),Ya=require("i18next-browser-languagedetector"),w=require("react-router-dom"),Ja=require("@microsoft/signalr"),l=require("lucide-react"),pr=require("react-error-boundary"),Ft=require("react-dom"),Ts=require("modern-screenshot"),gt=require("react-resizable-panels"),Qa=require("dompurify");function xr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const oe=xr(Ja),xt=xr(l),Qe={none:"0px",small:"4px",medium:"8px",large:"12px",xlarge:"16px",xxlarge:"24px"},Za={none:"Carré",small:"Léger",medium:"Moyen",large:"Arrondi",xlarge:"Très arrondi",xxlarge:"Pill"},_e={slate:{name:"Ardoise",shades:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"}},gray:{name:"Gris",shades:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"}},zinc:{name:"Zinc",shades:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"}},stone:{name:"Pierre",shades:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"}},indigo:{name:"Indigo",shades:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"}},violet:{name:"Violet",shades:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"}},blue:{name:"Bleu",shades:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},cyan:{name:"Cyan",shades:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"}},teal:{name:"Teal",shades:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"}},emerald:{name:"Émeraude",shades:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"}},amber:{name:"Ambre",shades:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"}},orange:{name:"Orange",shades:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"}},rose:{name:"Rose",shades:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},pink:{name:"Pink",shades:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"}}},en={card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},ut={neutral:{name:"Neutre",icon:"⚪",colors:{light:{light:"#ffffff",medium:"#f4f4f5",dark:"#e4e4e7",border:"#d4d4d8"},dark:{light:"#1c1c1f",medium:"#27272a",dark:"#3f3f46",border:"#52525b"}}},ocean:{name:"Océan",icon:"🌊",colors:{light:{light:"#e0f2fe",medium:"#bae6fd",dark:"#7dd3fc",border:"#93c5fd"},dark:{light:"#141c24",medium:"#1a2836",dark:"#2a4a5e",border:"#3a5a70"}}},forest:{name:"Forêt",icon:"🌲",colors:{light:{light:"#d1fae5",medium:"#a7f3d0",dark:"#6ee7b7",border:"#86efac"},dark:{light:"#121d18",medium:"#182a22",dark:"#2a4a3a",border:"#3a5a4a"}}},sunset:{name:"Coucher de soleil",icon:"🌅",colors:{light:{light:"#fef3c7",medium:"#fde68a",dark:"#fbbf24",border:"#fcd34d"},dark:{light:"#1c1810",medium:"#2a2418",dark:"#4a3a24",border:"#5a4a34"}}},lavender:{name:"Lavande",icon:"💜",colors:{light:{light:"#ede9fe",medium:"#ddd6fe",dark:"#c4b5fd",border:"#c4b5fd"},dark:{light:"#1a1820",medium:"#24222e",dark:"#3a3650",border:"#4a4660"}}},rose:{name:"Rose",icon:"🌸",colors:{light:{light:"#fce7f3",medium:"#fbcfe8",dark:"#f9a8d4",border:"#f9a8d4"},dark:{light:"#1c1418",medium:"#2a1e24",dark:"#4a3040",border:"#5a4050"}}}},ms="neutral",mt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Clair",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#fafafa",primary:"#ffffff",secondary:"#f4f4f5",tertiary:"#e4e4e7",card:"#ffffff",hover:"#f4f4f5",active:"#e4e4e7"},text:{primary:"#18181b",secondary:"#52525b",tertiary:"#71717a",muted:"#a1a1aa",inverse:"#fafafa"},border:{default:"#e4e4e7",subtle:"#f4f4f5",strong:"#d4d4d8"},status:{success:{bg:"#f0fdfa",text:"#0f766e",border:"#99f6e4",dot:"#14b8a6"},warning:{bg:"#fffbeb",text:"#b45309",border:"#fde68a",dot:"#f59e0b"},error:{bg:"#fff1f2",text:"#be123c",border:"#fecdd3",dot:"#f43f5e"},info:{bg:"#f0f9ff",text:"#0369a1",border:"#bae6fd",dot:"#0ea5e9"}},accentTransparent:{bg:`${s[50]}`,text:s[700],border:s[200]}}},pt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Sombre",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#161618",primary:"#1c1c1f",secondary:"#232326",tertiary:"#2a2a2e",card:"#1c1c1f",hover:"#27272a",active:"#3f3f46"},text:{primary:"#fafafa",secondary:"#d4d4d8",tertiary:"#a1a1aa",muted:"#71717a",inverse:"#18181b"},border:{default:"#3f3f46",subtle:"#27272a",strong:"#52525b"},status:{success:{bg:"rgba(20, 184, 166, 0.15)",text:"#5eead4",border:"rgba(20, 184, 166, 0.3)",dot:"#14b8a6"},warning:{bg:"rgba(245, 158, 11, 0.15)",text:"#fbbf24",border:"rgba(245, 158, 11, 0.3)",dot:"#f59e0b"},error:{bg:"rgba(244, 63, 94, 0.15)",text:"#fb7185",border:"rgba(244, 63, 94, 0.3)",dot:"#f43f5e"},info:{bg:"rgba(14, 165, 233, 0.15)",text:"#7dd3fc",border:"rgba(14, 165, 233, 0.3)",dot:"#0ea5e9"}},accentTransparent:{bg:`rgba(${Rs(s[500])}, 0.15)`,text:s[300],border:`rgba(${Rs(s[500])}, 0.3)`}}};function Rs(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?`${parseInt(s[1],16)}, ${parseInt(s[2],16)}, ${parseInt(s[3],16)}`:"99, 102, 241"}const yt={mode:"dark",borderRadius:en,colors:{light:mt("indigo"),dark:pt("indigo")},accentColorKey:"indigo",itemPaletteKey:ms},tn=[{id:"default",name:"Par défaut",description:"Style SmartStack classique avec coins arrondis",icon:"✨",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"indigo",itemPaletteKey:"neutral"}},{id:"minimal",name:"Minimal",description:"Style épuré et professionnel",icon:"⚪",config:{borderRadius:{card:"medium",button:"small",badge:"small",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"slate",itemPaletteKey:"neutral"}},{id:"corporate",name:"Corporate",description:"Style sobre pour environnement professionnel",icon:"🏢",config:{borderRadius:{card:"small",button:"small",badge:"medium",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"gray",itemPaletteKey:"neutral"}},{id:"ocean",name:"Océan",description:"Teintes bleues apaisantes",icon:"🌊",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"cyan",itemPaletteKey:"ocean"}},{id:"forest",name:"Forêt",description:"Tons verts naturels",icon:"🌲",config:{borderRadius:{card:"medium",button:"medium",badge:"medium",input:"medium",modal:"large",menuItem:"medium"},accentColorKey:"emerald",itemPaletteKey:"forest"}},{id:"sunset",name:"Coucher de soleil",description:"Couleurs chaudes et accueillantes",icon:"🌅",config:{borderRadius:{card:"large",button:"large",badge:"xxlarge",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"orange",itemPaletteKey:"sunset"}},{id:"lavender",name:"Lavande",description:"Tons violets élégants",icon:"💜",config:{borderRadius:{card:"xlarge",button:"large",badge:"xlarge",input:"large",modal:"xlarge",menuItem:"large"},accentColorKey:"violet",itemPaletteKey:"lavender"}},{id:"rose",name:"Rose",description:"Teintes roses douces",icon:"🌸",config:{borderRadius:{card:"xxlarge",button:"xlarge",badge:"xxlarge",input:"large",modal:"xxlarge",menuItem:"large"},accentColorKey:"pink",itemPaletteKey:"rose"}}],hr="smartstack-theme-config";class Pt extends Error{statusCode;details;constructor(s,r,a){super(s),this.name="AppError",this.statusCode=r,this.details=a}}class ps extends Error{constructor(s="Network error occurred"){super(s),this.name="NetworkError"}}class gr extends Error{code;constructor(s="Authentication required",r){super(s),this.name="AuthenticationError",this.code=r}}class sn extends Error{constructor(s="Access denied"){super(s),this.name="ForbiddenError"}}const rn=10;class an{queue=[];recentErrors=[];isProcessing=!1;batchSize=10;batchDelay=2e3;async logError(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const d=String(a.url),u=a.status?` [${a.status}]`:"";c=`${o}${u} - ${d}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Error",metadata:a};this.storeRecentError(i),this.queue.push({type:"error",data:i}),this.processQueue()}async logCritical(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const u=String(a.url),m=a.status?` [${a.status}]`:"";c=`${o}${m} - ${u}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Critical",metadata:a};return this.storeRecentError(i),await this.sendErrorWithResponse(i)}getRecentErrors(){return[...this.recentErrors]}clearRecentErrors(){this.recentErrors=[]}storeRecentError(s){this.recentErrors.unshift({...s,timestamp:new Date}),this.recentErrors.length>rn&&this.recentErrors.pop()}async logEvent(s,r,a){const o={event:s,category:r,data:a};this.queue.push({type:"event",data:o}),this.processQueue()}async processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0,await new Promise(r=>setTimeout(r,this.batchDelay));const s=this.queue.splice(0,this.batchSize);for(const r of s)try{r.type==="error"?await this.sendError(r.data):await this.sendEvent(r.data)}catch{}this.isProcessing=!1,this.queue.length>0&&this.processQueue()}async sendError(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}async sendErrorWithResponse(s){const r=localStorage.getItem("token");try{const a=await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)});return a.ok&&a.status===200&&(await a.json()).ticketNumber||null}catch{return null}}async sendEvent(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-event",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}}const Te=new an;window.onerror=(t,s,r,a,o)=>{Te.logError(o||String(t),"window.onerror",{source:s,lineno:r,colno:a})};window.onunhandledrejection=t=>{Te.logError(t.reason instanceof Error?t.reason:String(t.reason),"unhandledrejection")};const Se=us.create({timeout:3e4,headers:{"Content-Type":"application/json"}});Se.interceptors.request.use(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`);const r=crypto.randomUUID();t.headers&&(t.headers["X-Correlation-ID"]=r);const a=localStorage.getItem("i18nextLng")||navigator.language||"fr";t.headers&&(t.headers["Accept-Language"]=a);const o=localStorage.getItem("currentTenantSlug");return o&&t.headers&&!t.headers["X-Tenant-Slug"]&&(t.headers["X-Tenant-Slug"]=o),t},t=>(Te.logError(t,"apiClient.request"),Promise.reject(t)));Se.interceptors.response.use(t=>t,async t=>{const s=t.config?.headers?.["X-Correlation-ID"];if(us.isCancel(t)||t.code==="ERR_CANCELED")return Promise.reject(t);if(!t.response){const i=new ps("Impossible de se connecter au serveur. Vérifiez votre connexion internet.");return Te.logError(i,"apiClient.response",{correlationId:s}),Promise.reject(i)}const{status:r,data:a}=t.response,o=a?.message||a?.detail||a?.title||t.message,c=a?.code;switch(r){case 401:{const i=new gr(o,c);Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,code:c});const d=t.config?.url||"",m=["/api/user/preferences","/api/auth/session-info","/api/auth/refresh","/api/navigation/menu","/api/navigation/favorites","/api/navigation/contexts","/api/onboarding/status","/api/administration/tenants/tenant-analytics/track/"].some(p=>d.startsWith(p));if(!window.location.pathname.includes("/login")&&!m){localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user");const g=c==="SESSION_EXPIRED"?"/login?reason=session_expired":"/login";window.location.href=g}return Promise.reject(i)}case 403:{const i=new sn(o),d=["/api/administration/tenants/tenant-analytics/track/","/api/support/notifications"],u=t.config?.url||"";return d.some(p=>u.startsWith(p))||Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,method:t.config?.method}),Promise.reject(i)}case 404:return Promise.reject(new Pt(o||"Resource not found",r));case 400:return Promise.reject(new Pt(o||"Invalid request",r,a?.details||a?.errors));case 500:case 502:case 503:case 504:{const i=new Pt(o||"Server error",r);return Te.logCritical(i,"apiClient.response",{correlationId:s,url:t.config?.url,status:r}),Promise.reject(i)}default:{const i=new Pt(o,r,a?.details);return Te.logError(i,"apiClient.response",{correlationId:s,status:r}),Promise.reject(i)}}});const E={get:(t,s)=>Se.get(t,s).then(r=>r.data),post:(t,s,r)=>Se.post(t,s,r).then(a=>a.data),put:(t,s,r)=>Se.put(t,s,r).then(a=>a.data),patch:(t,s,r)=>Se.patch(t,s,r).then(a=>a.data),delete:(t,s)=>Se.delete(t,s).then(r=>r.data)},_t={preferences:{get:()=>E.get("/api/user/preferences"),updateTheme:t=>E.put("/api/user/preferences/theme",t),updateLanguage:t=>E.put("/api/user/preferences/language",t),updateNotifications:t=>E.put("/api/user/preferences/notifications",t)},dashboard:{getAll:(t=30,s=10)=>E.get(`/api/user/dashboard/all?period=${t}&errorLimit=${s}`),getSessionAnalytics:(t=30)=>E.get(`/api/user/dashboard/session-analytics?period=${t}`),getLoginErrors:(t=10)=>E.get(`/api/user/dashboard/login-errors?limit=${t}`),getCurrentSession:()=>E.get("/api/user/dashboard/current-session"),getDeviceStats:()=>E.get("/api/user/dashboard/device-stats"),getWeeklyStats:(t=30)=>E.get(`/api/user/dashboard/weekly-stats?period=${t}`),getHourlyStats:(t=30)=>E.get(`/api/user/dashboard/hourly-stats?period=${t}`),getApplicationUsage:(t=30)=>E.get(`/api/user/dashboard/application-usage?period=${t}`)}},nn=t=>({get:(s,r)=>Se.get(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data),post:(s,r,a)=>Se.post(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),put:(s,r,a)=>Se.put(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),patch:(s,r,a)=>Se.patch(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),delete:(s,r)=>Se.delete(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data)}),on={PasswordResetMalfunction:1,FalsePositive:2,UrgentBusinessNeed:3,TechnicalSystemError:4,SupportTicketVerified:5},ln=t=>({getAll:s=>t.get("/api/administration/users",{params:s}),getById:s=>t.get(`/api/administration/users/${s}`),create:s=>t.post("/api/administration/users",s),update:(s,r)=>t.put(`/api/administration/users/${s}`,r),sendPasswordResetLink:s=>t.post(`/api/administration/users/${s}/send-password-reset`),resetPasswordDirect:(s,r)=>t.post(`/api/administration/users/${s}/reset-password-direct`,r?{temporaryPassword:r}:{}),activate:s=>t.patch(`/api/administration/users/${s}/activate`),deactivate:s=>t.patch(`/api/administration/users/${s}/deactivate`),unlock:(s,r)=>t.post(`/api/administration/users/${s}/unlock`,r),clearFailedAttempts:s=>t.post(`/api/administration/users/${s}/clear-failed-attempts`),delete:s=>t.delete(`/api/administration/users/${s}`),getSessions:s=>t.get(`/api/administration/users/${s}/sessions`),endAllSessions:s=>t.post(`/api/administration/users/${s}/sessions/end-all`),endSession:(s,r)=>t.delete(`/api/administration/users/${s}/sessions/${r}`),getActivity:s=>t.get(`/api/administration/users/${s}/activity`),getCustomRole:s=>t.get(`/api/administration/users/${s}/custom-role`),createCustomRole:s=>t.post(`/api/administration/users/${s}/custom-role`),deleteCustomRole:s=>t.delete(`/api/administration/users/${s}/custom-role`),getHistory:(s,r=50)=>t.get(`/api/administration/users/${s}/history`,{params:{limit:r}}),restoreFromHistory:(s,r)=>t.post(`/api/administration/users/${s}/history/${r}/restore`),getOrganizationReferences:()=>t.get("/api/administration/users/organization-references"),references:{getCompanies:s=>t.get("/api/administration/users/references/companies",{params:s}),getDepartments:s=>t.get("/api/administration/users/references/departments",{params:s}),getJobTitles:s=>t.get("/api/administration/users/references/job-titles",{params:s}),getOffices:s=>t.get("/api/administration/users/references/offices",{params:s}),createCompany:(s,r)=>t.post(`/api/administration/users/references/companies${r?`?tenantId=${r}`:""}`,s),createDepartment:(s,r)=>t.post(`/api/administration/users/references/departments${r?`?tenantId=${r}`:""}`,s),createJobTitle:(s,r)=>t.post(`/api/administration/users/references/job-titles${r?`?tenantId=${r}`:""}`,s),createOffice:(s,r)=>t.post(`/api/administration/users/references/offices${r?`?tenantId=${r}`:""}`,s),updateCompany:(s,r)=>t.put(`/api/administration/users/references/companies/${s}`,r),updateDepartment:(s,r)=>t.put(`/api/administration/users/references/departments/${s}`,r),updateJobTitle:(s,r)=>t.put(`/api/administration/users/references/job-titles/${s}`,r),updateOffice:(s,r)=>t.put(`/api/administration/users/references/offices/${s}`,r),activateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/activate`),activateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/activate`),activateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/activate`),activateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/activate`),deactivateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/deactivate`),deactivateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/deactivate`),deactivateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/deactivate`),deactivateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/deactivate`),deleteCompany:s=>t.delete(`/api/administration/users/references/companies/${s}`),deleteDepartment:s=>t.delete(`/api/administration/users/references/departments/${s}`),deleteJobTitle:s=>t.delete(`/api/administration/users/references/job-titles/${s}`),deleteOffice:s=>t.delete(`/api/administration/users/references/offices/${s}`)},updateProfile:(s,r)=>t.put(`/api/administration/users/${s}/profile`,r),updateOrganization:(s,r)=>t.put(`/api/administration/users/${s}/organization`,r),updateJobInfo:(s,r)=>t.put(`/api/administration/users/${s}/job-info`,r),updatePhones:(s,r)=>t.put(`/api/administration/users/${s}/phones`,r),updateAddress:(s,r)=>t.put(`/api/administration/users/${s}/address`,r),updateContact:(s,r)=>t.put(`/api/administration/users/${s}/contact`,r),getTenants:s=>t.get(`/api/administration/users/${s}/tenants`),getGroups:s=>t.get(`/api/administration/users/${s}/groups`),getConsolidatedRoles:(s,r)=>{const a=r?`/api/administration/users/${s}/consolidated-roles?tenantId=${r}`:`/api/administration/users/${s}/consolidated-roles`;return t.get(a)},getApplicationAccess:(s,r)=>{const a=r?`/api/administration/users/${s}/application-access?tenantId=${r}`:`/api/administration/users/${s}/application-access`;return t.get(a)}}),cn=ln,dn=t=>({getAll:s=>t.get("/api/administration/permissions/roles",{params:s}),getAssignable:()=>t.get("/api/administration/permissions/roles",{params:{excludeCategories:"Custom",minPermissionsCount:1}}),getServiceAssignable:()=>t.get("/api/administration/permissions/roles",{params:{forExternalApps:!0,minPermissionsCount:1}}),getByApplication:s=>t.get("/api/administration/permissions/roles",{params:{applicationId:s,excludeCategories:"Custom",minPermissionsCount:1}}),getById:s=>t.get(`/api/administration/permissions/roles/${s}`),create:s=>t.post("/api/administration/permissions/roles",s),update:(s,r)=>t.put(`/api/administration/permissions/roles/${s}`,r),delete:s=>t.delete(`/api/administration/permissions/roles/${s}`),assignUser:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/users/${r}`),removeUser:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/users/${r}`),getGroups:s=>t.get(`/api/administration/permissions/roles/${s}/groups`),assignGroup:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/groups/${r}`),removeGroup:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/groups/${r}`),getTranslations:s=>t.get(`/api/administration/permissions/roles/${s}/translations`),upsertTranslation:(s,r,a)=>t.put(`/api/administration/permissions/roles/${s}/translations/${r}`,a),deleteTranslation:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/translations/${r}`)}),un=dn,mn=t=>({getAll:s=>t.get("/api/administration/permissions",{params:s}),getById:s=>t.get(`/api/administration/permissions/${s}`),getTree:()=>t.get("/api/administration/permissions/tree"),getMatrix:()=>t.get("/api/administration/permissions/matrix"),delete:s=>t.delete(`/api/administration/permissions/${s}`)}),pn=mn,xn=t=>({getAll:s=>t.get("/api/administration/applications",{params:s}),getById:s=>t.get(`/api/administration/applications/${s}`),update:(s,r)=>t.put(`/api/administration/applications/${s}`,r),activate:s=>t.patch(`/api/administration/applications/${s}/activate`),deactivate:s=>t.patch(`/api/administration/applications/${s}/deactivate`),getModules:s=>t.get(`/api/administration/applications/${s}/modules`),updateModule:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}`,a),getModuleSections:(s,r)=>t.get(`/api/administration/applications/${s}/modules/${r}/sections`),reorderModules:(s,r)=>t.put(`/api/administration/applications/${s}/modules/reorder`,{items:r}),reorderSections:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}/sections/reorder`,{items:a}),getTenants:s=>t.get(`/api/administration/applications/${s}/tenants`),getAvailableTenants:s=>t.get(`/api/administration/applications/${s}/tenants/available`),assignToTenant:(s,r,a)=>t.post(`/api/administration/applications/${s}/tenants/${r}`,a?{accessLevel:a}:{}),removeFromTenant:(s,r)=>t.delete(`/api/administration/applications/${s}/tenants/${r}`),updateTenantAccessLevel:(s,r,a)=>t.patch(`/api/administration/applications/${s}/tenants/${r}/access-level`,{accessLevel:a}),bulkAssignTenants:(s,r)=>t.post(`/api/administration/applications/${s}/tenants/bulk`,r)}),hn=xn,gn=t=>({getOverview:(s=30,r)=>t.get("/api/administration/users/dashboard/overview",{params:{days:s},signal:r?.signal}),getByStatus:s=>t.get("/api/administration/users/dashboard/by-status",{signal:s?.signal}),getByRole:s=>t.get("/api/administration/users/dashboard/by-role",{signal:s?.signal}),getByType:s=>t.get("/api/administration/users/dashboard/by-type",{signal:s?.signal}),getLoginActivity:(s=30,r)=>t.get("/api/administration/users/dashboard/login-activity",{params:{days:s},signal:r?.signal}),getTrends:(s=30,r)=>t.get("/api/administration/users/dashboard/trends",{params:{days:s},signal:r?.signal}),getRecentUsers:(s=10,r)=>t.get("/api/administration/users/dashboard/recent-users",{params:{limit:s},signal:r?.signal}),getSecurityAlerts:(s=3,r=24,a)=>t.get("/api/administration/users/dashboard/security-alerts",{params:{threshold:s,hours:r},signal:a?.signal}),getActiveSessions:s=>t.get("/api/administration/users/dashboard/active-sessions",{signal:s?.signal}),getLatestActiveSessions:(s=5,r)=>t.get("/api/administration/users/dashboard/latest-active-sessions",{params:{limit:s},signal:r?.signal})}),fn=gn,bn=t=>({getAll:()=>t.get("/api/administration/configuration/settings"),getByCategory:s=>t.get(`/api/administration/configuration/settings/${s}`),get:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}`),update:(s,r,a)=>t.put(`/api/administration/configuration/settings/${s}/${r}`,{value:a}),reset:(s,r)=>t.post(`/api/administration/configuration/settings/${s}/${r}/reset`),getHistory:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}/history`),getCategories:()=>t.get("/api/administration/configuration/settings/categories")}),vn=bn,yn=t=>({get:()=>t.get("/api/user/preferences"),getGlobal:()=>t.get("/api/user/preferences/global"),getForTenant:s=>t.get(`/api/user/preferences/for-tenant/${s}`),getThemeOverrides:()=>t.get("/api/user/preferences/theme-overrides"),deleteTenantOverride:()=>t.delete("/api/user/preferences/tenant-override"),applyToTenant:()=>t.post("/api/user/preferences/apply-to-tenant")}),jn=yn,Nn=t=>({getConfig:()=>t.get("/api/administration/tenants/config"),getAll:s=>{const{excludeTypes:r,...a}=s||{},o=new URLSearchParams;a.page&&o.set("page",String(a.page)),a.pageSize&&o.set("pageSize",String(a.pageSize)),a.search&&o.set("search",a.search),a.status&&o.set("status",a.status),a.type&&o.set("type",a.type),a.sortBy&&o.set("sortBy",a.sortBy),a.sortDesc&&o.set("sortDesc","true"),r?.length&&r.forEach(i=>o.append("excludeTypes",i));const c=o.toString();return t.get(`/api/administration/tenants${c?`?${c}`:""}`)},getById:s=>t.get(`/api/administration/tenants/${s}`),createB2C:s=>t.post("/api/administration/tenants/b2c",s),createB2B:s=>t.post("/api/administration/tenants/b2b",s),update:(s,r)=>t.put(`/api/administration/tenants/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/${s}`),activate:s=>t.post(`/api/administration/tenants/${s}/activate`),suspend:s=>t.post(`/api/administration/tenants/${s}/suspend`),archive:s=>t.delete(`/api/administration/tenants/${s}`),checkSlugAvailable:s=>t.get(`/api/administration/tenants/check-slug/${s}`),assignTemplate:(s,r)=>t.post(`/api/administration/tenants/${s}/template`,{templateId:r}),removeTemplate:s=>t.delete(`/api/administration/tenants/${s}/template`),getMembers:s=>t.get(`/api/administration/tenants/${s}/members`),getMember:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}`),addMember:(s,r)=>t.post(`/api/administration/tenants/${s}/members`,r),removeMember:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}`),setMemberDefault:(s,r)=>t.patch(`/api/administration/tenants/${s}/members/${r}/set-default`),transferOwnership:(s,r)=>t.post(`/api/administration/tenants/${s}/members/transfer-ownership`,{toUserId:r}),assignRole:(s,r,a)=>t.post(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),removeRole:(s,r,a)=>t.delete(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),assignMemberRoles:(s,r,a)=>t.put(`/api/administration/tenants/${s}/members/${r}/roles`,{roleIds:a}),getMemberCustomRole:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}/custom-role`),createMemberCustomRole:(s,r)=>t.post(`/api/administration/tenants/${s}/members/${r}/custom-role`),deleteMemberCustomRole:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}/custom-role`),getTenantRoles:s=>t.get(`/api/administration/tenants/${s}/roles`),getGroups:s=>t.get(`/api/administration/tenants/${s}/groups`),getAvailableGroups:s=>t.get(`/api/administration/tenants/${s}/groups/available`),addGroupToTenant:(s,r)=>t.post(`/api/administration/tenants/${s}/groups`,{groupId:r}),removeGroupFromTenant:(s,r)=>t.delete(`/api/administration/tenants/${s}/groups/${r}`),getApplications:s=>t.get(`/api/administration/tenants/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/${s}/applications/available`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/bulk`,r),toggleApplication:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/toggle`,{isActive:a}),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/access-level`,{accessLevel:a}),getEffectiveTree:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/effective-tree`),saveOverrides:(s,r,a)=>t.put(`/api/administration/tenants/${s}/applications/${r}/overrides`,a),getModules:s=>t.get(`/api/administration/tenants/${s}/modules`),getAvailableModules:s=>t.get(`/api/administration/tenants/${s}/modules/available`),assignModule:(s,r)=>t.post(`/api/administration/tenants/${s}/modules/${r}`),removeModule:(s,r)=>t.delete(`/api/administration/tenants/${s}/modules/${r}`),toggleModule:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/modules/${r}/toggle`,{isActive:a}),getSections:s=>t.get(`/api/administration/tenants/${s}/sections`),getAvailableSections:s=>t.get(`/api/administration/tenants/${s}/sections/available`),assignSection:(s,r)=>t.post(`/api/administration/tenants/${s}/sections/${r}`),removeSection:(s,r)=>t.delete(`/api/administration/tenants/${s}/sections/${r}`),toggleSection:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/sections/${r}/toggle`,{isActive:a}),getModulesWithSections:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/modules-tree`),linkOrganisation:(s,r)=>t.post(`/api/administration/tenants/${s}/organisation`,{organisationId:r}),unlinkOrganisation:s=>t.delete(`/api/administration/tenants/${s}/organisation`)}),wn=Nn,Sn=t=>({getAll:()=>t.get("/api/administration/tenants/templates"),getById:s=>t.get(`/api/administration/tenants/templates/${s}`),create:s=>t.post("/api/administration/tenants/templates",s),update:(s,r)=>t.put(`/api/administration/tenants/templates/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/templates/${s}`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/bulk`,r),getTenants:s=>t.get(`/api/administration/tenants/templates/${s}/tenants`),getApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications/available`),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/templates/${s}/applications/${r}/access-level`,{accessLevel:a}),getApplicationModules:(s,r)=>t.get(`/api/administration/tenants/templates/${s}/applications/${r}/modules`),updateApplicationModules:(s,r,a)=>t.put(`/api/administration/tenants/templates/${s}/applications/${r}/modules`,a),getAiInstances:s=>t.get(`/api/administration/tenants/templates/${s}/ai-instances`),assignAiInstance:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/ai-instances/${r}`),removeAiInstance:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/ai-instances/${r}`)}),Cn=Sn,kn=t=>({getAll:s=>t.get("/api/administration/tenants/organisations",{params:s}),getAvailable:s=>t.get("/api/administration/tenants/organisations/available",{params:s?{search:s}:void 0}),getPendingVerification:()=>t.get("/api/administration/tenants/organisations/pending-verification"),getById:s=>t.get(`/api/administration/tenants/organisations/${s}`),findById:async s=>{const r=await Se.get(`/api/administration/tenants/organisations/${s}`,{validateStatus:a=>a===200||a===404});return r.status===200?r.data:null},create:s=>t.post("/api/administration/tenants/organisations",s),updateContact:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/contact`,r),updateAddress:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/address`,r),verify:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/verify`,{notes:r}),reject:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/reject`,{reason:r}),lookup:(s,r)=>t.get("/api/administration/tenants/organisations/lookup",{params:{countryCode:s,identifier:r}})}),An=kn,Pn=t=>({getAll:s=>t.get("/api/administration/tenants/my",{params:s?{search:s}:void 0}),getDefault:()=>t.get("/api/administration/tenants/my/default"),setDefault:s=>t.post(`/api/administration/tenants/${s}/set-default`),clearDefault:()=>t.delete("/api/administration/tenants/clear-default"),getFavorites:()=>t.get("/api/user/preferences/tenant-favorites"),addFavorite:s=>t.post(`/api/user/preferences/tenant-favorites/${s}`),removeFavorite:s=>t.delete(`/api/user/preferences/tenant-favorites/${s}`),recordRecent:s=>t.post(`/api/user/preferences/tenant-recent/${s}`)}),Tn=Pn,Rn=t=>({getAll:s=>t.get("/api/accounts",{params:s}),getById:s=>t.get(`/api/accounts/${s}`),create:s=>t.post("/api/accounts",s),update:(s,r)=>t.put(`/api/accounts/${s}`,r),delete:s=>t.delete(`/api/accounts/${s}`),activate:s=>t.patch(`/api/accounts/${s}/activate`),deactivate:s=>t.patch(`/api/accounts/${s}/deactivate`),rotateSecret:(s,r="Primary")=>t.post(`/api/accounts/${s}/rotate-secret?keySlot=${r}`),revokeSecondarySecret:s=>t.delete(`/api/accounts/${s}/secondary-secret`),assignRole:(s,r)=>t.post(`/api/accounts/${s}/roles`,r),removeRole:(s,r,a)=>t.delete(`/api/accounts/${s}/roles/${r}`,{params:a?{tenantId:a}:void 0}),generateSecret:()=>t.post("/api/accounts/generate-secret"),getAuditLogs:(s,r=1,a=20)=>t.get(`/api/accounts/${s}/audit-logs`,{params:{page:r,pageSize:a}}),getUsageStats:(s,r=30)=>t.get(`/api/accounts/${s}/usage-stats`,{params:{days:r}}),getKeyUsage:s=>t.get(`/api/accounts/${s}/key-usage`),getApiEndpoints:()=>t.get("/api/accounts/api-endpoints"),getAppApiAccess:s=>t.get(`/api/accounts/${s}/api-access`),updateApiAccess:(s,r,a)=>t.put(`/api/accounts/${s}/api-access/${r}`,a),removeApiAccess:(s,r)=>t.delete(`/api/accounts/${s}/api-access/${r}`)}),En=Rn,In=t=>({getNavigationLookup:()=>t.get("/api/apis/navigation-lookup")}),Ln=In,fr=t=>{const s=t?nn(t):E;return{users:cn(s),roles:un(s),permissions:pn(s),applications:hn(s),dashboard:fn(s),settings:vn(s),tenants:wn(s),templates:Cn(s),organisations:An(s),myTenants:Tn(s),preferences:jn(s),externalApps:En(s),apiCatalog:Ln(s)}},Ne=fr(),ge=(t,s,r)=>{const a=t[s];return a?typeof a=="function"?a():Promise.resolve(a):new Promise((o,c)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(c.bind(null,new Error("Unknown variable dynamic import: "+s+(s.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ss=async t=>{if(!t)return null;try{const[s,r,a,o,c,i,d,u,m,p,g,f,b,h,y,x,j,v,S,N,I,P,k,A,R,$,q,C,D,Y,T,z,Z,H]=await Promise.all([ge(Object.assign({"./locales/de/common.json":()=>Promise.resolve().then(()=>require("./common-BZM8Gf-R.js")),"./locales/en/common.json":()=>Promise.resolve().then(()=>require("./common-Daanch0E.js")),"./locales/fr/common.json":()=>Promise.resolve().then(()=>require("./common-lhAPHx3v.js")),"./locales/it/common.json":()=>Promise.resolve().then(()=>require("./common-B4gIg-Uo.js"))}),`./locales/${t}/common.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-D8yOGHza.js")),"./locales/en/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-rEtU7BPw.js")),"./locales/fr/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BI8iMTJl.js")),"./locales/it/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BTkWh95c.js"))}),`./locales/${t}/navigation.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/auth.json":()=>Promise.resolve().then(()=>require("./auth-C5zpZ9k7.js")),"./locales/en/auth.json":()=>Promise.resolve().then(()=>require("./auth-DL47kvnl.js")),"./locales/fr/auth.json":()=>Promise.resolve().then(()=>require("./auth-B-hELPDB.js")),"./locales/it/auth.json":()=>Promise.resolve().then(()=>require("./auth-CyPkCta2.js"))}),`./locales/${t}/auth.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/admin.json":()=>Promise.resolve().then(()=>require("./admin-C2-UJ8bz.js")),"./locales/en/admin.json":()=>Promise.resolve().then(()=>require("./admin-BqA1PapA.js")),"./locales/fr/admin.json":()=>Promise.resolve().then(()=>require("./admin-CthTD2ui.js")),"./locales/it/admin.json":()=>Promise.resolve().then(()=>require("./admin-vLYwBGRd.js"))}),`./locales/${t}/admin.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/support.json":()=>Promise.resolve().then(()=>require("./support-BU6GoEbW.js")),"./locales/en/support.json":()=>Promise.resolve().then(()=>require("./support-DnSiwJx7.js")),"./locales/fr/support.json":()=>Promise.resolve().then(()=>require("./support-B0kcB-tL.js")),"./locales/it/support.json":()=>Promise.resolve().then(()=>require("./support-Cm84X3pP.js"))}),`./locales/${t}/support.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs.json":()=>Promise.resolve().then(()=>require("./docs-sqOeJ3Lg.js")),"./locales/en/docs.json":()=>Promise.resolve().then(()=>require("./docs-BR4q7sou.js")),"./locales/fr/docs.json":()=>Promise.resolve().then(()=>require("./docs-CDz8QplV.js")),"./locales/it/docs.json":()=>Promise.resolve().then(()=>require("./docs-DCOsvfv7.js"))}),`./locales/${t}/docs.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/ai.json":()=>Promise.resolve().then(()=>require("./ai-BGanmkGz.js")),"./locales/en/ai.json":()=>Promise.resolve().then(()=>require("./ai-CnWgG5hN.js")),"./locales/fr/ai.json":()=>Promise.resolve().then(()=>require("./ai-wRnnMW5a.js")),"./locales/it/ai.json":()=>Promise.resolve().then(()=>require("./ai-Cgn4sP2c.js"))}),`./locales/${t}/ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/communications.json":()=>Promise.resolve().then(()=>require("./communications-DBbKXpf1.js")),"./locales/en/communications.json":()=>Promise.resolve().then(()=>require("./communications-BPsS3Vfm.js")),"./locales/fr/communications.json":()=>Promise.resolve().then(()=>require("./communications-DElJaoVw.js")),"./locales/it/communications.json":()=>Promise.resolve().then(()=>require("./communications-BKaku0MU.js"))}),`./locales/${t}/communications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/entra.json":()=>Promise.resolve().then(()=>require("./entra-BadKCc7Y.js")),"./locales/en/entra.json":()=>Promise.resolve().then(()=>require("./entra-CfLYpxKq.js")),"./locales/fr/entra.json":()=>Promise.resolve().then(()=>require("./entra-Bc0Dwf7d.js")),"./locales/it/entra.json":()=>Promise.resolve().then(()=>require("./entra-DDgx1JoT.js"))}),`./locales/${t}/entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/structure.json":()=>Promise.resolve().then(()=>require("./structure-BL5cd83u.js")),"./locales/fr/structure.json":()=>Promise.resolve().then(()=>require("./structure-BblXL_QG.js"))}),`./locales/${t}/structure.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-DLJ9mTYQ.js")),"./locales/en/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-pkUX3R0G.js")),"./locales/fr/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-Di_IL1wh.js")),"./locales/it/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-B65OLntJ.js"))}),`./locales/${t}/preferences.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/groups.json":()=>Promise.resolve().then(()=>require("./groups-DGDNx8Hf.js")),"./locales/en/groups.json":()=>Promise.resolve().then(()=>require("./groups-5uqhFMN4.js")),"./locales/fr/groups.json":()=>Promise.resolve().then(()=>require("./groups-Cp2Q-pWt.js")),"./locales/it/groups.json":()=>Promise.resolve().then(()=>require("./groups-cV3gnMYo.js"))}),`./locales/${t}/groups.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/ba.json":()=>Promise.resolve().then(()=>require("./ba-9HglDm-t.js")),"./locales/fr/ba.json":()=>Promise.resolve().then(()=>require("./ba-CXlHUyjN.js"))}),`./locales/${t}/ba.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-CsRMxznf.js")),"./locales/en/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-BUnDEWjL.js")),"./locales/fr/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-DRITa5fK.js")),"./locales/it/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-qLwE7c_z.js"))}),`./locales/${t}/docs-administration-users.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BHJfnRA-.js")),"./locales/en/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-CXsWrgCA.js")),"./locales/fr/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BLmrJB-I.js")),"./locales/it/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BmiGStz4.js"))}),`./locales/${t}/docs-administration-permissions.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-Cmjpaxwy.js")),"./locales/en/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CvYnhoo5.js")),"./locales/fr/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-xhQOAORE.js")),"./locales/it/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CuHqwklv.js"))}),`./locales/${t}/docs-administration-tenants.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-CPqGrO8q.js")),"./locales/en/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-EVzVu3kS.js")),"./locales/fr/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-B0zkD6zQ.js")),"./locales/it/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-DngqfS6k.js"))}),`./locales/${t}/docs-administration-ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DRw16ooP.js")),"./locales/en/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-Da6XQxlv.js")),"./locales/fr/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-CofvuK9f.js")),"./locales/it/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DW4kFs3z.js"))}),`./locales/${t}/docs-administration-workflows.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D3hQEI3V.js")),"./locales/en/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-griadux5.js")),"./locales/fr/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-BbS4ZUu7.js")),"./locales/it/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D0KuJ7Ps.js"))}),`./locales/${t}/docs-administration-entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-C6VsiHxH.js")),"./locales/en/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-DRYyRp3S.js")),"./locales/fr/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BEepPuXf.js")),"./locales/it/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BiZBTxgS.js"))}),`./locales/${t}/docs-administration-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-BdZl4hL4.js")),"./locales/en/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-DvZxFmnH.js")),"./locales/fr/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-CXro3iiT.js")),"./locales/it/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-B1YtxR_A.js"))}),`./locales/${t}/docs-administration-configuration.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-DSMqi4PQ.js")),"./locales/en/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-C3rm7u1h.js")),"./locales/fr/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-CJsMRPaR.js")),"./locales/it/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-_LdQyRjT.js"))}),`./locales/${t}/docs-administration-configuration-license.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-HRqVNkqP.js")),"./locales/en/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-XQ-IiS31.js")),"./locales/fr/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-B3IDsztG.js")),"./locales/it/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-DKbpQgBH.js"))}),`./locales/${t}/docs-administration-tenants-template.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-BtAQiVRM.js")),"./locales/en/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-Cs4N4jrq.js")),"./locales/fr/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-XRmC4aRE.js")),"./locales/it/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-D1T8STQX.js"))}),`./locales/${t}/docs-administration-tenants-business.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DHGVmv0D.js")),"./locales/en/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-Bk0D7emY.js")),"./locales/fr/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DSnrN4MO.js")),"./locales/it/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-KFjQQGdW.js"))}),`./locales/${t}/docs-administration-tenants-personal.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-B5w2xFPJ.js")),"./locales/en/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-Dh2ohplZ.js")),"./locales/fr/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-WV4RsrVj.js")),"./locales/it/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-DeZKiNkH.js"))}),`./locales/${t}/docs-administration-tenants-other.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-BbAfGAzk.js")),"./locales/en/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-cv88prRo.js")),"./locales/fr/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Clm4Yhy7.js")),"./locales/it/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Xtrdol6a.js"))}),`./locales/${t}/docs-administration-permissions-assignments.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-BXTwlVt_.js")),"./locales/en/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DxKx9YEc.js")),"./locales/fr/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DehK43TA.js")),"./locales/it/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-D2SCJxWE.js"))}),`./locales/${t}/docs-administration-tenants-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-CMJEiBDZ.js")),"./locales/en/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-BDCjPv_a.js")),"./locales/fr/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-DXBq6rZX.js")),"./locales/it/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-7mBPVsvv.js"))}),`./locales/${t}/docs-administration-tenants-access-requests.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DV-_MnD2.js")),"./locales/en/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BJS2qchs.js")),"./locales/fr/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DDPYmh_7.js")),"./locales/it/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BWchU3XZ.js"))}),`./locales/${t}/docs-administration-tenants-organisations.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-nvIWiI_l.js")),"./locales/en/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-yc0oKKrD.js")),"./locales/fr/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-jObWdig-.js")),"./locales/it/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-BtPIdbRr.js"))}),`./locales/${t}/docs-platform-support-tickets.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-D6Oy2YkN.js")),"./locales/en/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-sPBt_1c4.js")),"./locales/fr/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-BVpRmDsI.js")),"./locales/it/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-lQ9K3m9K.js"))}),`./locales/${t}/docs-administration-users-dashboard.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Du_ykq8Q.js")),"./locales/en/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-CNWOU2Wq.js")),"./locales/fr/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Dc8nUoSy.js")),"./locales/it/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-C5YUKBpW.js"))}),`./locales/${t}/docs-administration-users-references.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-WmOKFuUm.js")),"./locales/en/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-C6xh7MWi.js")),"./locales/fr/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-DgWpE7cP.js")),"./locales/it/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-7NuH5xFT.js"))}),`./locales/${t}/docs-administration-users-groups.json`,4).catch(()=>({default:{}}))]);return{common:s.default||{},navigation:r.default||{},auth:a.default||{},admin:o.default||{},support:c.default||{},docs:i.default||{},ai:d.default||{},communications:u.default||{},entra:m.default||{},structure:p.default||{},preferences:g.default||{},groups:f.default||{},ba:b.default||{},docsAdministrationUsers:h.default||{},docsAdministrationPermissions:y.default||{},docsAdministrationTenants:x.default||{},docsAdministrationAi:j.default||{},docsAdministrationWorkflows:v.default||{},docsAdministrationEntra:S.default||{},docsAdministrationApplications:N.default||{},docsAdministrationConfiguration:I.default||{},docsAdministrationConfigurationLicense:P.default||{},docsAdministrationTenantsTemplate:k.default||{},docsAdministrationTenantsBusiness:A.default||{},docsAdministrationTenantsPersonal:R.default||{},docsAdministrationTenantsOther:$.default||{},docsAdministrationPermissionsAssignments:q.default||{},docsAdministrationTenantsApplications:C.default||{},docsAdministrationTenantsAccessRequests:D.default||{},docsAdministrationTenantsOrganisations:Y.default||{},docsPlatformSupportTickets:T.default||{},docsAdministrationUsersDashboard:z.default||{},docsAdministrationUsersReferences:Z.default||{},docsAdministrationUsersGroups:H.default||{}}}catch(s){return console.warn(`Failed to load language: ${t}`,s),null}},$n={},Dn=()=>{const t=localStorage.getItem("i18nextLng");if(t&&["en","fr","de","it"].includes(t))return t;const s=navigator.language.split("-")[0];return["en","fr","de","it"].includes(s)?s:"en"},It=Dn();Dt.use(Ya).use(ne.initReactI18next).init({resources:$n,lng:It,fallbackLng:"en",defaultNS:"common",ns:["common","navigation","auth","admin","support","docs","ai","communications","entra","structure","preferences","groups","ba","docsAdministrationUsers","docsAdministrationPermissions","docsAdministrationTenants","docsAdministrationAi","docsAdministrationWorkflows","docsAdministrationEntra","docsAdministrationApplications","docsAdministrationConfiguration","docsAdministrationConfigurationLicense","docsAdministrationTenantsTemplate","docsAdministrationTenantsBusiness","docsAdministrationTenantsPersonal","docsAdministrationTenantsOther","docsAdministrationPermissionsAssignments","docsAdministrationTenantsApplications","docsAdministrationTenantsAccessRequests","docsAdministrationTenantsOrganisations","docsPlatformSupportTickets","docsAdministrationUsersReferences","docsAdministrationUsersGroups"],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],caches:["localStorage"]}});const rs=(t,s)=>{Object.entries(s).forEach(([r,a])=>{Dt.addResourceBundle(t,r,a,!0,!0)})},Mn=(async()=>{const t=[];It!=="en"&&t.push(ss("en").then(s=>{s&&rs("en",s)})),t.push(ss(It).then(s=>{s&&rs(It,s)})),await Promise.all(t)})(),xs=async t=>{if(await Mn,!Dt.hasResourceBundle(t,"common")){const s=await ss(t);s&&rs(t,s)}await Dt.changeLanguage(t)},br=n.createContext(void 0);function On(){if(typeof window>"u")return yt;try{const s=localStorage.getItem(hr);if(s){const r=JSON.parse(s);return{...yt,...r,borderRadius:{...yt.borderRadius,...r.borderRadius},itemPaletteKey:r.itemPaletteKey||ms,colors:{light:mt(r.accentColorKey||"indigo"),dark:pt(r.accentColorKey||"indigo")}}}}catch{}const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return{...yt,mode:t?"dark":"light"}}function Tt(t){const s=t.accentColorKey||"indigo",r=t.borderRadius;return{mode:t.theme||"dark",accentColorKey:s,borderRadius:{card:r?.card||"large",button:r?.button||"medium",badge:r?.badge||"medium",input:r?.input||"medium",modal:r?.modal||"xlarge",menuItem:r?.menuItem||"medium"},itemPaletteKey:t.itemPaletteKey||ms,colors:{light:mt(s),dark:pt(s)}}}function Fn(t){const s=document.documentElement,r=t.mode==="dark"?t.colors.dark:t.colors.light,a=_e[t.accentColorKey]?.shades||_e.indigo.shades,o=ut[t.itemPaletteKey]||ut.neutral,c=t.mode==="dark"?o.colors.dark:o.colors.light;t.mode==="dark"?s.classList.add("dark"):s.classList.remove("dark"),s.style.setProperty("--radius-card",Qe[t.borderRadius.card]),s.style.setProperty("--radius-button",Qe[t.borderRadius.button]),s.style.setProperty("--radius-badge",Qe[t.borderRadius.badge]),s.style.setProperty("--radius-input",Qe[t.borderRadius.input]),s.style.setProperty("--radius-modal",Qe[t.borderRadius.modal]),s.style.setProperty("--radius-menu-item",Qe[t.borderRadius.menuItem]),Object.entries(a).forEach(([i,d])=>{s.style.setProperty(`--color-accent-${i}`,d)}),s.style.setProperty("--item-color-light",c.light),s.style.setProperty("--item-color-medium",c.medium),s.style.setProperty("--item-color-dark",c.dark),s.style.setProperty("--item-color-border",c.border),s.style.setProperty("--bg-app",r.backgrounds.app),s.style.setProperty("--bg-primary",r.backgrounds.primary),s.style.setProperty("--bg-secondary",r.backgrounds.secondary),s.style.setProperty("--bg-tertiary",r.backgrounds.tertiary),s.style.setProperty("--bg-card",r.backgrounds.card),s.style.setProperty("--bg-hover",r.backgrounds.hover),s.style.setProperty("--bg-active",r.backgrounds.active),s.style.setProperty("--text-primary",r.text.primary),s.style.setProperty("--text-secondary",r.text.secondary),s.style.setProperty("--text-tertiary",r.text.tertiary),s.style.setProperty("--text-muted",r.text.muted),s.style.setProperty("--text-inverse",r.text.inverse),s.style.setProperty("--border-color",r.border.default),s.style.setProperty("--border-subtle",r.border.subtle),s.style.setProperty("--border-strong",r.border.strong),s.style.setProperty("--success-bg",r.status.success.bg),s.style.setProperty("--success-text",r.status.success.text),s.style.setProperty("--success-border",r.status.success.border),s.style.setProperty("--success-dot",r.status.success.dot),s.style.setProperty("--warning-bg",r.status.warning.bg),s.style.setProperty("--warning-text",r.status.warning.text),s.style.setProperty("--warning-border",r.status.warning.border),s.style.setProperty("--warning-dot",r.status.warning.dot),s.style.setProperty("--error-bg",r.status.error.bg),s.style.setProperty("--error-text",r.status.error.text),s.style.setProperty("--error-border",r.status.error.border),s.style.setProperty("--error-dot",r.status.error.dot),s.style.setProperty("--info-bg",r.status.info.bg),s.style.setProperty("--info-text",r.status.info.text),s.style.setProperty("--info-border",r.status.info.border),s.style.setProperty("--info-dot",r.status.info.dot),s.style.setProperty("--accent-bg",r.accentTransparent.bg),s.style.setProperty("--accent-text",r.accentTransparent.text),s.style.setProperty("--accent-border",r.accentTransparent.border)}function vr({children:t}){const[s,r]=n.useState(On),[a,o]=n.useState(!1),[c,i]=n.useState(null),[d,u]=n.useState(void 0),[m,p]=n.useState([]),{i18n:g}=ne.useTranslation(),f=n.useRef(null),b=n.useRef(!0),h=n.useRef(!1),y=n.useRef(!1),x=n.useCallback(async(T,z=void 0)=>{if(!localStorage.getItem("token")||y.current)return;let H=null;const J=localStorage.getItem("currentTenantId");if(z===void 0)J?H=J:H=null;else{if(z!==null&&J&&z!==J)return;H=z}try{o(!0),await _t.preferences.updateTheme({mode:T.mode,accentColorKey:T.accentColorKey,borderRadius:{card:T.borderRadius.card,button:T.borderRadius.button,badge:T.borderRadius.badge,input:T.borderRadius.input,modal:T.borderRadius.modal,menuItem:T.borderRadius.menuItem},itemPaletteKey:T.itemPaletteKey,targetTenantId:H}),H&&!m.includes(H)&&p(fe=>[...fe,H])}catch(fe){console.error("[ThemeContext] ❌ Failed to save theme to server:",{error:fe,targetTenantId:H,mode:T.mode,accentColorKey:T.accentColorKey,localStorage_currentTenantId:localStorage.getItem("currentTenantId"),localStorage_currentTenantSlug:localStorage.getItem("currentTenantSlug")})}finally{o(!1)}},[m]),j=n.useCallback((T,z=void 0)=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{x(T,z)},1e3)},[x]);n.useLayoutEffect(()=>{Fn(s)},[s]),n.useEffect(()=>{const T={mode:s.mode,borderRadius:s.borderRadius,accentColorKey:s.accentColorKey,itemPaletteKey:s.itemPaletteKey};localStorage.setItem(hr,JSON.stringify(T)),!y.current&&!b.current&&j(s,d),b.current=!1},[s,j,d]),n.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const v=n.useCallback(async T=>{const z=localStorage.getItem("token"),Z=localStorage.getItem("currentTenantSlug");if(!z)return;const H=T==="global";if(!(!H&&!Z))try{o(!0);const J=H?await Ne.preferences.getGlobal():await Ne.preferences.get();i(J.scope);const fe=Tt(J);b.current=!0,r(fe),h.current=!0,J.language&&J.language!==g.language&&(await xs(J.language),document.documentElement.lang=J.language)}catch(J){console.error("[ThemeContext] Failed to load theme from server:",J)}finally{o(!1)}},[g]),S=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.applyToTenant();i(Z.scope)}catch(Z){throw console.error("[ThemeContext] Failed to create tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),N=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.deleteTenantOverride();i(Z.scope);const H=Tt(Z);b.current=!0,r(H)}catch(Z){throw console.error("[ThemeContext] Failed to delete tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),I=n.useCallback(async()=>{if(localStorage.getItem("token"))try{const z=await Ne.preferences.getThemeOverrides();p(z)}catch(z){console.error("[ThemeContext] Failed to load tenant overrides:",z)}},[]),P=n.useCallback(async(T,z=!1)=>{if(f.current&&(clearTimeout(f.current),f.current=null),y.current=!0,h.current=!0,b.current=!0,u(T),z){y.current=!1;return}if(!localStorage.getItem("token")){y.current=!1;return}try{if(o(!0),T===null){const H=await Ne.preferences.getGlobal();i(H.scope);const J=Tt(H);b.current=!0,r(J)}else{const H=await Ne.preferences.getForTenant(T);i(H.scope);const J=Tt(H);b.current=!0,r(J)}}catch(H){console.error("[ThemeContext] Failed to load preferences for tenant:",H)}finally{o(!1),y.current=!1}},[]),k=n.useCallback(()=>{r(T=>({...T,mode:T.mode==="light"?"dark":"light",colors:{light:mt(T.accentColorKey),dark:pt(T.accentColorKey)}}))},[]),A=n.useCallback(T=>{r(z=>({...z,mode:T}))},[]),R=n.useCallback((T,z)=>{r(Z=>({...Z,borderRadius:{...Z.borderRadius,[T]:z}}))},[]),$=n.useCallback(T=>{_e[T]&&r(z=>({...z,accentColorKey:T,colors:{light:mt(T),dark:pt(T)}}))},[]),q=n.useCallback(T=>{ut[T]&&r(z=>({...z,itemPaletteKey:T}))},[]),C=n.useCallback(T=>{r(z=>{const Z=T.accentColorKey||z.accentColorKey;return{...z,...T,borderRadius:{...z.borderRadius,...T.borderRadius},accentColorKey:Z,itemPaletteKey:T.itemPaletteKey||z.itemPaletteKey,colors:{light:mt(Z),dark:pt(Z)}}})},[]),D=n.useCallback(()=>{r(yt)},[]),Y=n.useCallback(T=>Qe[s.borderRadius[T]],[s.borderRadius]);return e.jsx(br.Provider,{value:{config:s,mode:s.mode,toggleMode:k,setMode:A,setBorderRadius:R,setAccentColor:$,setItemPalette:q,applyPreset:C,resetToDefault:D,getBorderRadius:Y,loadFromServer:v,isSyncing:a,scopeInfo:c,applyToTenant:S,resetToGlobal:N,selectedThemeTenant:d,setSelectedThemeTenant:P,tenantOverrides:m,loadTenantOverrides:I},children:t})}function St(){const t=n.useContext(br);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}let ft=null,at=null;const _n={async getFeatureConfig(t){return ft||at||(at=(async()=>{try{return ft=(await us.get("/api/config/features",{timeout:1e4,signal:t,headers:{"Content-Type":"application/json"}})).data,ft}finally{at=null}})(),at)},clearCache(){ft=null,at=null}},yr=n.createContext(void 0);function qn({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(!0);n.useEffect(()=>{const i=new AbortController;return _n.getFeatureConfig(i.signal).then(d=>{i.signal.aborted||r(d)}).catch(d=>{d.name==="CanceledError"||i.signal.aborted||(console.error("Failed to load feature config:",d),r({multiTenantEnabled:!0,enableB2B:!0,enableB2C:!0,useUrlRouting:!0}))}).finally(()=>{i.signal.aborted||o(!1)}),()=>i.abort()},[]);const c={config:s,isLoading:a,isMultiTenant:!0,isHybridMode:s?.multiTenantEnabled===!0&&s?.enableB2B===!1&&s?.enableB2C===!0,enableB2B:s?.enableB2B??!0,enableB2C:s?.enableB2C??!0,useUrlRouting:s?.useUrlRouting??!0};return e.jsx(yr.Provider,{value:c,children:t})}function qt(){const t=n.useContext(yr);if(!t)throw new Error("useFeatureConfig must be used within FeatureConfigProvider");return t}const jr="*";function Ct(t,s){const r=t.toLowerCase(),a=s.toLowerCase();if(r==="*"||r===a)return!0;if(r.endsWith(".*")){const o=r.slice(0,-2);return a.startsWith(o+".")||a===o}return!1}function Un(t,s){if(t.includes(s))return!0;for(const r of t)if(Ct(r,s))return!0;return!1}function jt(t){return t.includes(jr)}function Nr(t,s){if(!s||jt(t))return!0;const r=s.toLowerCase(),a=r+".";for(const o of t){const c=o.toLowerCase();if(c==="*"||c===r||c.startsWith(a))return!0;if(c.endsWith(".*")){const i=c.slice(0,-1);if(r.startsWith(i)||a.startsWith(i))return!0}}return!1}const hs=n.createContext(void 0),nt="token",ot="user";function wr({children:t}){const[s,r]=n.useState(()=>{if(typeof window<"u"){const m=localStorage.getItem(ot);if(m)try{return JSON.parse(m)}catch{return null}}return null}),[a,o]=n.useState(!0),c=n.useCallback((m,p)=>{localStorage.setItem(nt,m),localStorage.setItem(ot,JSON.stringify(p)),r(p)},[]),i=n.useCallback(async()=>{try{localStorage.getItem(nt)&&await E.post("/api/auth/logout")}catch{}localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot),r(null),window.location.href="/login"},[]),d=n.useCallback(m=>{if(!s)return!1;if(jt(s.permissions)||s.permissions.includes(m))return!0;for(const p of s.permissions)if(Ct(p,m))return!0;return!1},[s]),u=n.useCallback(async()=>{if(localStorage.getItem(nt))try{const p=await E.get("/api/auth/me");r(p),localStorage.setItem(ot,JSON.stringify(p))}catch(p){console.error("Failed to refresh permissions:",p)}},[]);return n.useEffect(()=>{localStorage.getItem(nt)&&!s?E.get("/api/auth/me").then(p=>{r(p),localStorage.setItem(ot,JSON.stringify(p))}).catch(()=>{localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot)}).finally(()=>o(!1)):o(!1)},[s]),e.jsx(hs.Provider,{value:{user:s,isAuthenticated:!!s,isLoading:a,login:c,logout:i,hasPermission:d,refreshPermissions:u},children:t})}function Pe(){const t=n.useContext(hs);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}function zn(){return n.useContext(hs)??null}function Sr(t){return t.includes("*")}const Cr=n.createContext(void 0);function kr({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(null),[c,i]=n.useState(!0),[d,u]=n.useState(null),m=n.useRef(null),p=n.useCallback(async h=>{try{i(!0),u(null);const[y,x]=await Promise.all([E.get("/api/administration/license",{signal:h}),E.get("/api/administration/license/usage",{signal:h}).catch(()=>null)]);h?.aborted||(r(y),o(x))}catch(y){if(y instanceof Error&&y.name==="CanceledError"||h?.aborted)return;u(y instanceof Error?y.message:"Failed to load license info"),console.error("Failed to fetch license:",y)}finally{h?.aborted||i(!1)}},[]);n.useEffect(()=>{m.current?.abort();const h=new AbortController;return m.current=h,p(h.signal),()=>h.abort()},[p]);const g=n.useCallback(h=>s?Sr(s.enabledFeatures)?!0:s.enabledFeatures.some(y=>y.toLowerCase()===h.toLowerCase()):!1,[s]),f=n.useCallback(async()=>{m.current?.abort();const h=new AbortController;m.current=h,await p(h.signal)},[p]),b=n.useCallback(async(h,y)=>{try{const x=await E.post("/api/administration/license/activate",{licenseKey:h,apiKey:y||null});return x.success?(await f(),{success:!0}):{success:!1,error:x.errorMessage||"Activation failed"}}catch(x){return{success:!1,error:x instanceof Error?x.message:"Activation failed"}}},[f]);return e.jsx(Cr.Provider,{value:{license:s,usage:a,isLoading:c,error:d,isFeatureEnabled:g,isReadOnlyMode:s?.isReadOnlyMode??!1,isServerDowntimeBlocked:s?.isServerDowntimeBlocked??!1,refreshLicense:f,activateLicense:b},children:t})}function He(){const t=n.useContext(Cr);if(t===void 0)throw new Error("useLicense must be used within a LicenseProvider");return t}const Ar=n.createContext(void 0),Xe="currentTenantId",Ye="currentTenantSlug",Be="isGlobalView";function Bn({children:t}){const{isAuthenticated:s,user:r,refreshPermissions:a}=Pe(),{isLoading:o}=qt(),[c,i]=n.useState(null),[d,u]=n.useState([]),[m,p]=n.useState(!0),[g,f]=n.useState(null),[b,h]=n.useState(()=>localStorage.getItem(Be)==="true"),y=n.useRef(!1),x=n.useRef(""),j=d.filter(C=>C.type==="Business"),v=d.find(C=>C.type==="Personal")||null,S=n.useCallback((C,D)=>{if(u(C),C.length===0){i(null),h(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be),p(!1);return}const Y=localStorage.getItem(Xe),T=Y?C.find(J=>J.id===Y):null;if(T?.status==="Active"){i(T),h(!1),localStorage.setItem(Xe,T.id),localStorage.setItem(Ye,T.slug),localStorage.removeItem(Be),p(!1);return}if(localStorage.getItem(Be)==="true"){h(!0),i(null),p(!1);return}const Z=C.find(J=>J.isDefault&&J.status==="Active");if(Z){i(Z),h(!1),localStorage.setItem(Xe,Z.id),localStorage.setItem(Ye,Z.slug),localStorage.removeItem(Be),p(!1);return}if(D){h(!0),i(null),localStorage.setItem(Be,"true"),p(!1);return}const H=C.find(J=>J.status==="Active");i(H||null),H&&(localStorage.setItem(Xe,H.id),localStorage.setItem(Ye,H.slug)),p(!1)},[]),N=n.useCallback(async C=>{const D=d.find(Y=>Y.id===C);if(!D)throw new Error("Tenant not found");if(D.status!=="Active")throw new Error("Cannot switch to inactive tenant");h(!1),localStorage.removeItem(Be),i(D),localStorage.setItem(Xe,C),localStorage.setItem(Ye,D.slug),await a()},[d,a]),I=n.useCallback(async()=>{h(!0),localStorage.setItem(Be,"true"),i(null),localStorage.removeItem(Xe),localStorage.removeItem(Ye),await a()},[a]),P=n.useCallback(async()=>{h(!1),localStorage.removeItem(Be);const C=d.find(T=>T.isDefault&&T.status==="Active"),D=d.find(T=>T.status==="Active"),Y=C||D||null;Y&&(i(Y),localStorage.setItem(Xe,Y.id),localStorage.setItem(Ye,Y.slug)),await a()},[d,a]),k=n.useCallback(async C=>{try{await Ne.myTenants.setDefault(C),u(D=>D.map(T=>({...T,isDefault:T.id===C}))),await N(C)}catch(D){throw console.error("[TenantContext] Failed to set default tenant:",D),D}},[N]),A=n.useCallback(async()=>{try{await Ne.myTenants.clearDefault(),u(C=>C.map(D=>({...D,isDefault:!1}))),await I()}catch(C){throw console.error("[TenantContext] Failed to clear default tenant:",C),C}},[I]),R=n.useCallback(async()=>{p(!0),f(null);try{await a()}catch(C){console.error("Failed to refresh tenants:",C),f("Failed to refresh tenants")}finally{p(!1)}},[a]);n.useEffect(()=>{if(!s||!r){y.current&&(u([]),i(null),p(!1),y.current=!1,x.current="");return}const C=r.tenants||[],D=C.map(Y=>`${Y.id}:${Y.status}:${Y.isDefault}`).sort((Y,T)=>Y.localeCompare(T)).join(",");if(!y.current||D!==x.current){y.current=!0,x.current=D;const Y=jt(r.permissions||[]);S(C,Y),localStorage.getItem(Ye)&&a().catch(z=>console.error("[TenantContext] Failed to refresh permissions after tenant init:",z))}},[s,r,S,a]),n.useEffect(()=>{s||(i(null),u([]),h(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be))},[s]);const $=r?jt(r.permissions||[]):!1,q={currentTenant:c,userTenants:d,b2bTenants:j,personalTenant:v,isLoading:m||o,error:g,switchTenant:N,setDefaultTenant:k,clearDefaultTenant:A,refreshTenants:R,hasMultipleTenants:d.filter(C=>C.status==="Active").length>1,isCurrentTenantOwner:c?.isOwner??!1,hasGlobalRoles:$,isGlobalView:b,enterGlobalView:I,exitGlobalView:P};return e.jsx(Ar.Provider,{value:q,children:t})}function Ee(){const t=n.useContext(Ar);if(t===void 0)throw new Error("useTenant must be used within a TenantProvider");return t}const Rt=5,Pr=n.createContext(null);function Tr({children:t}){const{i18n:s}=ne.useTranslation(),{isAuthenticated:r}=Pe(),{currentTenant:a,isLoading:o}=Ee(),[c,i]=n.useState([]),[d,u]=n.useState(!1),[m,p]=n.useState(null),[g,f]=n.useState(!1),b=n.useCallback(()=>{f(!0)},[]),h=n.useCallback(()=>{f(!1)},[]),y=n.useCallback(async()=>{try{u(!0),p(null);const A=(await E.get("/api/navigation/module-favorites")).map(R=>({id:R.id,code:R.code,label:R.label,icon:R.icon||"Star",route:R.route||"",applicationId:R.applicationId,applicationCode:R.applicationCode,applicationLabel:R.applicationLabel,displayOrder:R.displayOrder}));i(A)}catch(k){console.error("Failed to load favorite modules:",k),p("Erreur lors du chargement des favoris"),i([])}finally{u(!1)}},[]);n.useEffect(()=>{r&&!o?y():r||(i([]),p(null))},[r,o,a,y]),n.useEffect(()=>{const k=()=>{r&&!o&&y()};return s.on("languageChanged",k),()=>{s.off("languageChanged",k)}},[s,r,o,y]);const x=n.useCallback(async k=>{if(c.length>=Rt||c.some(A=>A.id===k.id))return!1;try{return p(null),await E.post(`/api/navigation/module-favorites/${k.id}`),i(A=>[...A,{...k,displayOrder:A.length+1}]),!0}catch(A){return console.error("Failed to add favorite module:",A),await y(),!1}},[c,y]),j=n.useCallback(async k=>{try{return p(null),await E.delete(`/api/navigation/module-favorites/${k}`),i(A=>A.filter(R=>R.id!==k)),!0}catch(A){return console.error("Failed to remove favorite module:",A),await y(),!1}},[y]),v=n.useCallback(k=>c.some(A=>A.id===k),[c]),S=n.useCallback(async k=>v(k.id)?await j(k.id):await x(k),[v,j,x]),N=n.useCallback(async k=>{const A=k.slice(0,Rt),R=A.map(q=>q.id),$=[...c];i(A.map((q,C)=>({...q,displayOrder:C+1})));try{return p(null),await E.put("/api/navigation/module-favorites/reorder",R),!0}catch(q){return console.error("Failed to reorder favorite modules:",q),i($),!1}},[c]),I=c.length<Rt;return e.jsx(Pr.Provider,{value:{favorites:c,loading:d,error:m,addFavorite:x,removeFavorite:j,toggleFavorite:S,isFavorite:v,reorderFavorites:N,canAddMore:I,maxFavorites:Rt,reload:y,expandFavorites:g,triggerExpand:b,clearExpand:h,requiresTenant:!1},children:t})}function Ke(){const t=n.useContext(Pr);if(!t)throw new Error("useFavorites must be used within a FavoritesProvider");return t}const Rr="smartstack-sidebar-collapsed",Er=n.createContext(void 0);function Gn(){if(typeof window>"u")return!1;try{return localStorage.getItem(Rr)==="true"}catch{return!1}}function Ir({children:t}){const[s,r]=n.useState(Gn);n.useEffect(()=>{localStorage.setItem(Rr,String(s))},[s]);const a=n.useCallback(()=>{r(i=>!i)},[]),o=n.useCallback(i=>{r(i)},[]),c=s?64:256;return e.jsx(Er.Provider,{value:{isCollapsed:s,toggleCollapsed:a,setCollapsed:o,sidebarWidth:c},children:t})}function Ut(){const t=n.useContext(Er);if(t===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return t}const Lr=["login","callback","logout","onboarding","system","applications","notifications"],$r=n.createContext(void 0);function Kn(t){let s=t.split("/").filter(Boolean);return s.length>=2&&s[0]==="t"&&(s=s.slice(2)),s.length===0?{app:null,module:null}:Lr.includes(s[0])?{app:null,module:null}:{app:s[0]||null,module:s[1]||null}}function gs({children:t}){const s=w.useLocation(),{i18n:r}=ne.useTranslation(),{currentTenant:a,isLoading:o,isGlobalView:c}=Ee(),[i,d]=n.useState(null),[u,m]=n.useState([]),[p,g]=n.useState(!0),f=n.useRef(!1),b=n.useRef(void 0),h=n.useRef(0),y=c?"global":a?.id??"none";f.current&&y!==b.current&&!p&&g(!0);const{app:x,module:j}=Kn(s.pathname),v=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/menu");d(C)}catch(C){console.error("Failed to fetch menu:",C)}},[]),S=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/favorites");m(C)}catch(C){console.error("Failed to fetch favorites:",C)}},[]),N=n.useCallback(async()=>{const C=++h.current;if(g(!0),await v(),C===h.current){if(a){if(await S(),C!==h.current)return}else m([]);g(!1)}},[v,S,a]);n.useEffect(()=>{const C=localStorage.getItem("token"),D=c?"global":a?.id??"none";if(!(!C||o)){if(!f.current){f.current=!0,b.current=D,N();return}D!==b.current&&(b.current=D,N())}},[a?.id,c,o]),n.useEffect(()=>{const C=()=>{localStorage.getItem("token")&&N()};return r.on("languageChanged",C),()=>{r.off("languageChanged",C)}},[r,N]);const I=n.useCallback(C=>C.startsWith("core_")?C.slice(5):C.startsWith("ext_")?C.slice(4):C,[]),P=n.useCallback((C,D)=>C&&C.split("/").filter(Boolean)[D]||null,[]),k=n.useCallback(()=>i?.applications.find(C=>P(C.route,0)===x||I(C.code)===x),[i,x,P,I]),A=n.useCallback(()=>k()?.modules.find(D=>P(D.route,1)===j||I(D.code)===j),[k,j,P,I]),R=n.useCallback(C=>i?.applications.filter(D=>D.zone===C)||[],[i]),$=n.useCallback(C=>u.some(D=>D.id===C),[u]),q=n.useCallback(async C=>{if(a)try{$(C)?(await E.delete(`/api/navigation/favorites/${C}`),m(D=>D.filter(Y=>Y.id!==C))):(await E.post(`/api/navigation/favorites/${C}`,{}),await S())}catch(D){console.error("Failed to toggle favorite:",D)}},[a,$,S]);return e.jsx($r.Provider,{value:{menu:i,favorites:u,currentAppCode:x,currentModuleCode:j,isLoading:p,getCurrentApplication:k,getCurrentModule:A,getApplicationsByZone:R,getApplicationsForContext:R,toggleFavorite:q,isFavorite:$,refreshMenu:N},children:t})}function Ce(){const t=n.useContext($r);if(t===void 0)throw new Error("useNavigation must be used within a NavigationProvider");return t}const Dr=n.createContext(null);function Mr({children:t}){const{isAuthenticated:s,refreshPermissions:r}=Pe(),{refreshMenu:a}=Ce(),o=n.useRef(null),[c,i]=n.useState(oe.HubConnectionState.Disconnected),d=n.useRef(new Set),u=n.useRef(new Set),m=n.useRef(!1),p=n.useCallback(async()=>{if(!m.current){m.current=!0;try{await Promise.all([r(),a()])}catch(x){console.error("[SignalR] Failed to refresh permissions:",x)}finally{m.current=!1}}},[r,a]),g=n.useCallback(async()=>{const x=localStorage.getItem("token");if(x&&!(o.current?.state===oe.HubConnectionState.Connected||o.current?.state===oe.HubConnectionState.Connecting))try{const j=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>x}).withAutomaticReconnect({nextRetryDelayInMilliseconds:v=>v.previousRetryCount===0?0:v.previousRetryCount===1?2e3:v.previousRetryCount===2?1e4:v.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();j.on("ReceiveNotification",v=>{d.current.forEach(S=>S(v))}),j.on("UnreadCountUpdate",v=>{u.current.forEach(S=>S(v))}),j.on("PermissionsChanged",p),j.onreconnecting(()=>{i(oe.HubConnectionState.Reconnecting)}),j.onreconnected(()=>{i(oe.HubConnectionState.Connected)}),j.onclose(()=>{i(oe.HubConnectionState.Disconnected)}),await j.start(),o.current=j,i(oe.HubConnectionState.Connected)}catch(j){console.error("[SignalR] Failed to connect:",j),i(oe.HubConnectionState.Disconnected)}},[p]),f=n.useCallback(async()=>{if(o.current)try{await o.current.stop(),o.current=null,i(oe.HubConnectionState.Disconnected)}catch(x){console.error("[SignalR] Failed to disconnect:",x)}},[]);n.useEffect(()=>(s?g():f(),()=>{f()}),[s,g,f]);const b=n.useCallback(x=>(d.current.add(x),()=>{d.current.delete(x)}),[]),h=n.useCallback(x=>(u.current.add(x),()=>{u.current.delete(x)}),[]),y={isConnected:c===oe.HubConnectionState.Connected,connectionState:c,onNotification:b,onUnreadCountUpdate:h};return e.jsx(Dr.Provider,{value:y,children:t})}function Or(){const t=n.useContext(Dr);if(!t)throw new Error("useSignalRContext must be used within a SignalRProvider");return t}const Mt={register:async t=>E.post("/api/auth/register",t),confirmEmail:async t=>E.post("/api/auth/confirm-email",{token:t}),resendConfirmation:async t=>E.post("/api/auth/resend-confirmation",{email:t}),forgotPassword:async t=>E.post("/api/auth/forgot-password",{email:t}),resetPassword:async(t,s)=>E.post("/api/auth/reset-password",{token:t,newPassword:s}),login:async(t,s)=>{const r=await E.post("/api/auth/login",{email:t,password:s});return r.token&&(localStorage.setItem("token",r.token),localStorage.setItem("refreshToken",r.refreshToken)),r},logout:async()=>{try{await E.post("/api/auth/logout")}finally{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user")}},changePassword:async(t,s)=>E.post("/api/auth/change-password",{currentPassword:t,newPassword:s}),refreshSession:async()=>{const t=await E.post("/api/auth/refresh");return t.token&&(localStorage.setItem("token",t.token),localStorage.setItem("refreshToken",t.refreshToken)),t},getSessionInfo:async t=>E.get("/api/auth/session-info",{signal:t?.signal})};function Fr(t={}){const{checkIntervalMs:s=6e4,onSessionExpired:r,onWarningThreshold:a,enabled:o=!0}=t,[c,i]=n.useState({isActive:!0,timeRemainingSeconds:0,isWarning:!1,sessionInfo:null}),[d,u]=n.useState(!1),m=n.useRef(!1),p=n.useRef(null),g=n.useRef(null),f=n.useCallback(async h=>{if(!o)return;if(!localStorage.getItem("token")){i(x=>({...x,isActive:!1}));return}try{const x=await Mt.getSessionInfo({signal:h});if(h?.aborted)return;const j=Math.min(x.timeUntilIdleExpirySeconds,x.timeUntilAbsoluteExpirySeconds);i({isActive:!0,timeRemainingSeconds:j,isWarning:x.isWarningThreshold,sessionInfo:x}),x.isWarningThreshold&&!m.current&&(m.current=!0,a?.()),x.isWarningThreshold||(m.current=!1)}catch(x){if(x instanceof Error&&x.name==="CanceledError"||h?.aborted)return;i(j=>({...j,isActive:!1})),r?.()}},[o,r,a]),b=n.useCallback(async()=>{if(d)return!1;u(!0);try{return await Mt.refreshSession(),m.current=!1,await f(),!0}catch{return i(h=>({...h,isActive:!1})),!1}finally{u(!1)}},[d,f]);return n.useEffect(()=>{if(!o)return;g.current?.abort();const h=new AbortController;return g.current=h,f(h.signal),p.current=setInterval(()=>f(),s),()=>{h.abort(),p.current&&clearInterval(p.current)}},[o,s,f]),n.useEffect(()=>{if(!o)return;const h=()=>{c.isWarning&&f()},y=["mousedown","keydown","touchstart","scroll"];return y.forEach(x=>{window.addEventListener(x,h,{passive:!0})}),()=>{y.forEach(x=>{window.removeEventListener(x,h)})}},[o,c.isWarning,f]),{...c,isRefreshing:d,refreshSession:b,checkSession:f}}function Hn(t){if(t<=0)return"0:00";const s=Math.floor(t/60),r=t%60;if(s>=60){const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}return`${s}:${r.toString().padStart(2,"0")}`}function _r({isOpen:t,timeRemainingSeconds:s,onExtendSession:r,onLogout:a}){const{t:o}=ne.useTranslation("common"),[c,i]=n.useState(!1),[d,u]=n.useState(s);n.useEffect(()=>{u(s)},[s]),n.useEffect(()=>{if(!t||d<=0)return;const g=setInterval(()=>{u(f=>f<=1?(a(),0):f-1)},1e3);return()=>clearInterval(g)},[t,d,a]);const m=async()=>{i(!0);try{await r()||a()}finally{i(!1)}};if(!t)return null;const p=Math.max(0,Math.min(100,d/300*100));return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"relative w-full max-w-md bg-[var(--bg-card)] rounded-2xl shadow-2xl border border-amber-500/30 overflow-hidden animate-in fade-in zoom-in duration-200",children:[e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-amber-500/30 w-full",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 transition-all duration-1000 ease-linear",style:{width:`${p}%`}})}),e.jsxs("div",{className:"p-6 pt-8",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/20 flex items-center justify-center mb-4",children:e.jsx(l.Clock,{className:"w-8 h-8 text-amber-500"})}),e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)] mb-2",children:o("session.warningTitle","Session Expiring")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:o("session.warningMessage","Your session will expire due to inactivity.")}),e.jsx("div",{className:"text-4xl font-mono font-bold text-amber-500 tabular-nums",children:Hn(d)}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-2",children:o("session.remainingTime","remaining")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("button",{onClick:a,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-all font-medium",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),o("session.logout","Logout")]}),e.jsxs("button",{onClick:m,disabled:c,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl font-medium transition-all bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 shadow-lg shadow-amber-500/30 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(l.RefreshCw,{className:`w-4 h-4 ${c?"animate-spin":""}`}),c?o("session.extending","Extending..."):o("session.extend","Continue Session")]})]})]})]})})}const Vn=n.createContext(void 0);function qr({children:t}){const{isAuthenticated:s,logout:r}=Pe(),a=n.useCallback(()=>{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),window.location.href="/login?reason=session_expired"},[]),{isActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d}=Fr({enabled:s,checkIntervalMs:3e4,onSessionExpired:a}),u=n.useCallback(async()=>{try{await Mt.logout()}finally{r()}},[r]),m=n.useCallback(async()=>await d(),[d]);return e.jsxs(Vn.Provider,{value:{isSessionActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d},children:[t,e.jsx(_r,{isOpen:i&&s,timeRemainingSeconds:c,onExtendSession:m,onLogout:u})]})}const Wn=150;function Xn({children:t}){const s=zn(),r=s?.isAuthenticated??!1,a=s?.isLoading??!0,{currentTenant:o,isLoading:c,isGlobalView:i}=Ee(),{setSelectedThemeTenant:d,loadFromServer:u}=St(),m=n.useRef(null),p=n.useRef(!1),g=n.useRef(null),f=n.useRef(null),b=n.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),h=n.useCallback(()=>m.current==="global"?!1:(b(),f.current=null,m.current="global",p.current=!0,u("global"),d(null,!0),!0),[b,u,d]),y=n.useCallback((v,S)=>{f.current=v,g.current=setTimeout(()=>{f.current===v&&(m.current=v,p.current=!0,f.current=null,d(v,!1)),g.current=null},Wn)},[d]),x=n.useCallback(()=>{if(!o)return;const v=o.id!==m.current,S=f.current!==null&&f.current!==o.id;!v&&!S||(b(),v?y(o.id,o.slug):f.current=null)},[o,b,y]),j=n.useCallback(()=>{b(),m.current=null,f.current=null,p.current=!1},[b]);return n.useEffect(()=>{if(!r){j();return}if(!(a||c)){if(i&&!o){h();return}o&&x()}},[r,a,c,o,i,h,x,j]),n.useEffect(()=>()=>{b()},[b]),e.jsx(e.Fragment,{children:t})}function Yn(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Jn(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const Qn={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function Ur({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Jn()),i=Yn(t),d=Qn[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-16 h-16 rounded-full ${d.bgColor} flex items-center justify-center mb-6`,children:e.jsx(u,{className:`w-8 h-8 ${d.color}`})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-6 px-3 py-1.5 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),r("errors.home")]})]}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-tertiary)]",children:[r("errors.persistsHelp")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-[var(--color-accent-500)] hover:underline",children:r("errors.contactSupport")})]})]})})})}function Zn(t,s){Te.logCritical(t,"GlobalErrorBoundary",{componentStack:s.componentStack})}function eo(){window.location.reload()}function zr({children:t}){return e.jsx(pr.ErrorBoundary,{FallbackComponent:Ur,onError:Zn,onReset:eo,children:t})}const zt=n.createContext(null);function Br(){const t=n.useContext(zt);if(!t)throw new Error("useSlotFill must be used within a SlotFillProvider");return t}function Gr({children:t,initialFills:s}){const r=n.useMemo(()=>{const o=new Map;return s&&Object.entries(s).forEach(([c,i])=>{const d=o.get(c)||[];Array.isArray(i)?o.set(c,[...d,...i]):o.set(c,[...d,i])}),o},[s]),a=n.useMemo(()=>({fills:r,registerFill:(o,c)=>{const i=r.get(o)||[];r.set(o,[...i,c])},unregisterFill:(o,c)=>{const i=r.get(o)||[];r.set(o,i.filter(d=>d!==c))},getSlotContent:o=>r.get(o)||[]}),[r]);return e.jsx(zt.Provider,{value:a,children:t})}function Kr({name:t,context:s={},children:r,fallback:a,wrapper:o}){const i=n.useContext(zt)?.getSlotContent(t)||[],d=n.useMemo(()=>({slotName:t,context:s}),[t,s]),u=n.useMemo(()=>i.length===0?a||null:i.map((p,g)=>{const f=`${t}-${g}`;return e.jsx(n.Fragment,{children:Vr(p,d)},f)}),[i,t,d,a]),m=e.jsxs(e.Fragment,{children:[u,r]});return o?e.jsx(o,{children:m}):e.jsx(e.Fragment,{children:m})}function Hr({slot:t,children:s}){const{registerFill:r,unregisterFill:a}=Br();return n.useMemo(()=>(r(t,s),()=>a(t,s)),[t,s,r,a]),null}function Vr(t,s){if(t==null)return null;if(Array.isArray(t))return e.jsx(e.Fragment,{children:t.map((r,a)=>e.jsx(n.Fragment,{children:Vr(r,s)},`slot-item-${a}`))});if(n.isValidElement(t))return t;if(typeof t=="function"){const r=t;return e.jsx(r,{...s})}return t}function to(t){return(n.useContext(zt)?.getSlotContent(t)?.length||0)>0}function so(t){function s(a){return e.jsx(Kr,{...a,name:t})}s.displayName=`Slot(${t})`;function r({children:a}){return e.jsx(Hr,{slot:t,children:a})}return r.displayName=`Fill(${t})`,{Slot:s,Fill:r,slotName:t}}const Wr=n.createContext(null);function kt(){const t=n.useContext(Wr);return t||{config:{},getPage:()=>{},getSlotContent:()=>{},getTableColumns:()=>[],getFormFields:()=>[],hasExtension:()=>!1}}function Bt(t){const{getPage:s}=kt();return s(t)}function ro(t){const{getTableColumns:s}=kt();return s(t)}function ao(t){const{getFormFields:s}=kt();return s(t)}function no(t){const{hasExtension:s}=kt();return s(t)}function Xr({config:t={},children:s}){const r=n.useMemo(()=>{const{pages:a={},slots:o={},tableColumns:c={},formFields:i={}}=t;return{config:t,getPage:d=>a[d],getSlotContent:d=>o[d],getTableColumns:d=>c[d]||[],getFormFields:d=>i[d]||[],hasExtension:d=>d in a||d in o||d in c||d in i}},[t]);return e.jsx(Wr.Provider,{value:r,children:e.jsx(Gr,{initialFills:t.slots,children:s})})}class oo{pages=new Map;register(s,r,a=[]){this.pages.set(s,{key:s,defaultComponent:r,slots:a})}get(s){return this.pages.get(s)}resolve(s){return this.pages.get(s)?.defaultComponent}getAll(){return Array.from(this.pages.values())}has(s){return this.pages.has(s)}getSlots(s){return this.pages.get(s)?.slots||[]}keys(){return Array.from(this.pages.keys())}}const O=new oo;function io(t,s){function r(a){const o=Bt(t);return o?e.jsx(o,{...a}):e.jsx(s,{...a})}return r.displayName=`Overridable(${t})`,r}function lo(t){const s=Bt(t),r=O.get(t);return s||r?.defaultComponent}function co({pageKey:t,defaultComponent:s,params:r}){const a=Bt(t),o={pageKey:t,params:r};return a?e.jsx(a,{...o}):e.jsx(s,{...o})}const _={ADMIN_INDEX:"administration",ADMIN_DASHBOARD:"administration.dashboard",USERS_LIST:"administration.users.list",USERS_DETAIL:"administration.users.detail",USERS_DASHBOARD:"administration.users.dashboard",USERS_GROUPS:"administration.users.groups",USERS_GROUPS_DETAIL:"administration.users.groups.detail",USERS_REFERENCES:"administration.users.references",ROLES_LIST:"administration.permissions.roles",ROLES_DETAIL:"administration.permissions.roles.detail",PERMISSIONS_LIST:"administration.permissions.permissions",PERMISSIONS_DETAIL:"administration.permissions.permissions.detail",ASSIGNMENTS:"administration.permissions.assignments",APPLICATIONS_INDEX:"administration.applications",APPLICATIONS_DASHBOARD:"administration.applications.dashboard",APPLICATIONS_LIST:"administration.applications.list",APPLICATIONS_DETAIL:"administration.applications.detail",AI_DASHBOARD:"administration.ai.dashboard",AI_SETTINGS:"administration.ai.settings",AI_SKILLS_LIST:"administration.ai.skills",AI_SKILLS_DETAIL:"administration.ai.skills.detail",AI_SKILLS_CREATE:"administration.ai.skills.create",AI_SKILLS_EDIT:"administration.ai.skills.edit",AI_BLOCKS_LIST:"administration.ai.skills.blocks",AI_BLOCKS_DETAIL:"administration.ai.skills.blocks.detail",AI_BLOCKS_CREATE:"administration.ai.skills.blocks.create",AI_BLOCKS_EDIT:"administration.ai.skills.blocks.edit",AI_MONITORING:"administration.ai.monitoring",AI_AGENTS:"administration.ai.agents",AI_AGENTS_DETAIL:"administration.ai.agents.detail",AI_AGENTS_EDIT:"administration.ai.agents.edit",WORKFLOWS_LIST:"administration.workflows.list",WORKFLOWS_DETAIL:"administration.workflows.detail",WORKFLOWS_CREATE:"administration.workflows.create",WORKFLOWS_EDIT:"administration.workflows.edit",WORKFLOWS_TRIGGERS:"administration.workflows.triggers",WORKFLOWS_HISTORY:"administration.workflows.history",EMAIL_TEMPLATES_LIST:"administration.workflows.email-templates",EMAIL_TEMPLATES_DETAIL:"administration.workflows.email-templates.detail",EMAIL_TEMPLATES_CREATE:"administration.workflows.email-templates.create",EMAIL_TEMPLATES_EDIT:"administration.workflows.email-templates.edit",SMS_TEMPLATES_LIST:"administration.workflows.email-templates.sms",ENTRA_DASHBOARD:"administration.entra.dashboard",ENTRA_GROUPS:"administration.entra.groups",ENTRA_USERS:"administration.entra.users",ENTRA_CONFLICTS:"administration.entra.conflicts",ENTRA_SETTINGS:"administration.entra.settings",TENANTS_DASHBOARD:"administration.tenants.dashboard",TENANTS_LIST:"administration.tenants.list",TENANTS_DETAIL:"administration.tenants.detail",TENANTS_CREATE:"administration.tenants.create",TENANTS_SETTINGS:"administration.tenants.settings",TENANTS_TYPE_SETTINGS:"administration.tenants.type-settings",TENANTS_TEMPLATE:"administration.tenants.template",TENANTS_TEMPLATE_CREATE:"administration.tenants.template.create",TENANTS_TEMPLATE_DETAIL:"administration.tenants.template.detail",TENANTS_BUSINESS:"administration.tenants.list.enterprise",TENANTS_PERSONAL:"administration.tenants.list.personal",TENANTS_OTHER:"administration.tenants.list.other",TENANTS_ACCESS_REQUESTS:"administration.tenants.access-requests",ORGANISATIONS_LIST:"administration.tenants.organisations",ORGANISATIONS_CREATE:"administration.tenants.organisations.create",ORGANISATIONS_DETAIL:"administration.tenants.organisations.detail",SETTINGS:"administration.configuration.settings",SETTINGS_GENERAL:"administration.configuration.settings.general",SETTINGS_FILE_UPLOAD:"administration.configuration.settings.file-upload",SETTINGS_LEGAL_FILE:"administration.configuration.settings.legal-file",APPSETTINGS:"administration.configuration.appsettings",APPSETTINGS_INFRASTRUCTURE:"administration.configuration.appsettings.infrastructure",APPSETTINGS_AUTHENTICATION:"administration.configuration.appsettings.authentication",APPSETTINGS_LOGGING:"administration.configuration.appsettings.logging",APPSETTINGS_EMAIL:"administration.configuration.appsettings.email",APPSETTINGS_ENTRA:"administration.configuration.appsettings.entra",LICENSE:"administration.configuration.license",API_ACCOUNTS_LIST:"api.accounts.list",API_ACCOUNTS_CREATE:"api.accounts.create",API_ACCOUNTS_DETAIL:"api.accounts.detail",API_CATALOG:"api.apis.catalog",API_CATALOG_DETAIL:"api.apis.catalog.detail",SUPPORT_DASHBOARD:"support.tickets",TICKETS_LIST:"support.tickets.list",TICKETS_DETAIL:"support.tickets.detail",TICKETS_ESCALATION:"support.tickets.escalation",TICKETS_NEW:"support.tickets.new",MY_TICKETS_LIST:"support.my-tickets",MY_TICKETS_DETAIL:"support.my-tickets.detail",MY_TICKETS_CREATE:"support.my-tickets.create",SUPPORT_SLA:"support.admin.sla",SUPPORT_TEMPLATES:"support.admin.templates",SUPPORT_PERMISSIONS:"support.admin.permissions",SUPPORT_ASSIGNMENT:"support.assignment",SUPPORT_ASSIGNMENT_SKILLS:"support.assignment.skills",SUPPORT_ASSIGNMENT_WORKLOAD:"support.assignment.workload",MYSPACE_DASHBOARD:"myspace.dashboard",USER_PROFILE:"myspace.profile",USER_PREFERENCES:"myspace.preferences",MYSPACE_TENANTS:"myspace.tenants.workspaces",MYSPACE_ACCESS_REQUESTS:"myspace.tenants.access-requests",MYSPACE_PORTAL:"myspace.portal",NOTIFICATIONS:"notifications",APPLICATIONS_HUB:"applications"};O.register(_.ADMIN_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsGridPage-Bo3NDnBF.js")).then(t=>({default:t.ApplicationsGridPage}))));O.register(_.ADMIN_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-DdQlTLw0.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./UsersPage-CQ38akZ_.js")).then(t=>({default:t.UsersPage}))));O.register(_.USERS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserDetailPage-BMW8jAWG.js")).then(t=>({default:t.UserDetailPage}))));O.register(_.USERS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-DdQlTLw0.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./UsersGroupsPage-xJmGib8b.js")).then(t=>({default:t.UsersGroupsPage}))));O.register(_.USERS_GROUPS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./GroupDetailPage-CPPUWzXf.js")).then(t=>({default:t.GroupDetailPage}))));O.register(_.USERS_REFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./ReferencesManagementPage-C0RgHbJb.js")).then(t=>({default:t.ReferencesManagementPage}))));O.register(_.ROLES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./RolesPage-B75lCugt.js")).then(t=>({default:t.RolesPage}))));O.register(_.ROLES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./RoleDetailPage-DvEEWPKr.js")).then(t=>({default:t.RoleDetailPage}))));O.register(_.PERMISSIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionsPage-sauv7ct1.js")).then(t=>({default:t.PermissionsPage}))));O.register(_.PERMISSIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionDetailPage-C1iuWv0G.js")).then(t=>({default:t.PermissionDetailPage}))));O.register(_.ASSIGNMENTS,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentsPage-78C_EBsw.js")).then(t=>({default:t.AssignmentsPage}))));O.register(_.APPLICATIONS_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./NavigationAppsPage-DiPBCsAF.js")).then(t=>({default:t.NavigationAppsPage}))));O.register(_.APPLICATIONS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsDashboardPage-DHmnjk2O.js")).then(t=>({default:t.ApplicationsDashboardPage}))));O.register(_.APPLICATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsListPage-De8jQ1Cm.js")).then(t=>({default:t.ApplicationsListPage}))));O.register(_.APPLICATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationDetailPage-CngD5JSN.js"))));O.register(_.AI_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiDashboardPage}))));O.register(_.AI_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiSettingsPage}))));O.register(_.AI_SKILLS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiSkillsListPage}))));O.register(_.AI_SKILLS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiSkillsDetailPage}))));O.register(_.AI_SKILLS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_SKILLS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_BLOCKS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiBlockDefinitionsListPage}))));O.register(_.AI_BLOCKS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiBlockDefinitionDetailPage}))));O.register(_.AI_BLOCKS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_BLOCKS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_MONITORING,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiMonitoringPage}))));O.register(_.AI_AGENTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiAgentsPage}))));O.register(_.AI_AGENTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiAgentDetailPage}))));O.register(_.AI_AGENTS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-_g82N2nb.js")).then(t=>({default:t.AiAgentEditPage}))));O.register(_.WORKFLOWS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowsListPage}))));O.register(_.WORKFLOWS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowDetailPage}))));O.register(_.WORKFLOWS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowCreatePage}))));O.register(_.WORKFLOWS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowEditPage}))));O.register(_.WORKFLOWS_TRIGGERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowsTriggersPage}))));O.register(_.WORKFLOWS_HISTORY,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.WorkflowHistoryPage}))));O.register(_.EMAIL_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.EmailTemplatesListPage}))));O.register(_.EMAIL_TEMPLATES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.EmailTemplateDetailPage}))));O.register(_.EMAIL_TEMPLATES_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.EmailTemplateCreatePage}))));O.register(_.EMAIL_TEMPLATES_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.EmailTemplateEditPage}))));O.register(_.SMS_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-BxHVPJ-j.js")).then(t=>({default:t.SmsTemplatesListPage}))));O.register(_.ENTRA_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-DEOBhXS_.js")).then(t=>({default:t.EntraDashboardPage}))));O.register(_.ENTRA_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DEOBhXS_.js")).then(t=>({default:t.EntraGroupsPage}))));O.register(_.ENTRA_USERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DEOBhXS_.js")).then(t=>({default:t.EntraUsersPage}))));O.register(_.ENTRA_CONFLICTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DEOBhXS_.js")).then(t=>({default:t.EntraConflictsPage}))));O.register(_.ENTRA_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DEOBhXS_.js")).then(t=>({default:t.EntraSettingsPage}))));O.register(_.TENANTS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsDashboardPage}))));O.register(_.TENANTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsPage}))));O.register(_.TENANTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantDetailPage}))));O.register(_.TENANTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantCreatePage}))));O.register(_.TENANTS_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantSettingsPage}))));O.register(_.TENANTS_TYPE_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantTypeSettingsPage}))));O.register(_.TENANTS_TEMPLATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsTemplatePage}))));O.register(_.TENANTS_TEMPLATE_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantTemplateCreatePage}))));O.register(_.TENANTS_TEMPLATE_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantTemplateDetailPage}))));O.register(_.TENANTS_BUSINESS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsBusinessPage}))));O.register(_.TENANTS_PERSONAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsPersonalPage}))));O.register(_.TENANTS_OTHER,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantsOtherPage}))));O.register(_.TENANTS_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.TenantAccessRequestsPage}))));O.register(_.ORGANISATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.OrganisationsListPage}))));O.register(_.ORGANISATIONS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.OrganisationCreatePage}))));O.register(_.ORGANISATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Dht6EQW1.js")).then(t=>({default:t.OrganisationDetailPage}))));O.register(_.SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-C1w97Ejz.js")).then(t=>({default:t.SettingsPage}))));O.register(_.SETTINGS_GENERAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-C1w97Ejz.js")).then(t=>({default:t.GeneralSettingsSection}))));O.register(_.SETTINGS_FILE_UPLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./index-C1w97Ejz.js")).then(t=>({default:t.FileUploadSettingsSection}))));O.register(_.SETTINGS_LEGAL_FILE,n.lazy(()=>Promise.resolve().then(()=>require("./index-C1w97Ejz.js")).then(t=>({default:t.LegalFileSettingsSection}))));O.register(_.APPSETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.AppSettingsPage}))));O.register(_.APPSETTINGS_INFRASTRUCTURE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.InfrastructureSection}))));O.register(_.APPSETTINGS_AUTHENTICATION,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.AuthenticationSection}))));O.register(_.APPSETTINGS_LOGGING,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.LoggingSection}))));O.register(_.APPSETTINGS_EMAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.EmailSection}))));O.register(_.APPSETTINGS_ENTRA,n.lazy(()=>Promise.resolve().then(()=>require("./index-CNxx56kE.js")).then(t=>({default:t.EntraSection}))));O.register(_.LICENSE,n.lazy(()=>Promise.resolve().then(()=>require("./index-BOKR3bw6.js")).then(t=>({default:t.LicenseManagementPage}))));O.register(_.API_ACCOUNTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Djy4eIbB.js")).then(t=>({default:t.ExternalAppsListPage}))));O.register(_.API_ACCOUNTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Djy4eIbB.js")).then(t=>({default:t.ExternalAppCreatePage}))));O.register(_.API_ACCOUNTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Djy4eIbB.js")).then(t=>({default:t.ExternalAppDetailPage}))));O.register(_.API_CATALOG,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogPage-B0yIz8-U.js")).then(t=>({default:t.ApiCatalogPage}))));O.register(_.API_CATALOG_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogDetailPage-CsRxlHwO.js")).then(t=>({default:t.ApiCatalogDetailPage}))));O.register(_.SUPPORT_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CcCnUl7s.js")).then(t=>({default:t.DashboardPage}))));O.register(_.TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./TicketsPage-BjaN4Baq.js")).then(t=>({default:t.TicketsPage}))));O.register(_.TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./TicketDetailPage-C1UuMxD8.js")).then(t=>({default:t.TicketDetailPage}))));O.register(_.TICKETS_ESCALATION,n.lazy(()=>Promise.resolve().then(()=>require("./EscalationConfigPage-DRr55328.js")).then(t=>({default:t.EscalationConfigPage}))));O.register(_.TICKETS_NEW,n.lazy(()=>Promise.resolve().then(()=>require("./CreateSupportTicketPage-AVTwXbJd.js")).then(t=>({default:t.CreateSupportTicketPage}))));O.register(_.MY_TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./MyTicketsPage-BvZeiTXu.js")).then(t=>({default:t.MyTicketsPage}))));O.register(_.MY_TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserTicketDetailPage-ZH2BDWBt.js")).then(t=>({default:t.UserTicketDetailPage}))));O.register(_.MY_TICKETS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./UserCreateTicketPage-ChQL1mVY.js")).then(t=>({default:t.UserCreateTicketPage}))));O.register(_.SUPPORT_SLA,n.lazy(()=>Promise.resolve().then(()=>require("./SlaConfigPage-DZ4P1FFW.js")).then(t=>({default:t.SlaConfigPage}))));O.register(_.SUPPORT_TEMPLATES,n.lazy(()=>Promise.resolve().then(()=>require("./TemplatesPage-m5-sLJ7F.js")).then(t=>({default:t.TemplatesPage}))));O.register(_.SUPPORT_PERMISSIONS,n.lazy(()=>Promise.resolve().then(()=>require("./SupportPermissionsPage-DW7KJjYK.js")).then(t=>({default:t.SupportPermissionsPage}))));O.register(_.SUPPORT_ASSIGNMENT,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentRulesPage-DFsO4ZES.js")).then(t=>({default:t.AssignmentRulesPage}))));O.register(_.SUPPORT_ASSIGNMENT_SKILLS,n.lazy(()=>Promise.resolve().then(()=>require("./AgentSkillsPage-ABpqnnyK.js")).then(t=>({default:t.AgentSkillsPage}))));O.register(_.SUPPORT_ASSIGNMENT_WORKLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./AgentWorkloadPage-BltzNlXI.js")).then(t=>({default:t.AgentWorkloadPage}))));O.register(_.MYSPACE_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./UserDashboardPage-81-3GJAQ.js")).then(t=>({default:t.UserDashboardPage}))));O.register(_.USER_PROFILE,n.lazy(()=>Promise.resolve().then(()=>require("./ProfilePage-C5QS7tsh.js")).then(t=>({default:t.ProfilePage}))));O.register(_.USER_PREFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./PreferencesPage-Bu4gaDRb.js")).then(t=>({default:t.PreferencesPage}))));O.register(_.MYSPACE_TENANTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyTenantsPage-Bbn4HxN2.js")).then(t=>({default:t.MyTenantsPage}))));O.register(_.MYSPACE_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyAccessRequestsPage-BAX0xwJX.js"))));O.register(_.MYSPACE_PORTAL,n.lazy(()=>Promise.resolve().then(()=>require("./PortalDashboardPage-CQWEcghD.js")).then(t=>({default:t.PortalDashboardPage}))));O.register(_.NOTIFICATIONS,n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-BCnL9oPb.js")).then(t=>({default:t.NotificationsPage}))));O.register(_.APPLICATIONS_HUB,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-DBq7_Sm8.js")).then(t=>({default:t.ApplicationsPage}))));const uo=n.createContext(null);function mo({config:t,children:s}){typeof window<"u"&&(window.__SMARTSTACK_CONFIG__=t);const r=n.useMemo(()=>({config:t}),[t]);return e.jsx(uo.Provider,{value:r,children:e.jsx(zr,{children:e.jsx(Xr,{config:t.extensions,children:e.jsx(vr,{children:e.jsx(qn,{children:e.jsx(wr,{children:e.jsx(Bn,{children:e.jsx(kr,{children:e.jsx(Tr,{children:e.jsx(Ir,{children:e.jsx(qr,{children:e.jsx(Xn,{children:e.jsx(gs,{children:e.jsx(Mr,{children:s})})})})})})})})})})})})})})}const Yr="smartstack-doc-panel-size",Jr=n.createContext(void 0);function po(){if(typeof window>"u")return 33;try{const t=localStorage.getItem(Yr);if(t){const s=parseFloat(t);if(s>=20&&s<=60)return s}}catch{}return 33}const Es={"administration/users":"/docs/business/administration/users","administration/users/dashboard":"/docs/business/administration/users","administration/users/list":"/docs/business/administration/users","administration/users/create":"/docs/business/administration/users","administration/users/groups":"/docs/business/administration/users/groups","administration/users/references":"/docs/business/administration/users/references","administration/permissions":"/docs/business/administration/permissions","administration/permissions/roles":"/docs/business/administration/permissions","administration/permissions/permissions":"/docs/business/administration/permissions","administration/permissions/assignments":"/docs/business/administration/permissions/assignments","administration/applications":"/docs/business/administration/applications","administration/applications/list":"/docs/business/administration/applications","administration/applications/grid":"/docs/business/administration/applications","administration/applications/dashboard":"/docs/business/administration/applications","administration/tenants":"/docs/business/administration/tenants","administration/tenants/dashboard":"/docs/business/administration/tenants","administration/tenants/create":"/docs/business/administration/tenants","administration/tenants/list":"/docs/business/administration/tenants/business","administration/tenants/list/enterprise":"/docs/business/administration/tenants/business","administration/tenants/list/personal":"/docs/business/administration/tenants/personal","administration/tenants/list/other":"/docs/business/administration/tenants/other","administration/tenants/template":"/docs/business/administration/tenants/template","administration/tenants/business":"/docs/business/administration/tenants/business","administration/tenants/personal":"/docs/business/administration/tenants","administration/tenants/organisations":"/docs/business/administration/tenants/organisations","administration/tenants/organisations/create":"/docs/business/administration/tenants/organisations","administration/tenants/access-requests":"/docs/business/administration/tenants/access-requests","administration/tenants/applications":"/docs/business/administration/tenants/applications","administration/workflows":"/docs/business/administration/workflows","administration/workflows/list":"/docs/business/administration/workflows","administration/workflows/create":"/docs/business/administration/workflows","administration/workflows/triggers":"/docs/business/administration/workflows","administration/workflows/history":"/docs/business/administration/workflows","administration/workflows/email-templates":"/docs/business/administration/workflows","administration/workflows/email-templates/email":"/docs/business/administration/workflows","administration/workflows/email-templates/sms":"/docs/business/administration/workflows","administration/workflows/email-templates/create":"/docs/business/administration/workflows","administration/ai":"/docs/business/administration/ai","administration/ai/dashboard":"/docs/business/administration/ai","administration/ai/settings":"/docs/business/administration/ai","administration/ai/providers":"/docs/business/administration/ai","administration/ai/models":"/docs/business/administration/ai","administration/ai/prompts":"/docs/business/administration/ai","administration/ai/blocks":"/docs/business/administration/ai","administration/entra":"/docs/business/administration/entra","administration/entra/dashboard":"/docs/business/administration/entra","administration/entra/groups":"/docs/business/administration/entra","administration/entra/users":"/docs/business/administration/entra","administration/entra/conflicts":"/docs/business/administration/entra","administration/entra/settings":"/docs/business/administration/entra","administration/configuration":"/docs/business/administration/configuration","administration/configuration/settings":"/docs/business/administration/configuration","administration/configuration/appsettings":"/docs/business/administration/configuration","administration/configuration/license":"/docs/business/administration/configuration/license","support/tickets":"/system/docs/user/support-dashboard","support/tickets/list":"/docs/business/platform/support/tickets","support/tickets/escalation":"/system/docs/user/support-escalation","support/my-tickets":"/docs/business/platform/support/tickets","support/my-tickets/list":"/docs/business/platform/support/tickets","support/my-tickets/create":"/docs/business/platform/support/tickets","support/admin/sla":"/system/docs/user/support-sla","support/admin/templates":"/system/docs/user/support-templates","myspace/profile":"/system/docs/user/modules","myspace/preferences":"/system/docs/user/modules","myspace/tenants":"/system/docs/user/modules","myspace/portal":"/system/docs/user/modules"},Is={administration:"/docs/business/administration/users",support:"/system/docs/user/support-dashboard",myspace:"/system/docs/user/modules"};function Ls(t){const s=t.split("/").filter(Boolean),a=s[0]==="t"&&s.length>=3?2:0,o=s.slice(a),c=o[0],i=o.slice(1);if(i.length>0)for(let d=i.length;d>0;d--){const u=`${c}/${i.slice(0,d).join("/")}`;if(Es[u])return Es[u]}return c&&Is[c]?Is[c]:"/system/docs/user"}function Qr({children:t}){const[s,r]=n.useState(!1),[a,o]=n.useState(po),[c,i]=n.useState(null),d=w.useLocation(),u=n.useRef(d.pathname);n.useEffect(()=>{u.current!==d.pathname&&(u.current=d.pathname,r(!1))},[d.pathname]),n.useEffect(()=>{a>=20&&a<=60&&localStorage.setItem(Yr,String(a))},[a]);const m=n.useCallback(b=>{const h=b||Ls(d.pathname);i(h),r(!0)},[d.pathname]),p=n.useCallback(()=>{r(!1)},[]),g=n.useCallback(()=>{if(s)r(!1);else{const b=Ls(d.pathname);i(b),r(!0)}},[s,d.pathname]),f=n.useCallback(b=>{b>=20&&b<=60&&o(b)},[]);return e.jsx(Jr.Provider,{value:{isOpen:s,panelSize:a,docUrl:c,openDocPanel:m,closeDocPanel:p,toggleDocPanel:g,setPanelSize:f},children:t})}function Gt(){const t=n.useContext(Jr);if(t===void 0)throw new Error("useDocPanel must be used within a DocPanelProvider");return t}class xo{captureBrowserInfo(){const s=navigator.userAgent;return{browser:this.getBrowserName(s),browserVersion:this.getBrowserVersion(s),os:this.getOSName(s),osVersion:this.getOSVersion(s),language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`,deviceType:this.getDeviceType(s)}}getBrowserName(s){return s.includes("Firefox")?"Firefox":s.includes("Edg/")?"Microsoft Edge":s.includes("Chrome")&&!s.includes("Edg/")?"Google Chrome":s.includes("Safari")&&!s.includes("Chrome")?"Safari":s.includes("Opera")||s.includes("OPR/")?"Opera":s.includes("MSIE")||s.includes("Trident/")?"Internet Explorer":"Unknown Browser"}getBrowserVersion(s){let r=null;return s.includes("Firefox")?r=/Firefox\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Edg/")?r=/Edg\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Chrome")&&!s.includes("Edg/")?r=/Chrome\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Safari")&&!s.includes("Chrome")?r=/Version\/(\d+(?:\.\d+)*)/.exec(s):s.includes("OPR/")&&(r=/OPR\/(\d+(?:\.\d+)*)/.exec(s)),r?r[1]:"Unknown"}getOSName(s){return s.includes("Windows NT 10")?"Windows 10/11":s.includes("Windows NT 6.3")?"Windows 8.1":s.includes("Windows NT 6.2")?"Windows 8":s.includes("Windows NT 6.1")?"Windows 7":s.includes("Windows")?"Windows":s.includes("Mac OS X")?"macOS":s.includes("Linux")&&s.includes("Android")?"Android":s.includes("Linux")?"Linux":s.includes("iPhone")||s.includes("iPad")?"iOS":s.includes("CrOS")?"Chrome OS":"Unknown OS"}getWindowsVersion(s){return s==="10.0"?"10/11":s==="6.3"?"8.1":s==="6.2"?"8":s==="6.1"?"7":s}getOSVersion(s){if(s.includes("Windows NT")){const r=/Windows NT (\d+\.\d+)/.exec(s);if(r)return this.getWindowsVersion(r[1])}if(s.includes("Mac OS X")){const r=/Mac OS X (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}if(s.includes("Android")){const r=/Android (\d+(?:\.\d+)*)/.exec(s);if(r)return r[1]}if(s.includes("iPhone OS")||s.includes("iPad")){const r=/(?:iPhone|iPad|CPU) OS (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}return"Unknown"}getDeviceType(s){return/Tablet|iPad/i.test(s)?"Tablet":/Mobile|iPhone|Android.*Mobile/i.test(s)?"Mobile":"Desktop"}formatForDescription(s){return[`Browser: ${s.browser} ${s.browserVersion}`,`OS: ${s.os} ${s.osVersion}`,`Device: ${s.deviceType}`,`Screen: ${s.screenResolution}`,`Language: ${s.language}`].join(`
2
- `)}}const Zr=new xo;function ho(){return{captureContext:n.useCallback(()=>{const s=Zr.captureBrowserInfo(),r=Te.getRecentErrors().slice(0,5);return{sourceUrl:window.location.href,browser:{name:s.browser,version:s.browserVersion,language:s.language},os:{name:s.os,version:s.osVersion},device:{type:s.deviceType,screenResolution:s.screenResolution},recentErrors:r.map(a=>({message:a.message,stack:a.stack,component:a.component,timestamp:a.timestamp.toISOString()}))}},[])}}function go(){const[t,s]=n.useState(new Set),[r,a]=n.useState(new Set),o=n.useCallback(p=>{s(g=>{const f=new Set(g);return f.has(p)?f.delete(p):f.add(p),f})},[]),c=n.useCallback(p=>{a(g=>{const f=new Set(g);return f.has(p)?f.delete(p):f.add(p),f})},[]),i=n.useCallback(()=>{s(new Set),a(new Set)},[]),d=n.useCallback((p,g)=>{s(new Set(p)),a(new Set(g))},[]),u=n.useCallback(p=>t.has(p),[t]),m=n.useCallback(p=>r.has(p),[r]);return{collapsedContexts:t,collapsedApps:r,toggleContext:o,toggleApp:c,expandAll:i,collapseAll:d,isContextCollapsed:u,isAppCollapsed:m}}const fs="/api/myspace/application-tracking",fo="00000000-0000-0000-0000-000000000000",$s=t=>!!t&&t!==fo,ea=t=>{const s=/^\/t\/[^/]+(\/.*)$/.exec(t);return s?s[1]:t},bo=t=>{const s=ea(t);return s.startsWith("/administration/")||s.startsWith("/support/")||s.startsWith("/myspace/")},ta=(t,s)=>{if(!t||typeof t!="object"||!("status"in t))return!0;const r=t.status;return!s.includes(r??-1)},vo=async(t,s)=>{const r=new Date,a=Math.floor((r.getTime()-s.getTime())/1e3);try{await E.post(`${fs}/end`,{accessId:t,endedAt:r.toISOString(),durationSeconds:a})}catch(o){ta(o,[401,408])&&console.error("Failed to end page tracking:",o)}},yo=async t=>{const s=new Date;try{return(await E.post(`${fs}/start`,{route:t,accessedAt:s.toISOString()})).accessId}catch(r){return ta(r,[401])&&console.error("Failed to track page access:",r),null}},jo=(t,s)=>{const r=localStorage.getItem("token");if(!r)return;const a=new Date,o=Math.floor((a.getTime()-s.getTime())/1e3);fetch(`${fs}/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({accessId:t,endedAt:a.toISOString(),durationSeconds:o}),keepalive:!0}).catch(()=>{})};function sa(){const t=w.useLocation(),s=n.useRef(new Date),r=n.useRef(null),a=n.useRef(!1);n.useEffect(()=>a.current?void 0:((async()=>{const c=ea(t.pathname);bo(c)&&(a.current=!0,$s(r.current)&&await vo(r.current,s.current),s.current=new Date,r.current=await yo(c),a.current=!1)})(),()=>{$s(r.current)&&jo(r.current,s.current)}),[t.pathname])}function No(t={}){const{canEditSystemRoles:s=!1}=t,{t:r,i18n:a}=ne.useTranslation("admin"),[o,c]=n.useState(!0),[i,d]=n.useState(null),[u,m]=n.useState(null),[p,g]=n.useState(!1),[f,b]=n.useState(!1),[h,y]=n.useState([]),[x,j]=n.useState([]),[v,S]=n.useState(new Map),[N,I]=n.useState({}),[P,k]=n.useState({}),[A,R]=n.useState({}),[$,q]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all",categoryFilter:"all"}),C=n.useRef(null),D=n.useRef(new Map),Y=n.useCallback((U,W,ee)=>{const te=U.has(ee),se=W.get(ee);if(!se)return{isDirect:te,isInherited:!1};const me=se.path.toLowerCase();let ie,ve,be=1/0;for(const Me of Array.from(U)){const Le=W.get(Me);if(!Le||Me===ee)continue;const ze=Le.path.toLowerCase();if((Le.isWildcard||ze.endsWith(".*"))&&Ct(ze,me)){const We=ze.split(".").length;We<be&&(be=We,ie=Le.path,ve=Le.id)}}return{isDirect:te,isInherited:ie!==void 0,inheritedFromPath:ie,inheritedFromId:ve}},[]),T=n.useCallback((U,W)=>{const ee={};return Object.entries(U).forEach(([te,se])=>{const me=new Map;W.forEach((ie,ve)=>{const be=Y(se,W,ve);me.set(ve,be)}),ee[te]=me}),ee},[Y]),z=(U,W,ee,te)=>{const se=[],me=[];return U.resources.forEach(ie=>{const ve=ie.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),be=te.get(ve)||[],Ie={id:ie.id,path:ie.permissionPath,label:ie.label,applicationLabel:ee.label,moduleLabel:ie.label,parentModuleLabel:W.label,parentModuleId:W.id,parentSectionLabel:U.label,parentSectionId:U.id,level:"resource",permissions:be,totalPermissions:be.length};se.push(Ie),me.push(Ie)}),{childResources:se,nodes:me}},Z=(U,W,ee)=>{const te=[],se=[];return U.sections.forEach(me=>{const ie=me.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),ve=ee.get(ie)||[],{childResources:be,nodes:Ie}=z(me,U,W,ee),Me=be.reduce((et,We)=>et+We.totalPermissions,0),Le=ve.length+Me,ze={id:me.id,path:me.permissionPath,label:me.label,applicationLabel:W.label,moduleLabel:me.label,parentModuleLabel:U.label,parentModuleId:U.id,level:"section",permissions:ve,totalPermissions:Le,childResources:be.length>0?be:void 0};te.push(ze),se.push(ze),se.push(...Ie)}),{childSections:te,nodes:se}},H=(U,W,ee,te)=>{const se=U.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),me=ee.get(se)||[],{childSections:ie,nodes:ve}=Z(U,W,ee),be=ie.reduce((Me,Le)=>Me+Le.totalPermissions,0),Ie=me.length+be;te.push({id:U.id,path:U.permissionPath,label:U.label,applicationLabel:W.label,moduleLabel:U.label,level:"module",permissions:me,totalPermissions:Ie,childSections:ie.length>0?ie:void 0}),te.push(...ve)},J=(U,W,ee)=>{U.modules.forEach(te=>{H(te,U,W,ee)})},fe=n.useCallback((U,W)=>{const ee=[];if(!U||!U.applications||!W||!Array.isArray(W))return ee;const te=new Map;return W.forEach(se=>{const ie=se.path.toLowerCase().split(".");if(ie.length>=2){const ve=ie.slice(0,-1).join("."),be=te.get(ve)||[];be.push({id:se.id,action:ie.at(-1),path:se.path}),te.set(ve,be)}}),U.applications.forEach(se=>{J(se,te,ee)}),ee.sort((se,me)=>{const ie=se.applicationLabel.localeCompare(me.applicationLabel);return ie!==0?ie:se.moduleLabel.localeCompare(me.moduleLabel)})},[]),B=n.useCallback(async()=>{try{c(!0),d(null);const U=await Ne.permissions.getMatrix(),W={};U.roles.forEach(ie=>{W[ie.id]=new Set(ie.permissionIds)});const ee=new Map(U.permissions.map(ie=>[ie.id,ie])),te=fe(U.tree,U.permissions),se=T(W,ee);y(U.roles),j(te),S(ee),I(W),R(se);const me=Object.entries(W).reduce((ie,[ve,be])=>(ie[ve]=new Set(Array.from(be)),ie),{});k(me),D.current.clear()}catch(U){d(U instanceof Error?U.message:"Failed to load permission matrix data")}finally{c(!1)}},[fe,T]);n.useEffect(()=>{B()},[B,a.language]),n.useEffect(()=>{if(v.size>0){const U=T(N,v);R(U)}},[N,v,T]);const Q=n.useCallback(async()=>{if(D.current.size===0)return;const U=new Map(D.current);D.current.clear(),g(!0),m(null);try{const W=Array.from(U.entries()).map(async([se,me])=>{const ie=h.find(ve=>ve.id===se);ie&&await Ne.roles.update(se,{name:ie.name,shortName:ie.shortName,category:ie.category,description:ie.description||void 0,permissionIds:Array.from(me)})});await Promise.all(W);const ee=JSON.parse(JSON.stringify(Object.fromEntries(Object.entries(N).map(([se,me])=>[se,Array.from(me)])))),te=Object.entries(ee).reduce((se,[me,ie])=>(se[me]=new Set(ie),se),{});k(te),b(!0),setTimeout(()=>{b(!1)},3e3)}catch(W){console.error("Failed to save permission changes:",W);let ee="Failed to save changes";if(W&&typeof W=="object"&&"response"in W){const te=W.response;te?.status===403?ee=r("assignments.noPermissionToEditRole"):te?.data?.message&&(ee=te.data.message)}else W instanceof Error&&(ee=W.message);m(ee),await B()}finally{g(!1)}},[h,N,B]),M=n.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{Q()},500)},[Q]),re=n.useCallback((U,W)=>{h.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set(te[U]||[]);return se.has(W)?se.delete(W):se.add(W),D.current.set(U,se),M(),{...te,[U]:se}})},[h,s,M]),F=U=>{x.forEach(W=>{W.permissions.forEach(ee=>{U.add(ee.id)})})},K=n.useCallback((U,W)=>{h.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set;return W&&F(se),D.current.set(U,se),M(),{...te,[U]:se}})},[h,s,x,M]),V=(U,W,ee)=>{W.permissions.forEach(te=>{ee?U.add(te.id):U.delete(te.id)})},ae=n.useCallback((U,W)=>{I(ee=>{const te={...ee};return h.forEach(se=>{if(se.isSystem&&!s)return;const me=new Set(te[se.id]||[]);V(me,U,W),te[se.id]=me,D.current.set(se.id,me)}),M(),te})},[h,s,M]),ue=n.useCallback(U=>{q(W=>({...W,...U}))},[]),G=n.useCallback(()=>{const U=Object.entries(P).reduce((W,[ee,te])=>(W[ee]=new Set(Array.from(te)),W),{});I(U),D.current.clear(),C.current&&clearTimeout(C.current)},[P]),ce=n.useMemo(()=>h.filter(U=>$.selectedRoleIds.length===0?!0:$.selectedRoleIds.includes(U.id)),[h,$.selectedRoleIds]),de=n.useMemo(()=>x.filter(U=>!($.resourceSearch&&!U.moduleLabel.toLowerCase().includes($.resourceSearch.toLowerCase())||$.applicationFilter!=="all"&&U.applicationLabel!==$.applicationFilter||$.moduleFilter!=="all"&&U.moduleLabel!==$.moduleFilter)),[x,$]),he=n.useMemo(()=>Array.from(Object.entries(N)).some(([U,W])=>{const ee=P[U];return ee?W.size!==ee.size?!0:Array.from(W).some(te=>!ee.has(te)):W.size>0}),[N,P]),pe=n.useMemo(()=>{const U=new Map;return x.forEach(W=>{U.has(W.applicationLabel)||U.set(W.applicationLabel,{app:W.applicationLabel,label:W.applicationLabel})}),Array.from(U.values()).sort((W,ee)=>W.label.localeCompare(ee.label))},[x]),ye=n.useMemo(()=>x.filter(U=>U.level==="module").map(U=>({app:U.applicationLabel,module:U.label,label:U.label})).sort((U,W)=>U.label.localeCompare(W.label)),[x]),qe=n.useMemo(()=>{const U=new Set(h.map(ee=>ee.category));return["Global","Admin","Manager","Contributor","Viewer","Custom"].filter(ee=>U.has(ee))},[h]),Ue=n.useCallback((U,W)=>{const ee=A[U];return ee?ee.get(W)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[A]),Ve=n.useCallback(()=>{m(null)},[]);return{loading:o,error:i,saveError:u,saving:p,saveSuccess:f,roles:h,resources:x,permissions:v,assignments:N,inheritanceMap:A,filters:$,filteredRoles:ce,filteredResources:de,hasChanges:he,canEditSystemRoles:s,applications:pe,modules:ye,categories:qe,togglePermission:re,toggleAllForRole:K,toggleAllForResource:ae,updateFilters:ue,reloadData:B,resetChanges:G,saveChanges:Q,clearSaveError:Ve,getPermissionInheritance:Ue}}function ra(t={}){const s=n.useRef(null),[r,a]=n.useState(oe.HubConnectionState.Disconnected),o=n.useRef(t);o.current=t;const c=n.useCallback(()=>localStorage.getItem("token"),[]),i=n.useCallback(async()=>{const u=c();if(u&&s.current?.state!==oe.HubConnectionState.Connected)try{const m=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>u}).withAutomaticReconnect({nextRetryDelayInMilliseconds:p=>p.previousRetryCount===0?0:p.previousRetryCount===1?2e3:p.previousRetryCount===2?1e4:p.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();m.on("ReceiveNotification",p=>{o.current.onNotification?.(p)}),m.on("UnreadCountUpdate",p=>{o.current.onUnreadCountUpdate?.(p)}),m.on("PermissionsChanged",()=>{o.current.onPermissionsChanged?.()}),m.onreconnecting(()=>{a(oe.HubConnectionState.Reconnecting),o.current.onConnectionStateChange?.(oe.HubConnectionState.Reconnecting)}),m.onreconnected(()=>{a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}),m.onclose(()=>{a(oe.HubConnectionState.Disconnected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Disconnected)}),await m.start(),s.current=m,a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}catch(m){console.error("SignalR: Failed to connect",m),a(oe.HubConnectionState.Disconnected)}},[c]),d=n.useCallback(async()=>{if(s.current)try{await s.current.stop(),s.current=null,a(oe.HubConnectionState.Disconnected)}catch(u){console.error("SignalR: Failed to disconnect",u)}},[]);return n.useEffect(()=>(i(),()=>{d()}),[i,d]),n.useEffect(()=>{const u=m=>{m.key==="token"&&(m.newValue?i():d())};return window.addEventListener("storage",u),()=>window.removeEventListener("storage",u)},[i,d]),{connectionState:r,isConnected:r===oe.HubConnectionState.Connected,connect:i,disconnect:d}}function wo(){const{refreshPermissions:t,user:s}=Pe(),{refreshMenu:r}=Ce(),a=n.useRef(!1),o=n.useCallback(async()=>{if(!a.current){a.current=!0;try{await Promise.all([t(),r()])}catch(d){console.error("[PermissionSync] Failed to refresh permissions:",d)}finally{a.current=!1}}},[t,r]),{isConnected:c,connectionState:i}=ra({onPermissionsChanged:o});return{isConnected:c,connectionState:i,isAuthenticated:!!s}}function aa(t){const{ticketId:s,onCommentAdded:r,onTicketUpdated:a,onConnectionStateChange:o}=t,c=n.useRef(null),i=n.useRef(null),[d,u]=n.useState(oe.HubConnectionState.Disconnected),m=n.useCallback(()=>localStorage.getItem("token"),[]),p=n.useCallback(async h=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("JoinTicket",h),i.current=h}catch(y){console.error("SignalR: Failed to join ticket group",y)}},[]),g=n.useCallback(async h=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("LeaveTicket",h)}catch(y){console.error("SignalR: Failed to leave ticket group",y)}i.current=null},[]),f=n.useCallback(async()=>{const h=m();if(h){if(c.current?.state===oe.HubConnectionState.Connected)return c.current;try{const y=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>h}).withAutomaticReconnect({nextRetryDelayInMilliseconds:x=>x.previousRetryCount===0?0:x.previousRetryCount===1?2e3:x.previousRetryCount===2?1e4:x.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();return y.on("TicketCommentAdded",x=>{r?.(x)}),y.on("TicketUpdated",x=>{a?.(x)}),y.onreconnecting(()=>{u(oe.HubConnectionState.Reconnecting),o?.(oe.HubConnectionState.Reconnecting)}),y.onreconnected(async()=>{u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),i.current&&await p(i.current)}),y.onclose(()=>{u(oe.HubConnectionState.Disconnected),o?.(oe.HubConnectionState.Disconnected)}),await y.start(),c.current=y,u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),y}catch(y){return console.error("SignalR: Failed to connect",y),u(oe.HubConnectionState.Disconnected),null}}},[m,p,r,a,o]),b=n.useCallback(async()=>{if(i.current&&await g(i.current),c.current)try{await c.current.stop(),c.current=null,u(oe.HubConnectionState.Disconnected)}catch(h){console.error("SignalR: Failed to disconnect",h)}},[g]);return n.useEffect(()=>{let h=!0;return(async()=>(await f(),h&&s&&await p(s)))(),()=>{h=!1,b()}},[f,b,s,p]),n.useEffect(()=>{const h=async()=>{i.current&&i.current!==s&&await g(i.current),s&&s!==i.current&&await p(s)};c.current?.state===oe.HubConnectionState.Connected&&h()},[s,p,g]),{connectionState:d,isConnected:d===oe.HubConnectionState.Connected,joinTicket:p,leaveTicket:g}}function So(t,s,r,a){const o=[];for(const c of a.resources)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"resource",applicationCode:t});return o}function Co(t,s,r,a){const o=[];for(const c of a.sections)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"section",applicationCode:t}),o.push(...So(t,s,r,c));return o}function ko(t,s,r){const a=[];for(const o of r.modules)o.route&&a.push({componentKey:o.componentKey,permissionPath:o.permissionPath,route:o.route,hasComponent:O.has(o.componentKey),requiredFeature:o.requiredFeature,isOpen:s,level:"module",applicationCode:t}),a.push(...Co(t,s,o.requiredFeature,o));return a}function Ao(t){const s=[];for(const r of t)r.route&&s.push({componentKey:r.componentKey,permissionPath:r.permissionPath,route:r.route,hasComponent:O.has(r.componentKey),requiredFeature:r.requiredFeature,isOpen:r.isOpen,level:"application",applicationCode:r.code}),s.push(...ko(r.code,r.isOpen,r));return s}function Po(){const{menu:t,isLoading:s}=Ce();return n.useMemo(()=>{if(!t||s)return{entries:[],byKey:new Map,isLoading:!0,byApplication:new Map};const r=Ao(t.applications),a=new Map(r.map(c=>[c.componentKey,c])),o=new Map;for(const c of r){const i=o.get(c.applicationCode)||[];i.push(c),o.set(c.applicationCode,i)}return{entries:r,byKey:a,isLoading:!1,byApplication:o}},[t,s])}const To=(t,s,r)=>{const a=t.has(r),o=s.get(r);if(!o)return{isDirect:a,isInherited:!1};const c=o.path;let i,d,u=1/0;for(const p of Array.from(t)){const g=s.get(p);if(!(!g||!g.isWildcard||p===r)&&Ct(g.path,c)){const f=g.path.split(".").length;f<u&&(u=f,i=g.path,d=g.id)}}return{isDirect:a,isInherited:i!==void 0,inheritedFromPath:i,inheritedFromId:d}},Ds=(t,s)=>{const r={};return Object.entries(t).forEach(([a,o])=>{const c=new Map;s.forEach((i,d)=>{const u=To(o,s,d);c.set(d,u)}),r[a]=c}),r},Ro=t=>{const s=new Map;return t.forEach(r=>{const o=r.path.toLowerCase().split(".");if(o.length>=2){const c=o.slice(0,-1).join("."),i=s.get(c)||[];i.push({id:r.id,action:o.at(-1),path:r.path}),s.set(c,i)}}),s},Ht=(t,s)=>{const r=s.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,"");return t.get(r)||[]};function na(t){const{entityId:s,tenantId:r,loadEntity:a,loadRoles:o}=t,{i18n:c}=ne.useTranslation(),[i,d]=n.useState(!0),[u,m]=n.useState(null),[p,g]=n.useState(null),[f,b]=n.useState([]),[h,y]=n.useState([]),[x,j]=n.useState(new Map),[v,S]=n.useState({}),[N,I]=n.useState({}),[P,k]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all"}),A=!!r,R=n.useCallback((F,K,V,ae)=>{const ue=Ht(ae,K.permissionPath);F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:V.label,moduleLabel:K.label,level:"module",permissions:ue,totalPermissions:ue.length})},[]),$=n.useCallback((F,K,V,ae,ue)=>{const G=Ht(ue,K.permissionPath);K.resources.forEach(ce=>{const de=Ht(ue,ce.permissionPath);F.push({id:ce.id,path:ce.permissionPath,label:ce.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,parentSectionLabel:K.label,parentSectionId:K.id,level:"resource",permissions:de,totalPermissions:de.length})}),F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,level:"section",permissions:G,totalPermissions:G.length})},[]),q=n.useCallback((F,K,V,ae)=>{R(ae,F,K,V),F.sections.forEach(ue=>{$(ae,ue,F,K,V)})},[R,$]),C=n.useCallback((F,K,V)=>{F.modules.forEach(ae=>{q(ae,F,K,V)})},[q]),D=n.useCallback((F,K)=>{if(!F?.applications||!Array.isArray(K))return[];const V=Ro(K),ae=[];return F.applications.forEach(ue=>{C(ue,V,ae)}),ae.sort((ue,G)=>{const ce=ue.applicationLabel.localeCompare(G.applicationLabel);return ce!==0?ce:ue.moduleLabel.localeCompare(G.moduleLabel)})},[C]),Y=n.useCallback(async()=>{try{d(!0),m(null);const[F,K,V]=await Promise.all([a(s),o(s,r),Ne.permissions.getMatrix()]);g(F),b(K);const ae=new Set(K.map(pe=>pe.id)),ue=V.roles.filter(pe=>ae.has(pe.id)),G={};ue.forEach(pe=>{G[pe.id]=new Set(pe.permissionIds)});const ce=new Map(V.permissions.map(pe=>[pe.id,pe])),de=D(V.tree,V.permissions),he=Ds(G,ce);y(de),j(ce),S(G),I(he)}catch(F){m(F instanceof Error?F.message:"Failed to load permissions data")}finally{d(!1)}},[s,r,a,o,D]);n.useEffect(()=>{Y()},[Y,c.language]),n.useEffect(()=>{if(x.size>0){const F=Ds(v,x);I(F)}},[v,x]);const T=n.useMemo(()=>{const F=new Set;return Object.entries(N).forEach(([K,V])=>{V.forEach((ae,ue)=>{(ae.isDirect||ae.isInherited)&&F.add(ue)})}),F},[N]),z=F=>P.resourceSearch?F.label.toLowerCase().includes(P.resourceSearch.toLowerCase()):!0,Z=F=>P.applicationFilter==="all"?!0:F.applicationLabel===P.applicationFilter,H=F=>P.moduleFilter==="all"?!0:F.level==="module"?F.label===P.moduleFilter:F.parentModuleLabel===P.moduleFilter,J=n.useMemo(()=>h.filter(F=>z(F)&&Z(F)&&H(F)),[h,P]),fe=n.useMemo(()=>{const F=new Map;return h.forEach(K=>{F.has(K.applicationLabel)||F.set(K.applicationLabel,{app:K.applicationLabel,label:K.applicationLabel})}),Array.from(F.values()).sort((K,V)=>K.label.localeCompare(V.label))},[h]),B=n.useMemo(()=>h.filter(F=>F.level==="module").map(F=>({app:F.applicationLabel,module:F.label,label:F.label})).sort((F,K)=>F.label.localeCompare(K.label)),[h]),Q=n.useCallback(F=>{k(K=>({...K,...F}))},[]),M=n.useCallback((F,K)=>{const V=N[F];return V?V.get(K)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[N]),re=n.useCallback(F=>{const K=[];return f.forEach(V=>{const ae=N[V.id];if(ae){const ue=ae.get(F);ue&&(ue.isDirect||ue.isInherited)&&K.push(V)}}),K},[f,N]);return{loading:i,error:u,entity:p,roles:f,resources:h,assignments:v,inheritanceMap:N,effectivePermissions:T,filters:P,filteredResources:J,applications:fe,modules:B,updateFilters:Q,getPermissionInheritance:M,getPermissionSources:re,reloadData:Y,isTenantMode:A}}function Eo(t){const{userId:s,tenantId:r}=t,[a,o]=n.useState(null),[c,i]=n.useState([]),d=!!r,u=n.useCallback(async y=>Ne.users.getById(y),[]),m=n.useCallback(async(y,x)=>{const j=await Ne.users.getById(y);let v=[];try{const N=await Ne.users.getConsolidatedRoles(y,x);if(i(N),v=N.map(I=>({id:I.roleId,name:I.roleName,shortName:I.roleShortName||I.roleName,category:"Custom",description:null})),x)try{const P=(await Ne.tenants.getMembers(x)).find(k=>k.userId===y);o(P||null)}catch{o(null)}else o(null)}catch{i([]),o(null),v=j.roles}return Array.from(new Map(v.map(N=>[N.id,N])).values())},[]),p=na({entityId:s,tenantId:r,loadEntity:u,loadRoles:m}),g=p.entity,f=p.roles,b=n.useCallback(y=>{const x=[];return f.forEach(j=>{const v=p.inheritanceMap[j.id];if(v){const S=v.get(y);S&&(S.isDirect||S.isInherited)&&x.push(j)}}),x},[f,p.inheritanceMap]),h=n.useCallback(async y=>{if(!d||!r||!a)throw new Error("Cannot assign tenant roles: not in tenant mode or no tenant member found");await Ne.tenants.assignMemberRoles(r,a.userId,y),await p.reloadData()},[d,r,a,p]);return{loading:p.loading,error:p.error,user:g,userRoles:f,resources:p.resources,assignments:p.assignments,inheritanceMap:p.inheritanceMap,effectivePermissions:p.effectivePermissions,filters:p.filters,filteredResources:p.filteredResources,applications:p.applications,modules:p.modules,updateFilters:p.updateFilters,getPermissionInheritance:p.getPermissionInheritance,getPermissionSources:b,reloadData:p.reloadData,isTenantMode:d,tenantMember:a,assignTenantRoles:h,consolidatedRoles:c}}function Kt(){const{mode:t,toggleMode:s}=St(),a=(t==="dark"?"dark":"light")==="light";return e.jsx("button",{onClick:s,className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300 group",style:{borderRadius:"var(--radius-button)"},"aria-label":`Basculer vers le mode ${a?"sombre":"clair"}`,children:e.jsxs("div",{className:"relative w-6 h-6",children:[e.jsx(l.Sun,{className:`absolute inset-0 w-6 h-6 text-amber-500 transition-all duration-300 ${a?"opacity-100 rotate-0 scale-100":"opacity-0 rotate-90 scale-0"}`}),e.jsx(l.Moon,{className:`absolute inset-0 w-6 h-6 text-[var(--color-accent-400)] transition-all duration-300 ${a?"opacity-0 -rotate-90 scale-0":"opacity-100 rotate-0 scale-100"}`})]})})}const Vt=[{code:"en",label:"English",short:"EN"},{code:"fr",label:"Français",short:"FR"},{code:"de",label:"Deutsch",short:"DE"},{code:"it",label:"Italiano",short:"IT"}];function bs(){const{i18n:t}=ne.useTranslation(),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1),o=n.useRef(null),c=t.language?.split("-")[0]||"en",i=Vt.find(u=>u.code===c)||Vt[0],d=async u=>{if(await xs(u),document.documentElement.lang=u,a(!1),s)try{await _t.preferences.updateLanguage({language:u})}catch{}};return n.useEffect(()=>{const u=m=>{o.current&&!o.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),e.jsxs("div",{ref:o,className:"relative",children:[e.jsx("button",{onClick:()=>a(!r),className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300",style:{borderRadius:"var(--radius-button)"},"aria-label":"Change language",children:e.jsx("span",{className:"flex items-center justify-center w-6 h-6 text-xs font-bold text-[var(--text-secondary)]",children:i.short})}),r&&e.jsx("div",{className:"absolute right-0 mt-2 py-1 bg-[var(--bg-tertiary)] border border-[var(--border-color)] shadow-lg shadow-[var(--shadow-color)] z-50 overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:Vt.map(u=>{const m=u.code===c;return e.jsxs("button",{onClick:()=>d(u.code),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors whitespace-nowrap ${m?"bg-primary-600/10 text-primary-500":"text-[var(--text-secondary)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-primary)]"}`,children:[e.jsx("span",{className:"text-xs font-bold w-6",children:u.short}),e.jsx("span",{className:"text-sm font-medium",children:u.label}),m&&e.jsx(l.Check,{className:"w-4 h-4 ml-auto text-primary-500"})]},u.code)})})]})}function Io(t,s){if(!s.useUrlRouting||!s.slug)return dt(t);if(t.startsWith(`/t/${s.slug}`))return t;const r=dt(t);return`/t/${s.slug}${r}`}function Ms(t){const s=/^\/t\/([^/]+)/.exec(t);return s?s[1]:null}function dt(t){return t.replace(/^\/t\/[^/]+/,"")||"/"}function Ze(){const{currentTenant:t}=Ee(),{useUrlRouting:s}=qt();return n.useCallback(r=>Io(r,{slug:t?.slug,useUrlRouting:s}),[t?.slug,s])}const Os={background:"linear-gradient(to bottom right, var(--color-accent-500), var(--color-accent-600))"};function oa(){const{t}=ne.useTranslation("navigation"),{user:s,logout:r}=Pe(),{refreshMenu:a}=Ce(),{refreshTenants:o}=Ee(),c=w.useLocation(),i=w.useNavigate(),d=Ze(),[u,m]=n.useState(!1),[p,g]=n.useState(!1),f=n.useRef(null),b=async()=>{g(!0);try{await E.post("/api/navigation/invalidate-cache").catch(()=>{}),await Promise.all([a(),o()])}catch(j){console.error("Failed to refresh cache:",j)}finally{g(!1),m(!1)}},h=j=>{const v=d(j);c.pathname!==v&&i(v),m(!1)};n.useEffect(()=>{function j(v){f.current&&!f.current.contains(v.target)&&m(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),n.useEffect(()=>{function j(v){v.key==="Escape"&&m(!1)}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);const y=()=>{if(!s)return"?";const j=s.firstName?.[0]||"",v=s.lastName?.[0]||"";return(j+v).toUpperCase()||s.email.at(0)?.toUpperCase()||"?"},x=()=>s?s.firstName||s.lastName?`${s.firstName||""} ${s.lastName||""}`.trim():s.email.split("@")[0]:"";return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 p-1.5 pr-3 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-200 group",style:{borderRadius:"var(--radius-button)"},"aria-expanded":u,"aria-haspopup":"true",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm font-medium shadow-sm",style:Os,children:y()}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform duration-200 ${u?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute right-0 mt-2 w-72 origin-top-right transition-all duration-200 ease-out ${u?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-4 bg-gradient-to-br from-[var(--bg-secondary)] to-[var(--bg-tertiary)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center text-white text-lg font-semibold shadow-lg",style:Os,children:y()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[var(--text-primary)] truncate",children:x()}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate",children:s?.email})]})]})}),e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>h("/applications"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.LayoutGrid,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.applications")})]}),e.jsxs("button",{onClick:()=>h("/myspace"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.User,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.mySpace")})]})]})}),e.jsx("div",{className:"p-2",children:e.jsxs("button",{onClick:b,disabled:p,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.RefreshCw,{className:`w-4 h-4 ${p?"animate-spin":""}`})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.refreshCache")})]})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>{m(!1),r()},className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-red-500/10 transition-colors group",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] group-hover:bg-red-500/20 flex items-center justify-center text-[var(--text-secondary)] group-hover:text-red-500 transition-colors",children:e.jsx(l.LogOut,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)] group-hover:text-red-500 transition-colors",children:t("avatarMenu.logout")})]})})]})})]})}const Lo={settings:l.Settings,users:l.Users,key:l.Key,briefcase:l.Briefcase,folder:l.FolderOpen,file:l.FileText,box:l.Box};function $o(t){return t&&Lo[t.toLowerCase()]||l.Box}function Fs({app:t,isFavorite:s,showFavorite:r,onToggleFavorite:a,onSelect:o}){const c=$o(t.icon);return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{onClick:o,className:"w-full flex flex-col items-center gap-2 p-3 hover:bg-[var(--bg-tertiary)] transition-all duration-200",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-[var(--color-accent-500)]/20 to-[var(--color-accent-600)]/20 flex items-center justify-center group-hover:from-[var(--color-accent-500)]/30 group-hover:to-[var(--color-accent-600)]/30 transition-all",style:{borderRadius:"var(--radius-card)"},children:e.jsx(c,{className:"w-6 h-6 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-primary)] text-center line-clamp-2",children:t.label})]}),r&&e.jsx("button",{onClick:i=>{i.stopPropagation(),a()},className:`absolute top-1 right-1 p-1.5 transition-all duration-200 ${s?"text-amber-500 bg-amber-500/10":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-secondary)]"}`,style:{borderRadius:"var(--radius-button)"},title:s?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${s?"fill-current":""}`})})]})}function ia(){const{t}=ne.useTranslation("navigation"),{favorites:s,menu:r,toggleFavorite:a,isFavorite:o}=Ce(),{currentTenant:c}=Ee(),[i,d]=n.useState(!1),u=n.useRef(null),m=w.useNavigate(),p=Ze(),g=!!c,f=r?.applications||[];n.useEffect(()=>{function h(y){u.current&&!u.current.contains(y.target)&&d(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),n.useEffect(()=>{function h(y){y.key==="Escape"&&d(!1)}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const b=h=>{d(!1),h.route&&m(p(h.route))};return e.jsxs("div",{ref:u,className:"relative",children:[e.jsx("button",{onClick:()=>d(!i),className:"p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},"aria-expanded":i,"aria-haspopup":"true",title:t("appSwitcher.title","Applications"),children:e.jsx(l.LayoutGrid,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`absolute right-0 mt-2 w-80 origin-top-right transition-all duration-200 ease-out ${i?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[s.length>0&&e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500 fill-amber-500"}),t("appSwitcher.favorites","Favoris")]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2",children:s.slice(0,6).map(h=>e.jsx(Fs,{app:h,isFavorite:!0,showFavorite:g,onToggleFavorite:()=>a(h.id),onSelect:()=>{d(!1),h.route&&m(p(h.route))}},h.id))})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider",children:t("appSwitcher.allApps","Toutes les applications")}),f.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2 max-h-64 overflow-y-auto",children:f.map(h=>e.jsx(Fs,{app:h,isFavorite:o(h.id),showFavorite:g,onToggleFavorite:()=>a(h.id),onSelect:()=>b(h)},h.id))}):e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-6",children:t("appSwitcher.noApps","Aucune application disponible")})]})]})})]})}function Do(){const[t,s]=n.useState([]),r=n.useCallback(async()=>{try{const c=await Ne.myTenants.getFavorites();s(c)}catch{}},[]),a=n.useCallback(async c=>{const i=t.includes(c);try{if(i){const d=await Ne.myTenants.removeFavorite(c);s(d)}else{const d=await Ne.myTenants.addFavorite(c);s(d)}}catch(d){console.error("Failed to toggle favorite:",d)}},[t]),o=n.useCallback(c=>{Ne.myTenants.recordRecent(c).catch(console.error)},[]);return{favorites:t,loadFavorites:r,toggleFavorite:a,recordRecent:o}}const Mo={Pending:"bg-blue-500",Active:"bg-emerald-500",Suspended:"bg-amber-500",Archived:"bg-gray-400"},Oo={Pending:"En attente",Active:"Actif",Suspended:"Suspendu",Archived:"Archivé"};function Wt({tenant:t,isSelected:s,isFavorite:r,hasThemeOverride:a,onSelect:o,onToggleFavorite:c,showStatus:i=!0}){const d=t.type==="Business",u=t.status==="Active",m=(p,g)=>p?"bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)]":g?"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]":"opacity-50 cursor-not-allowed text-[var(--text-tertiary)]";return e.jsxs("div",{className:"flex items-center group",children:[e.jsxs("button",{onClick:o,disabled:!u,className:`flex-1 flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${m(s,u)}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${d?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:d?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:t.name}),a&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--color-accent-500)]",title:"Thème personnalisé"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)] truncate",children:t.organisationName||t.slug}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Mo[t.status]}`}),t.status!=="Active"&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Oo[t.status]})]})]})]}),s&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"})]}),c&&u&&e.jsx("button",{onClick:p=>{p.stopPropagation(),c()},className:`p-2 transition-colors ${r?"text-amber-500":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:text-amber-500"}`,title:r?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${r?"fill-amber-500":""}`})})]})}const la="tenant_recents",as=5;function ca(){try{return JSON.parse(localStorage.getItem(la)||"[]")}catch{return[]}}function Fo(t){const s=ca().filter(r=>r!==t);s.unshift(t),localStorage.setItem(la,JSON.stringify(s.slice(0,as)))}const _o=(t,s,r)=>{const a=o=>{t.current&&!t.current.contains(o.target)&&(s(!1),r(""))};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},qo=(t,s)=>{const r=a=>{a.key==="Escape"&&(t(!1),s(""))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},Uo=(t,s,r,a,o)=>{const c=n.useMemo(()=>t.filter(u=>s.includes(u.id)&&u.status==="Active"),[t,s]),i=n.useMemo(()=>{if(o.trim())return[];const u=new Set(s);return r.map(m=>a.find(p=>p.id===m)).filter(m=>!!m&&m.status==="Active"&&!u.has(m.id)).slice(0,as)},[r,a,s,o]),d=n.useMemo(()=>{const u=new Set([...s,...r.slice(0,as)]);return t.filter(m=>!u.has(m.id))},[t,s,r]);return{favoriteTenants:c,recentTenants:i,otherTenants:d}};function zo(){const{t}=ne.useTranslation("navigation"),{refreshMenu:s}=Ce(),{currentTenant:r,userTenants:a,switchTenant:o,isLoading:c,hasMultipleTenants:i,hasGlobalRoles:d,isGlobalView:u,enterGlobalView:m}=Ee(),{tenantOverrides:p,loadTenantOverrides:g}=St(),[f,b]=n.useState(!1),[h,y]=n.useState(""),[x]=n.useState(()=>ca()),j=n.useRef(null),v=n.useRef(null),{favorites:S,loadFavorites:N,toggleFavorite:I,recordRecent:P}=Do();n.useEffect(()=>{f&&(N(),g())},[f,N,g]),n.useEffect(()=>{f&&v.current&&setTimeout(()=>v.current?.focus(),100)},[f]),n.useEffect(()=>_o(j,b,y),[]),n.useEffect(()=>qo(b,y),[]);const k=n.useCallback(async T=>{if(T===r?.id&&!u){b(!1);return}try{Fo(T),P(T),await o(T),b(!1),y(""),await s()}catch(z){console.error("Failed to switch tenant:",z)}},[r?.id,u,o,s,P]),A=n.useCallback(async()=>{await m(),b(!1),y(""),await s()},[m,s]),R=n.useCallback(async T=>{await I(T)},[I]),$=n.useMemo(()=>{if(!h.trim())return a;const T=h.toLowerCase();return a.filter(z=>z.name.toLowerCase().includes(T)||z.slug.toLowerCase().includes(T)||z.organisationName?.toLowerCase().includes(T))},[a,h]),{favoriteTenants:q,recentTenants:C,otherTenants:D}=Uo($,S,x,a,h);if(c)return null;if(!(i||d)&&r){const T=r.type==="Business";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-button)"},children:[T?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r.name})]})}return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{onClick:()=>b(!f),className:`flex items-center gap-2 px-3 py-1.5 border transition-colors ${u?"bg-emerald-500/10 border-emerald-500/30 hover:bg-emerald-500/20":"bg-[var(--bg-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-tertiary)]"}`,style:{borderRadius:"var(--radius-button)"},"aria-expanded":f,"aria-haspopup":"true",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-sm font-medium text-emerald-700",children:t("tenants.selector.global","Global")})]}),!u&&r&&e.jsxs(e.Fragment,{children:[r.type==="Business"?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] max-w-[120px] truncate",children:r.name})]}),!u&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Building2,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("tenants.selector.select","Select")})]}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform ${f?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute left-0 mt-2 w-80 origin-top-left transition-all duration-200 ease-out z-50 ${f?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:v,type:"text",value:h,onChange:T=>y(T.target.value),placeholder:t("tenants.selector.search","Rechercher..."),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] focus:border-[var(--color-accent-500)] focus:outline-none",style:{borderRadius:"var(--radius-input)"}})]})}),e.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d&&!h&&e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("button",{onClick:A,className:`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${u?"bg-emerald-500/10 text-emerald-700":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-emerald-500/10 flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium",children:t("tenants.selector.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:t("tenants.selector.globalDesc","Voir tous les tenants")})]}),u&&e.jsx(l.Check,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"})]})}),q.length>0&&e.jsxs("div",{className:"p-2",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500"}),t("tenants.selector.favorites","Favoris")]}),e.jsx("div",{className:"mt-1",children:q.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:!0,hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),C.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0?"border-t border-[var(--border-color)]":""}`,children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),t("tenants.selector.recent","Récents")]}),e.jsx("div",{className:"mt-1",children:C.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),D.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0||C.length>0?"border-t border-[var(--border-color)]":""}`,children:[!h&&e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Building2,{className:"w-3 h-3"}),t("tenants.selector.all","Tous")]}),e.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto",children:D.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),h&&$.length===0&&e.jsx("div",{className:"p-4 text-center text-sm text-[var(--text-tertiary)]",children:t("tenants.selector.noResults","Aucun résultat")})]}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs(w.Link,{to:"/myspace/tenants",className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},onClick:()=>b(!1),children:[e.jsx(l.Eye,{className:"w-4 h-4"}),t("tenants.selector.viewAll","Voir tous mes espaces")," (",a.length,")"]})})]})})]})}function vs(t,s){return t?s===t?"current":"other":"global"}const Bo={getOverview:(t=30)=>E.get("/api/support/dashboard/overview",{params:{days:t}}),getByStatus:()=>E.get("/api/support/dashboard/by-status"),getByPriority:()=>E.get("/api/support/dashboard/by-priority"),getByType:(t=30)=>E.get("/api/support/dashboard/by-type",{params:{days:t}}),getAgentWorkload:()=>E.get("/api/support/dashboard/agent-workload"),getTrends:(t=30)=>E.get("/api/support/dashboard/trends",{params:{days:t}}),getSatisfactionStats:(t=30)=>E.get("/api/support/dashboard/satisfaction",{params:{days:t}}),getSlaCompliance:(t=30)=>E.get("/api/support/dashboard/sla-compliance",{params:{days:t}})},da={getConfigurations:()=>E.get("/api/support/sla/configurations"),updateConfiguration:(t,s)=>E.put(`/api/support/sla/configurations/${t}`,s),getEscalationRules:()=>E.get("/api/support/sla/escalation-rules"),getBreachedTickets:(t=!0,s=!0)=>E.get("/api/support/sla/breached",{params:{responseBreached:t,resolutionBreached:s}}),getTicketsApproachingBreach:(t=60)=>E.get("/api/support/sla/approaching-breach",{params:{warningMinutes:t}}),getMetrics:(t,s)=>E.get("/api/support/sla/metrics",{params:{fromDate:t,toDate:s}}),escalateTicket:(t,s,r)=>E.post(`/api/support/sla/tickets/${t}/escalate`,{level:s,reason:r})},st={getAll:(t=1,s=20,r,a)=>E.get("/api/support/notifications",{params:{page:t,pageSize:s,isRead:r,tenantId:a}}),getUnread:(t=10)=>E.get("/api/support/notifications/unread",{params:{limit:t}}),getUnreadCount:()=>E.get("/api/support/notifications/unread/count"),markAsRead:t=>E.patch(`/api/support/notifications/${t}/read`),markAllAsRead:()=>E.patch("/api/support/notifications/read-all"),delete:t=>E.delete(`/api/support/notifications/${t}`),deleteAll:()=>E.delete("/api/support/notifications/all"),getPreferences:()=>E.get("/api/support/notifications/preferences"),updatePreferences:t=>E.put("/api/support/notifications/preferences",t)},Lt={getAll:(t,s=!0,r)=>E.get("/api/support/templates",{params:{category:t,activeOnly:s,language:r}}),getById:t=>E.get(`/api/support/templates/${t}`),getCategories:()=>E.get("/api/support/templates/categories"),getByCategory:t=>E.get(`/api/support/templates/by-category/${t}`),create:t=>E.post("/api/support/templates",t),update:(t,s)=>E.put(`/api/support/templates/${t}`,s),activate:t=>E.patch(`/api/support/templates/${t}/activate`),deactivate:t=>E.patch(`/api/support/templates/${t}/deactivate`),delete:t=>E.delete(`/api/support/templates/${t}`),render:(t,s)=>E.post(`/api/support/templates/${t}/render`,{variables:s})},ns={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function Go(t,s,r){if(r){const o=s.relatedEntityId,c=t.filter(i=>!(i.type===ns.STARTED&&i.relatedEntityId===o));return[s,...c].slice(0,10)}return t.some(o=>o.id===s.id)?t:[s,...t].slice(0,10)}function Ko(t){return{id:t.id,type:t.type,title:t.title,message:t.message,relatedEntityType:t.relatedEntityType,relatedEntityId:t.relatedEntityId,actionUrl:t.actionUrl,isRead:t.isRead,readAt:t.readAt,createdAt:t.createdAt,tenantId:t.tenantId,tenantName:t.tenantName,tenantSlug:t.tenantSlug}}function Ho(){const[t,s]=n.useState(0),[r,a]=n.useState([]),[o,c]=n.useState(!1),{isConnected:i,onNotification:d,onUnreadCountUpdate:u}=Or(),{isFeatureEnabled:m}=He(),p=m("support");n.useEffect(()=>{const x=d(v=>{const S=Ko(v),N=v.type===ns.COMPLETED||v.type===ns.FAILED;a(I=>Go(I,S,N))}),j=u(v=>{s(v)});return()=>{x(),j()}},[d,u]),n.useEffect(()=>{if(!p)return;let x=!1;async function j(){try{const v=await st.getUnreadCount();x||s(v.count)}catch(v){x||console.error("Failed to load unread count:",v)}}return j(),()=>{x=!0}},[p]);const g=n.useCallback(async()=>{if(p)try{c(!0);const x=await st.getUnread(10);a(x)}catch(x){console.error("Failed to load notifications:",x)}finally{c(!1)}},[p]),f=n.useCallback(async x=>{try{await st.markAsRead(x),a(j=>j.map(v=>v.id===x?{...v,isRead:!0}:v)),s(j=>Math.max(0,j-1))}catch(j){console.error("Failed to mark as read:",j)}},[]),b=n.useCallback(async()=>{try{await st.markAllAsRead(),a(x=>x.map(j=>({...j,isRead:!0}))),s(0)}catch(x){console.error("Failed to mark all as read:",x)}},[]),h=n.useCallback(async x=>{try{await st.delete(x);const j=r.find(v=>v.id===x);a(v=>v.filter(S=>S.id!==x)),j&&!j.isRead&&s(v=>Math.max(0,v-1))}catch(j){console.error("Failed to delete notification:",j)}},[r]),y=n.useCallback(x=>{st.markAsRead(x),s(j=>Math.max(0,j-1))},[]);return{notifications:r,unreadCount:t,loading:o,isConnected:i,loadNotifications:g,markAsRead:f,markAllAsRead:b,deleteNotification:h,markAsReadSilent:y}}const bt={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function ua(){const t=w.useNavigate(),{currentTenant:s,hasMultipleTenants:r}=Ee(),[a,o]=n.useState(!1),c=n.useRef(null),{notifications:i,unreadCount:d,loading:u,isConnected:m,loadNotifications:p,markAsRead:g,markAllAsRead:f,deleteNotification:b,markAsReadSilent:h}=Ho(),[,y]=n.useState(0);n.useEffect(()=>{if(!i.some(R=>R.type===bt.STARTED&&!R.isRead))return;const A=setInterval(()=>{y(R=>R+1)},1e3);return()=>clearInterval(A)},[i]),n.useEffect(()=>{a&&p()},[a,p]),n.useEffect(()=>{const k=A=>{c.current&&!c.current.contains(A.target)&&o(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const x=(k,A)=>{A.stopPropagation(),g(k)},j=(k,A)=>{A.stopPropagation(),b(k)},v=k=>{k.isRead||h(k.id),o(!1),k.actionUrl&&t(k.actionUrl)},S=k=>{switch(k){case"TicketCreated":return"🎫";case"TicketAssigned":return"👤";case"TicketStatusChanged":case"StatusChanged":return"🔄";case"TicketCommented":case"CommentAdded":return"💬";case"TicketResolved":return"✅";case"TicketClosed":return"🔒";case"TicketUpdated":return"📝";case"SlaResponseBreached":case"SlaResolutionBreached":return"⚠️";case"SlaWarning":return"⏰";case"TicketEscalated":return"📈";case"SatisfactionRequested":return"⭐";case"GroupMemberAdded":return"👥";case"GroupMemberRemoved":return"🚪";case"RoleAssigned":return"🎭";case"RoleRemoved":return"🚫";case"RolePermissionsChanged":return"🔑";case"AccountUpdated":return"👤";case"SystemAnnouncement":return"📢";case bt.STARTED:return null;case bt.COMPLETED:return"✅";case bt.FAILED:return"❌";default:return"📌"}},N=k=>{const A=new Date(k).getTime(),R=Date.now(),$=Math.floor((R-A)/1e3),q=Math.floor($/60),C=$%60;return`${q.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`},I=k=>{const A=new Date(k),$=new Date().getTime()-A.getTime(),q=Math.floor($/6e4),C=Math.floor(q/60),D=Math.floor(C/24);return q<1?"Just now":q<60?`${q}m ago`:C<24?`${C}h ago`:D<7?`${D}d ago`:A.toLocaleDateString()},P=k=>{if(!r)return null;const A=vs(k.tenantId,s?.id??null);return A==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):A==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:k.tenantName}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:k.tenantName})};return e.jsxs("div",{className:"relative",ref:c,children:[e.jsxs("button",{onClick:()=>o(!a),className:"relative p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors","aria-label":"Notifications",children:[e.jsx(l.Bell,{className:"w-5 h-5"}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white text-xs font-bold rounded-full flex items-center justify-center",children:d>9?"9+":d})]}),a&&e.jsxs("div",{className:"absolute right-0 mt-2 w-96 bg-[var(--bg-primary)] rounded-lg shadow-xl border border-[var(--border-color)] z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:"Notifications"}),m?e.jsx("span",{title:"Real-time connected",children:e.jsx(l.Wifi,{className:"w-3 h-3 text-green-500"})}):e.jsx("span",{title:"Offline mode",children:e.jsx(l.WifiOff,{className:"w-3 h-3 text-gray-400"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d>0&&e.jsxs("button",{onClick:f,className:"text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1",children:[e.jsx(l.CheckCheck,{className:"w-4 h-4"}),"Mark all read"]}),e.jsx("button",{onClick:()=>o(!1),className:"p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}),!u&&i.length>0&&i.map(k=>{const A=k.type===bt.STARTED&&!k.isRead,R=S(k.type);return e.jsx("div",{role:"button",tabIndex:0,onClick:()=>v(k),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),v(k))},className:`w-full text-left p-4 border-b border-[var(--border-color)] cursor-pointer hover:bg-[var(--bg-hover)] transition-colors ${k.isRead?"":"bg-blue-50/50 dark:bg-blue-900/10"} ${A?"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20":""}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"text-xl flex-shrink-0",children:A?e.jsx(l.RefreshCw,{className:"w-5 h-5 text-[var(--color-accent-600)] animate-spin"}):R}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:`text-sm ${k.isRead?"":"font-semibold"}`,children:k.title}),P(k)]}),A?e.jsxs("span",{className:"text-xs font-mono font-bold text-[var(--color-accent-600)] flex-shrink-0 bg-[var(--color-accent-100)] px-2 py-0.5 rounded",children:["⏱ ",N(k.createdAt)]}):e.jsx("span",{className:"text-xs text-[var(--text-secondary)] flex-shrink-0",children:I(k.createdAt)})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mt-1",children:k.message})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-shrink-0",children:[!k.isRead&&!A&&e.jsx("button",{onClick:$=>x(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Mark as read",children:e.jsx(l.Check,{className:"w-4 h-4 text-green-600"})}),!A&&e.jsx("button",{onClick:$=>j(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Delete",children:e.jsx(l.Trash2,{className:"w-4 h-4 text-red-500"})})]})]})},k.id)}),!u&&i.length===0&&e.jsxs("div",{className:"py-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Bell,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No notifications"})]})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)] text-center",children:e.jsx("button",{onClick:()=>{o(!1),t("/notifications")},className:"text-sm text-[var(--color-primary-600)] hover:underline",children:"View all notifications"})})]})]})}const Vo={default:{bg:"bg-[var(--bg-tertiary)]",text:"text-[var(--text-primary)]",border:"border-[var(--border-color)]",arrow:"bg-[var(--bg-tertiary)] border-[var(--border-color)]"},error:{bg:"bg-[var(--tooltip-error-bg)]",text:"text-[var(--error-text)]",border:"border-[var(--error-border)]",arrow:"bg-[var(--tooltip-error-bg)] border-[var(--error-border)]"},warning:{bg:"bg-[var(--tooltip-warning-bg)]",text:"text-[var(--warning-text)]",border:"border-[var(--warning-border)]",arrow:"bg-[var(--tooltip-warning-bg)] border-[var(--warning-border)]"},success:{bg:"bg-[var(--tooltip-success-bg)]",text:"text-[var(--success-text)]",border:"border-[var(--success-border)]",arrow:"bg-[var(--tooltip-success-bg)] border-[var(--success-border)]"},info:{bg:"bg-[var(--tooltip-info-bg)]",text:"text-[var(--info-text)]",border:"border-[var(--info-border)]",arrow:"bg-[var(--tooltip-info-bg)] border-[var(--info-border)]"}};function ma({content:t,children:s,position:r="top",variant:a="default",delay:o=200,disabled:c=!1,className:i=""}){const d=Vo[a],[u,m]=n.useState(!1),[p,g]=n.useState({top:0,left:0}),f=n.useRef(null),b=n.useRef(null),h=n.useRef(null),y=()=>{if(!f.current||!b.current)return;const S=f.current.getBoundingClientRect(),N=b.current.getBoundingClientRect(),I=window.scrollX,P=window.scrollY,k=8;let A=0,R=0;switch(r){case"top":A=S.top+P-N.height-k,R=S.left+I+(S.width-N.width)/2;break;case"bottom":A=S.bottom+P+k,R=S.left+I+(S.width-N.width)/2;break;case"left":A=S.top+P+(S.height-N.height)/2,R=S.left+I-N.width-k;break;case"right":A=S.top+P+(S.height-N.height)/2,R=S.right+I+k;break}const $=window.innerWidth,q=window.innerHeight,C=8;R<C?R=C:R+N.width>$-C&&(R=$-N.width-C),A<C+P?A=C+P:A+N.height>q+P-C&&(A=q+P-N.height-C),g({top:A,left:R})};n.useEffect(()=>(u&&(y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}),[u,r]);const x=()=>{c||!t||(h.current=setTimeout(()=>{m(!0)},o))},j=()=>{h.current&&(clearTimeout(h.current),h.current=null),m(!1)};n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const v=()=>{const S=`absolute w-2 h-2 ${d.arrow} transform rotate-45`;switch(r){case"top":return`${S} -bottom-1 left-1/2 -translate-x-1/2 border-r border-b`;case"bottom":return`${S} -top-1 left-1/2 -translate-x-1/2 border-l border-t`;case"left":return`${S} -right-1 top-1/2 -translate-y-1/2 border-t border-r`;case"right":return`${S} -left-1 top-1/2 -translate-y-1/2 border-b border-l`}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:f,onMouseEnter:x,onMouseLeave:j,onFocus:x,onBlur:j,className:"inline-flex",children:s}),u&&t&&Ft.createPortal(e.jsxs("div",{ref:b,role:"tooltip",style:{position:"absolute",top:p.top,left:p.left,zIndex:9999},className:`
1
+ "use strict";const e=require("react/jsx-runtime"),n=require("react"),us=require("axios"),ne=require("react-i18next"),Lt=require("i18next"),Qa=require("i18next-browser-languagedetector"),w=require("react-router-dom"),Za=require("@microsoft/signalr"),l=require("lucide-react"),xr=require("react-error-boundary"),Ot=require("react-dom"),Rs=require("modern-screenshot"),gt=require("react-resizable-panels"),en=require("dompurify");function hr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const oe=hr(Za),xt=hr(l),Qe={none:"0px",small:"4px",medium:"8px",large:"12px",xlarge:"16px",xxlarge:"24px"},tn={none:"Carré",small:"Léger",medium:"Moyen",large:"Arrondi",xlarge:"Très arrondi",xxlarge:"Pill"},_e={slate:{name:"Ardoise",shades:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"}},gray:{name:"Gris",shades:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"}},zinc:{name:"Zinc",shades:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"}},stone:{name:"Pierre",shades:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"}},indigo:{name:"Indigo",shades:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"}},violet:{name:"Violet",shades:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"}},blue:{name:"Bleu",shades:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},cyan:{name:"Cyan",shades:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"}},teal:{name:"Teal",shades:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"}},emerald:{name:"Émeraude",shades:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"}},amber:{name:"Ambre",shades:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"}},orange:{name:"Orange",shades:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"}},rose:{name:"Rose",shades:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},pink:{name:"Pink",shades:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"}}},sn={card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},ut={neutral:{name:"Neutre",icon:"⚪",colors:{light:{light:"#ffffff",medium:"#f4f4f5",dark:"#e4e4e7",border:"#d4d4d8"},dark:{light:"#1c1c1f",medium:"#27272a",dark:"#3f3f46",border:"#52525b"}}},ocean:{name:"Océan",icon:"🌊",colors:{light:{light:"#e0f2fe",medium:"#bae6fd",dark:"#7dd3fc",border:"#93c5fd"},dark:{light:"#141c24",medium:"#1a2836",dark:"#2a4a5e",border:"#3a5a70"}}},forest:{name:"Forêt",icon:"🌲",colors:{light:{light:"#d1fae5",medium:"#a7f3d0",dark:"#6ee7b7",border:"#86efac"},dark:{light:"#121d18",medium:"#182a22",dark:"#2a4a3a",border:"#3a5a4a"}}},sunset:{name:"Coucher de soleil",icon:"🌅",colors:{light:{light:"#fef3c7",medium:"#fde68a",dark:"#fbbf24",border:"#fcd34d"},dark:{light:"#1c1810",medium:"#2a2418",dark:"#4a3a24",border:"#5a4a34"}}},lavender:{name:"Lavande",icon:"💜",colors:{light:{light:"#ede9fe",medium:"#ddd6fe",dark:"#c4b5fd",border:"#c4b5fd"},dark:{light:"#1a1820",medium:"#24222e",dark:"#3a3650",border:"#4a4660"}}},rose:{name:"Rose",icon:"🌸",colors:{light:{light:"#fce7f3",medium:"#fbcfe8",dark:"#f9a8d4",border:"#f9a8d4"},dark:{light:"#1c1418",medium:"#2a1e24",dark:"#4a3040",border:"#5a4050"}}}},ms="neutral",mt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Clair",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#fafafa",primary:"#ffffff",secondary:"#f4f4f5",tertiary:"#e4e4e7",card:"#ffffff",hover:"#f4f4f5",active:"#e4e4e7"},text:{primary:"#18181b",secondary:"#52525b",tertiary:"#71717a",muted:"#a1a1aa",inverse:"#fafafa"},border:{default:"#e4e4e7",subtle:"#f4f4f5",strong:"#d4d4d8"},status:{success:{bg:"#f0fdfa",text:"#0f766e",border:"#99f6e4",dot:"#14b8a6"},warning:{bg:"#fffbeb",text:"#b45309",border:"#fde68a",dot:"#f59e0b"},error:{bg:"#fff1f2",text:"#be123c",border:"#fecdd3",dot:"#f43f5e"},info:{bg:"#f0f9ff",text:"#0369a1",border:"#bae6fd",dot:"#0ea5e9"}},accentTransparent:{bg:`${s[50]}`,text:s[700],border:s[200]}}},pt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Sombre",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#161618",primary:"#1c1c1f",secondary:"#232326",tertiary:"#2a2a2e",card:"#1c1c1f",hover:"#27272a",active:"#3f3f46"},text:{primary:"#fafafa",secondary:"#d4d4d8",tertiary:"#a1a1aa",muted:"#71717a",inverse:"#18181b"},border:{default:"#3f3f46",subtle:"#27272a",strong:"#52525b"},status:{success:{bg:"rgba(20, 184, 166, 0.15)",text:"#5eead4",border:"rgba(20, 184, 166, 0.3)",dot:"#14b8a6"},warning:{bg:"rgba(245, 158, 11, 0.15)",text:"#fbbf24",border:"rgba(245, 158, 11, 0.3)",dot:"#f59e0b"},error:{bg:"rgba(244, 63, 94, 0.15)",text:"#fb7185",border:"rgba(244, 63, 94, 0.3)",dot:"#f43f5e"},info:{bg:"rgba(14, 165, 233, 0.15)",text:"#7dd3fc",border:"rgba(14, 165, 233, 0.3)",dot:"#0ea5e9"}},accentTransparent:{bg:`rgba(${Es(s[500])}, 0.15)`,text:s[300],border:`rgba(${Es(s[500])}, 0.3)`}}};function Es(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?`${parseInt(s[1],16)}, ${parseInt(s[2],16)}, ${parseInt(s[3],16)}`:"99, 102, 241"}const yt={mode:"dark",borderRadius:sn,colors:{light:mt("indigo"),dark:pt("indigo")},accentColorKey:"indigo",itemPaletteKey:ms},rn=[{id:"default",name:"Par défaut",description:"Style SmartStack classique avec coins arrondis",icon:"✨",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"indigo",itemPaletteKey:"neutral"}},{id:"minimal",name:"Minimal",description:"Style épuré et professionnel",icon:"⚪",config:{borderRadius:{card:"medium",button:"small",badge:"small",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"slate",itemPaletteKey:"neutral"}},{id:"corporate",name:"Corporate",description:"Style sobre pour environnement professionnel",icon:"🏢",config:{borderRadius:{card:"small",button:"small",badge:"medium",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"gray",itemPaletteKey:"neutral"}},{id:"ocean",name:"Océan",description:"Teintes bleues apaisantes",icon:"🌊",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"cyan",itemPaletteKey:"ocean"}},{id:"forest",name:"Forêt",description:"Tons verts naturels",icon:"🌲",config:{borderRadius:{card:"medium",button:"medium",badge:"medium",input:"medium",modal:"large",menuItem:"medium"},accentColorKey:"emerald",itemPaletteKey:"forest"}},{id:"sunset",name:"Coucher de soleil",description:"Couleurs chaudes et accueillantes",icon:"🌅",config:{borderRadius:{card:"large",button:"large",badge:"xxlarge",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"orange",itemPaletteKey:"sunset"}},{id:"lavender",name:"Lavande",description:"Tons violets élégants",icon:"💜",config:{borderRadius:{card:"xlarge",button:"large",badge:"xlarge",input:"large",modal:"xlarge",menuItem:"large"},accentColorKey:"violet",itemPaletteKey:"lavender"}},{id:"rose",name:"Rose",description:"Teintes roses douces",icon:"🌸",config:{borderRadius:{card:"xxlarge",button:"xlarge",badge:"xxlarge",input:"large",modal:"xxlarge",menuItem:"large"},accentColorKey:"pink",itemPaletteKey:"rose"}}],gr="smartstack-theme-config";class kt extends Error{statusCode;details;constructor(s,r,a){super(s),this.name="AppError",this.statusCode=r,this.details=a}}class ps extends Error{constructor(s="Network error occurred"){super(s),this.name="NetworkError"}}class fr extends Error{code;constructor(s="Authentication required",r){super(s),this.name="AuthenticationError",this.code=r}}class an extends Error{constructor(s="Access denied"){super(s),this.name="ForbiddenError"}}const nn=10;class on{queue=[];recentErrors=[];isProcessing=!1;batchSize=10;batchDelay=2e3;async logError(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const d=String(a.url),u=a.status?` [${a.status}]`:"";c=`${o}${u} - ${d}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Error",metadata:a};this.storeRecentError(i),this.queue.push({type:"error",data:i}),this.processQueue()}async logCritical(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const u=String(a.url),m=a.status?` [${a.status}]`:"";c=`${o}${m} - ${u}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Critical",metadata:a};return this.storeRecentError(i),await this.sendErrorWithResponse(i)}getRecentErrors(){return[...this.recentErrors]}clearRecentErrors(){this.recentErrors=[]}storeRecentError(s){this.recentErrors.unshift({...s,timestamp:new Date}),this.recentErrors.length>nn&&this.recentErrors.pop()}async logEvent(s,r,a){const o={event:s,category:r,data:a};this.queue.push({type:"event",data:o}),this.processQueue()}async processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0,await new Promise(r=>setTimeout(r,this.batchDelay));const s=this.queue.splice(0,this.batchSize);for(const r of s)try{r.type==="error"?await this.sendError(r.data):await this.sendEvent(r.data)}catch{}this.isProcessing=!1,this.queue.length>0&&this.processQueue()}async sendError(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}async sendErrorWithResponse(s){const r=localStorage.getItem("token");try{const a=await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)});return a.ok&&a.status===200&&(await a.json()).ticketNumber||null}catch{return null}}async sendEvent(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-event",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}}const Te=new on;window.onerror=(t,s,r,a,o)=>{Te.logError(o||String(t),"window.onerror",{source:s,lineno:r,colno:a})};window.onunhandledrejection=t=>{Te.logError(t.reason instanceof Error?t.reason:String(t.reason),"unhandledrejection")};function xs(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return crypto.randomUUID()}catch{}return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>{const s=Number(t);return(s^crypto.getRandomValues(new Uint8Array(1))[0]&15>>s/4).toString(16)})}const Se=us.create({timeout:3e4,headers:{"Content-Type":"application/json"}});Se.interceptors.request.use(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`);const r=xs();t.headers&&(t.headers["X-Correlation-ID"]=r);const a=localStorage.getItem("i18nextLng")||navigator.language||"fr";t.headers&&(t.headers["Accept-Language"]=a);const o=localStorage.getItem("currentTenantSlug");return o&&t.headers&&!t.headers["X-Tenant-Slug"]&&(t.headers["X-Tenant-Slug"]=o),t},t=>(Te.logError(t,"apiClient.request"),Promise.reject(t)));Se.interceptors.response.use(t=>t,async t=>{const s=t.config?.headers?.["X-Correlation-ID"];if(us.isCancel(t)||t.code==="ERR_CANCELED")return Promise.reject(t);if(!t.response){const i=new ps("Impossible de se connecter au serveur. Vérifiez votre connexion internet.");return Te.logError(i,"apiClient.response",{correlationId:s}),Promise.reject(i)}const{status:r,data:a}=t.response,o=a?.message||a?.detail||a?.title||t.message,c=a?.code;switch(r){case 401:{const i=new fr(o,c);Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,code:c});const d=t.config?.url||"",m=["/api/user/preferences","/api/auth/session-info","/api/auth/refresh","/api/navigation/menu","/api/navigation/favorites","/api/navigation/contexts","/api/onboarding/status","/api/administration/tenants/tenant-analytics/track/"].some(p=>d.startsWith(p));if(!window.location.pathname.includes("/login")&&!m){localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user");const x=c==="SESSION_EXPIRED"?"/login?reason=session_expired":"/login";window.location.href=x}return Promise.reject(i)}case 403:{const i=new an(o),d=["/api/administration/tenants/tenant-analytics/track/","/api/support/notifications"],u=t.config?.url||"";return d.some(p=>u.startsWith(p))||Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,method:t.config?.method}),Promise.reject(i)}case 404:return Promise.reject(new kt(o||"Resource not found",r));case 400:return Promise.reject(new kt(o||"Invalid request",r,a?.details||a?.errors));case 500:case 502:case 503:case 504:{const i=new kt(o||"Server error",r);return Te.logCritical(i,"apiClient.response",{correlationId:s,url:t.config?.url,status:r}),Promise.reject(i)}default:{const i=new kt(o,r,a?.details);return Te.logError(i,"apiClient.response",{correlationId:s,status:r}),Promise.reject(i)}}});const E={get:(t,s)=>Se.get(t,s).then(r=>r.data),post:(t,s,r)=>Se.post(t,s,r).then(a=>a.data),put:(t,s,r)=>Se.put(t,s,r).then(a=>a.data),patch:(t,s,r)=>Se.patch(t,s,r).then(a=>a.data),delete:(t,s)=>Se.delete(t,s).then(r=>r.data)},Ft={preferences:{get:()=>E.get("/api/user/preferences"),updateTheme:t=>E.put("/api/user/preferences/theme",t),updateLanguage:t=>E.put("/api/user/preferences/language",t),updateNotifications:t=>E.put("/api/user/preferences/notifications",t)},dashboard:{getAll:(t=30,s=10)=>E.get(`/api/user/dashboard/all?period=${t}&errorLimit=${s}`),getSessionAnalytics:(t=30)=>E.get(`/api/user/dashboard/session-analytics?period=${t}`),getLoginErrors:(t=10)=>E.get(`/api/user/dashboard/login-errors?limit=${t}`),getCurrentSession:()=>E.get("/api/user/dashboard/current-session"),getDeviceStats:()=>E.get("/api/user/dashboard/device-stats"),getWeeklyStats:(t=30)=>E.get(`/api/user/dashboard/weekly-stats?period=${t}`),getHourlyStats:(t=30)=>E.get(`/api/user/dashboard/hourly-stats?period=${t}`),getApplicationUsage:(t=30)=>E.get(`/api/user/dashboard/application-usage?period=${t}`)}},ln=t=>({get:(s,r)=>Se.get(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data),post:(s,r,a)=>Se.post(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),put:(s,r,a)=>Se.put(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),patch:(s,r,a)=>Se.patch(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),delete:(s,r)=>Se.delete(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data)}),cn={PasswordResetMalfunction:1,FalsePositive:2,UrgentBusinessNeed:3,TechnicalSystemError:4,SupportTicketVerified:5},dn=t=>({getAll:s=>t.get("/api/administration/users",{params:s}),getById:s=>t.get(`/api/administration/users/${s}`),create:s=>t.post("/api/administration/users",s),update:(s,r)=>t.put(`/api/administration/users/${s}`,r),sendPasswordResetLink:s=>t.post(`/api/administration/users/${s}/send-password-reset`),resetPasswordDirect:(s,r)=>t.post(`/api/administration/users/${s}/reset-password-direct`,r?{temporaryPassword:r}:{}),activate:s=>t.patch(`/api/administration/users/${s}/activate`),deactivate:s=>t.patch(`/api/administration/users/${s}/deactivate`),unlock:(s,r)=>t.post(`/api/administration/users/${s}/unlock`,r),clearFailedAttempts:s=>t.post(`/api/administration/users/${s}/clear-failed-attempts`),delete:s=>t.delete(`/api/administration/users/${s}`),getSessions:s=>t.get(`/api/administration/users/${s}/sessions`),endAllSessions:s=>t.post(`/api/administration/users/${s}/sessions/end-all`),endSession:(s,r)=>t.delete(`/api/administration/users/${s}/sessions/${r}`),getActivity:s=>t.get(`/api/administration/users/${s}/activity`),getCustomRole:s=>t.get(`/api/administration/users/${s}/custom-role`),createCustomRole:s=>t.post(`/api/administration/users/${s}/custom-role`),deleteCustomRole:s=>t.delete(`/api/administration/users/${s}/custom-role`),getHistory:(s,r=50)=>t.get(`/api/administration/users/${s}/history`,{params:{limit:r}}),restoreFromHistory:(s,r)=>t.post(`/api/administration/users/${s}/history/${r}/restore`),getOrganizationReferences:()=>t.get("/api/administration/users/organization-references"),references:{getCompanies:s=>t.get("/api/administration/users/references/companies",{params:s}),getDepartments:s=>t.get("/api/administration/users/references/departments",{params:s}),getJobTitles:s=>t.get("/api/administration/users/references/job-titles",{params:s}),getOffices:s=>t.get("/api/administration/users/references/offices",{params:s}),createCompany:(s,r)=>t.post(`/api/administration/users/references/companies${r?`?tenantId=${r}`:""}`,s),createDepartment:(s,r)=>t.post(`/api/administration/users/references/departments${r?`?tenantId=${r}`:""}`,s),createJobTitle:(s,r)=>t.post(`/api/administration/users/references/job-titles${r?`?tenantId=${r}`:""}`,s),createOffice:(s,r)=>t.post(`/api/administration/users/references/offices${r?`?tenantId=${r}`:""}`,s),updateCompany:(s,r)=>t.put(`/api/administration/users/references/companies/${s}`,r),updateDepartment:(s,r)=>t.put(`/api/administration/users/references/departments/${s}`,r),updateJobTitle:(s,r)=>t.put(`/api/administration/users/references/job-titles/${s}`,r),updateOffice:(s,r)=>t.put(`/api/administration/users/references/offices/${s}`,r),activateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/activate`),activateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/activate`),activateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/activate`),activateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/activate`),deactivateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/deactivate`),deactivateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/deactivate`),deactivateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/deactivate`),deactivateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/deactivate`),deleteCompany:s=>t.delete(`/api/administration/users/references/companies/${s}`),deleteDepartment:s=>t.delete(`/api/administration/users/references/departments/${s}`),deleteJobTitle:s=>t.delete(`/api/administration/users/references/job-titles/${s}`),deleteOffice:s=>t.delete(`/api/administration/users/references/offices/${s}`)},updateProfile:(s,r)=>t.put(`/api/administration/users/${s}/profile`,r),updateOrganization:(s,r)=>t.put(`/api/administration/users/${s}/organization`,r),updateJobInfo:(s,r)=>t.put(`/api/administration/users/${s}/job-info`,r),updatePhones:(s,r)=>t.put(`/api/administration/users/${s}/phones`,r),updateAddress:(s,r)=>t.put(`/api/administration/users/${s}/address`,r),updateContact:(s,r)=>t.put(`/api/administration/users/${s}/contact`,r),getTenants:s=>t.get(`/api/administration/users/${s}/tenants`),getGroups:s=>t.get(`/api/administration/users/${s}/groups`),getConsolidatedRoles:(s,r)=>{const a=r?`/api/administration/users/${s}/consolidated-roles?tenantId=${r}`:`/api/administration/users/${s}/consolidated-roles`;return t.get(a)},getApplicationAccess:(s,r)=>{const a=r?`/api/administration/users/${s}/application-access?tenantId=${r}`:`/api/administration/users/${s}/application-access`;return t.get(a)}}),un=dn,mn=t=>({getAll:s=>t.get("/api/administration/permissions/roles",{params:s}),getAssignable:()=>t.get("/api/administration/permissions/roles",{params:{excludeCategories:"Custom",minPermissionsCount:1}}),getServiceAssignable:()=>t.get("/api/administration/permissions/roles",{params:{forExternalApps:!0,minPermissionsCount:1}}),getByApplication:s=>t.get("/api/administration/permissions/roles",{params:{applicationId:s,excludeCategories:"Custom",minPermissionsCount:1}}),getById:s=>t.get(`/api/administration/permissions/roles/${s}`),create:s=>t.post("/api/administration/permissions/roles",s),update:(s,r)=>t.put(`/api/administration/permissions/roles/${s}`,r),delete:s=>t.delete(`/api/administration/permissions/roles/${s}`),assignUser:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/users/${r}`),removeUser:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/users/${r}`),getGroups:s=>t.get(`/api/administration/permissions/roles/${s}/groups`),assignGroup:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/groups/${r}`),removeGroup:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/groups/${r}`),getTranslations:s=>t.get(`/api/administration/permissions/roles/${s}/translations`),upsertTranslation:(s,r,a)=>t.put(`/api/administration/permissions/roles/${s}/translations/${r}`,a),deleteTranslation:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/translations/${r}`)}),pn=mn,xn=t=>({getAll:s=>t.get("/api/administration/permissions",{params:s}),getById:s=>t.get(`/api/administration/permissions/${s}`),getTree:()=>t.get("/api/administration/permissions/tree"),getMatrix:()=>t.get("/api/administration/permissions/matrix"),delete:s=>t.delete(`/api/administration/permissions/${s}`)}),hn=xn,gn=t=>({getAll:s=>t.get("/api/administration/applications",{params:s}),getById:s=>t.get(`/api/administration/applications/${s}`),update:(s,r)=>t.put(`/api/administration/applications/${s}`,r),activate:s=>t.patch(`/api/administration/applications/${s}/activate`),deactivate:s=>t.patch(`/api/administration/applications/${s}/deactivate`),getModules:s=>t.get(`/api/administration/applications/${s}/modules`),updateModule:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}`,a),getModuleSections:(s,r)=>t.get(`/api/administration/applications/${s}/modules/${r}/sections`),reorderModules:(s,r)=>t.put(`/api/administration/applications/${s}/modules/reorder`,{items:r}),reorderSections:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}/sections/reorder`,{items:a}),getTenants:s=>t.get(`/api/administration/applications/${s}/tenants`),getAvailableTenants:s=>t.get(`/api/administration/applications/${s}/tenants/available`),assignToTenant:(s,r,a)=>t.post(`/api/administration/applications/${s}/tenants/${r}`,a?{accessLevel:a}:{}),removeFromTenant:(s,r)=>t.delete(`/api/administration/applications/${s}/tenants/${r}`),updateTenantAccessLevel:(s,r,a)=>t.patch(`/api/administration/applications/${s}/tenants/${r}/access-level`,{accessLevel:a}),bulkAssignTenants:(s,r)=>t.post(`/api/administration/applications/${s}/tenants/bulk`,r)}),fn=gn,bn=t=>({getOverview:(s=30,r)=>t.get("/api/administration/users/dashboard/overview",{params:{days:s},signal:r?.signal}),getByStatus:s=>t.get("/api/administration/users/dashboard/by-status",{signal:s?.signal}),getByRole:s=>t.get("/api/administration/users/dashboard/by-role",{signal:s?.signal}),getByType:s=>t.get("/api/administration/users/dashboard/by-type",{signal:s?.signal}),getLoginActivity:(s=30,r)=>t.get("/api/administration/users/dashboard/login-activity",{params:{days:s},signal:r?.signal}),getTrends:(s=30,r)=>t.get("/api/administration/users/dashboard/trends",{params:{days:s},signal:r?.signal}),getRecentUsers:(s=10,r)=>t.get("/api/administration/users/dashboard/recent-users",{params:{limit:s},signal:r?.signal}),getSecurityAlerts:(s=3,r=24,a)=>t.get("/api/administration/users/dashboard/security-alerts",{params:{threshold:s,hours:r},signal:a?.signal}),getActiveSessions:s=>t.get("/api/administration/users/dashboard/active-sessions",{signal:s?.signal}),getLatestActiveSessions:(s=5,r)=>t.get("/api/administration/users/dashboard/latest-active-sessions",{params:{limit:s},signal:r?.signal})}),vn=bn,yn=t=>({getAll:()=>t.get("/api/administration/configuration/settings"),getByCategory:s=>t.get(`/api/administration/configuration/settings/${s}`),get:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}`),update:(s,r,a)=>t.put(`/api/administration/configuration/settings/${s}/${r}`,{value:a}),reset:(s,r)=>t.post(`/api/administration/configuration/settings/${s}/${r}/reset`),getHistory:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}/history`),getCategories:()=>t.get("/api/administration/configuration/settings/categories")}),jn=yn,Nn=t=>({get:()=>t.get("/api/user/preferences"),getGlobal:()=>t.get("/api/user/preferences/global"),getForTenant:s=>t.get(`/api/user/preferences/for-tenant/${s}`),getThemeOverrides:()=>t.get("/api/user/preferences/theme-overrides"),deleteTenantOverride:()=>t.delete("/api/user/preferences/tenant-override"),applyToTenant:()=>t.post("/api/user/preferences/apply-to-tenant")}),wn=Nn,Sn=t=>({getConfig:()=>t.get("/api/administration/tenants/config"),getAll:s=>{const{excludeTypes:r,...a}=s||{},o=new URLSearchParams;a.page&&o.set("page",String(a.page)),a.pageSize&&o.set("pageSize",String(a.pageSize)),a.search&&o.set("search",a.search),a.status&&o.set("status",a.status),a.type&&o.set("type",a.type),a.sortBy&&o.set("sortBy",a.sortBy),a.sortDesc&&o.set("sortDesc","true"),r?.length&&r.forEach(i=>o.append("excludeTypes",i));const c=o.toString();return t.get(`/api/administration/tenants${c?`?${c}`:""}`)},getById:s=>t.get(`/api/administration/tenants/${s}`),createB2C:s=>t.post("/api/administration/tenants/b2c",s),createB2B:s=>t.post("/api/administration/tenants/b2b",s),update:(s,r)=>t.put(`/api/administration/tenants/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/${s}`),activate:s=>t.post(`/api/administration/tenants/${s}/activate`),suspend:s=>t.post(`/api/administration/tenants/${s}/suspend`),archive:s=>t.delete(`/api/administration/tenants/${s}`),checkSlugAvailable:s=>t.get(`/api/administration/tenants/check-slug/${s}`),assignTemplate:(s,r)=>t.post(`/api/administration/tenants/${s}/template`,{templateId:r}),removeTemplate:s=>t.delete(`/api/administration/tenants/${s}/template`),getMembers:s=>t.get(`/api/administration/tenants/${s}/members`),getMember:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}`),addMember:(s,r)=>t.post(`/api/administration/tenants/${s}/members`,r),removeMember:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}`),setMemberDefault:(s,r)=>t.patch(`/api/administration/tenants/${s}/members/${r}/set-default`),transferOwnership:(s,r)=>t.post(`/api/administration/tenants/${s}/members/transfer-ownership`,{toUserId:r}),assignRole:(s,r,a)=>t.post(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),removeRole:(s,r,a)=>t.delete(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),assignMemberRoles:(s,r,a)=>t.put(`/api/administration/tenants/${s}/members/${r}/roles`,{roleIds:a}),getMemberCustomRole:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}/custom-role`),createMemberCustomRole:(s,r)=>t.post(`/api/administration/tenants/${s}/members/${r}/custom-role`),deleteMemberCustomRole:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}/custom-role`),getTenantRoles:s=>t.get(`/api/administration/tenants/${s}/roles`),getGroups:s=>t.get(`/api/administration/tenants/${s}/groups`),getAvailableGroups:s=>t.get(`/api/administration/tenants/${s}/groups/available`),addGroupToTenant:(s,r)=>t.post(`/api/administration/tenants/${s}/groups`,{groupId:r}),removeGroupFromTenant:(s,r)=>t.delete(`/api/administration/tenants/${s}/groups/${r}`),getApplications:s=>t.get(`/api/administration/tenants/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/${s}/applications/available`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/bulk`,r),toggleApplication:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/toggle`,{isActive:a}),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/access-level`,{accessLevel:a}),getEffectiveTree:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/effective-tree`),saveOverrides:(s,r,a)=>t.put(`/api/administration/tenants/${s}/applications/${r}/overrides`,a),getModules:s=>t.get(`/api/administration/tenants/${s}/modules`),getAvailableModules:s=>t.get(`/api/administration/tenants/${s}/modules/available`),assignModule:(s,r)=>t.post(`/api/administration/tenants/${s}/modules/${r}`),removeModule:(s,r)=>t.delete(`/api/administration/tenants/${s}/modules/${r}`),toggleModule:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/modules/${r}/toggle`,{isActive:a}),getSections:s=>t.get(`/api/administration/tenants/${s}/sections`),getAvailableSections:s=>t.get(`/api/administration/tenants/${s}/sections/available`),assignSection:(s,r)=>t.post(`/api/administration/tenants/${s}/sections/${r}`),removeSection:(s,r)=>t.delete(`/api/administration/tenants/${s}/sections/${r}`),toggleSection:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/sections/${r}/toggle`,{isActive:a}),getModulesWithSections:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/modules-tree`),linkOrganisation:(s,r)=>t.post(`/api/administration/tenants/${s}/organisation`,{organisationId:r}),unlinkOrganisation:s=>t.delete(`/api/administration/tenants/${s}/organisation`)}),Cn=Sn,kn=t=>({getAll:()=>t.get("/api/administration/tenants/templates"),getById:s=>t.get(`/api/administration/tenants/templates/${s}`),create:s=>t.post("/api/administration/tenants/templates",s),update:(s,r)=>t.put(`/api/administration/tenants/templates/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/templates/${s}`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/bulk`,r),getTenants:s=>t.get(`/api/administration/tenants/templates/${s}/tenants`),getApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications/available`),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/templates/${s}/applications/${r}/access-level`,{accessLevel:a}),getApplicationModules:(s,r)=>t.get(`/api/administration/tenants/templates/${s}/applications/${r}/modules`),updateApplicationModules:(s,r,a)=>t.put(`/api/administration/tenants/templates/${s}/applications/${r}/modules`,a),getAiInstances:s=>t.get(`/api/administration/tenants/templates/${s}/ai-instances`),assignAiInstance:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/ai-instances/${r}`),removeAiInstance:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/ai-instances/${r}`)}),An=kn,Pn=t=>({getAll:s=>t.get("/api/administration/tenants/organisations",{params:s}),getAvailable:s=>t.get("/api/administration/tenants/organisations/available",{params:s?{search:s}:void 0}),getPendingVerification:()=>t.get("/api/administration/tenants/organisations/pending-verification"),getById:s=>t.get(`/api/administration/tenants/organisations/${s}`),findById:async s=>{const r=await Se.get(`/api/administration/tenants/organisations/${s}`,{validateStatus:a=>a===200||a===404});return r.status===200?r.data:null},create:s=>t.post("/api/administration/tenants/organisations",s),updateContact:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/contact`,r),updateAddress:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/address`,r),verify:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/verify`,{notes:r}),reject:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/reject`,{reason:r}),lookup:(s,r)=>t.get("/api/administration/tenants/organisations/lookup",{params:{countryCode:s,identifier:r}})}),Tn=Pn,Rn=t=>({getAll:s=>t.get("/api/administration/tenants/my",{params:s?{search:s}:void 0}),getDefault:()=>t.get("/api/administration/tenants/my/default"),setDefault:s=>t.post(`/api/administration/tenants/${s}/set-default`),clearDefault:()=>t.delete("/api/administration/tenants/clear-default"),getFavorites:()=>t.get("/api/user/preferences/tenant-favorites"),addFavorite:s=>t.post(`/api/user/preferences/tenant-favorites/${s}`),removeFavorite:s=>t.delete(`/api/user/preferences/tenant-favorites/${s}`),recordRecent:s=>t.post(`/api/user/preferences/tenant-recent/${s}`)}),En=Rn,In=t=>({getAll:s=>t.get("/api/accounts",{params:s}),getById:s=>t.get(`/api/accounts/${s}`),create:s=>t.post("/api/accounts",s),update:(s,r)=>t.put(`/api/accounts/${s}`,r),delete:s=>t.delete(`/api/accounts/${s}`),activate:s=>t.patch(`/api/accounts/${s}/activate`),deactivate:s=>t.patch(`/api/accounts/${s}/deactivate`),rotateSecret:(s,r="Primary")=>t.post(`/api/accounts/${s}/rotate-secret?keySlot=${r}`),revokeSecondarySecret:s=>t.delete(`/api/accounts/${s}/secondary-secret`),assignRole:(s,r)=>t.post(`/api/accounts/${s}/roles`,r),removeRole:(s,r,a)=>t.delete(`/api/accounts/${s}/roles/${r}`,{params:a?{tenantId:a}:void 0}),generateSecret:()=>t.post("/api/accounts/generate-secret"),getAuditLogs:(s,r=1,a=20)=>t.get(`/api/accounts/${s}/audit-logs`,{params:{page:r,pageSize:a}}),getUsageStats:(s,r=30)=>t.get(`/api/accounts/${s}/usage-stats`,{params:{days:r}}),getKeyUsage:s=>t.get(`/api/accounts/${s}/key-usage`),getApiEndpoints:()=>t.get("/api/accounts/api-endpoints"),getAppApiAccess:s=>t.get(`/api/accounts/${s}/api-access`),updateApiAccess:(s,r,a)=>t.put(`/api/accounts/${s}/api-access/${r}`,a),removeApiAccess:(s,r)=>t.delete(`/api/accounts/${s}/api-access/${r}`)}),Ln=In,$n=t=>({getNavigationLookup:()=>t.get("/api/apis/navigation-lookup")}),Dn=$n,br=t=>{const s=t?ln(t):E;return{users:un(s),roles:pn(s),permissions:hn(s),applications:fn(s),dashboard:vn(s),settings:jn(s),tenants:Cn(s),templates:An(s),organisations:Tn(s),myTenants:En(s),preferences:wn(s),externalApps:Ln(s),apiCatalog:Dn(s)}},Ne=br(),ge=(t,s,r)=>{const a=t[s];return a?typeof a=="function"?a():Promise.resolve(a):new Promise((o,c)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(c.bind(null,new Error("Unknown variable dynamic import: "+s+(s.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ss=async t=>{if(!t)return null;try{const[s,r,a,o,c,i,d,u,m,p,x,f,b,g,y,h,j,v,S,N,I,P,k,A,R,$,U,C,D,Y,T,B,Z,H]=await Promise.all([ge(Object.assign({"./locales/de/common.json":()=>Promise.resolve().then(()=>require("./common-BZM8Gf-R.js")),"./locales/en/common.json":()=>Promise.resolve().then(()=>require("./common-Daanch0E.js")),"./locales/fr/common.json":()=>Promise.resolve().then(()=>require("./common-lhAPHx3v.js")),"./locales/it/common.json":()=>Promise.resolve().then(()=>require("./common-B4gIg-Uo.js"))}),`./locales/${t}/common.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-D8yOGHza.js")),"./locales/en/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-rEtU7BPw.js")),"./locales/fr/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BI8iMTJl.js")),"./locales/it/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BTkWh95c.js"))}),`./locales/${t}/navigation.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/auth.json":()=>Promise.resolve().then(()=>require("./auth-UHnAu6_e.js")),"./locales/en/auth.json":()=>Promise.resolve().then(()=>require("./auth-Ca2Rn6on.js")),"./locales/fr/auth.json":()=>Promise.resolve().then(()=>require("./auth-HzvnTaOm.js")),"./locales/it/auth.json":()=>Promise.resolve().then(()=>require("./auth-M6aNTKCH.js"))}),`./locales/${t}/auth.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/admin.json":()=>Promise.resolve().then(()=>require("./admin-C2-UJ8bz.js")),"./locales/en/admin.json":()=>Promise.resolve().then(()=>require("./admin-BqA1PapA.js")),"./locales/fr/admin.json":()=>Promise.resolve().then(()=>require("./admin-CthTD2ui.js")),"./locales/it/admin.json":()=>Promise.resolve().then(()=>require("./admin-vLYwBGRd.js"))}),`./locales/${t}/admin.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/support.json":()=>Promise.resolve().then(()=>require("./support-BU6GoEbW.js")),"./locales/en/support.json":()=>Promise.resolve().then(()=>require("./support-DnSiwJx7.js")),"./locales/fr/support.json":()=>Promise.resolve().then(()=>require("./support-B0kcB-tL.js")),"./locales/it/support.json":()=>Promise.resolve().then(()=>require("./support-Cm84X3pP.js"))}),`./locales/${t}/support.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs.json":()=>Promise.resolve().then(()=>require("./docs-sqOeJ3Lg.js")),"./locales/en/docs.json":()=>Promise.resolve().then(()=>require("./docs-BR4q7sou.js")),"./locales/fr/docs.json":()=>Promise.resolve().then(()=>require("./docs-CDz8QplV.js")),"./locales/it/docs.json":()=>Promise.resolve().then(()=>require("./docs-DCOsvfv7.js"))}),`./locales/${t}/docs.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/ai.json":()=>Promise.resolve().then(()=>require("./ai-BGanmkGz.js")),"./locales/en/ai.json":()=>Promise.resolve().then(()=>require("./ai-CnWgG5hN.js")),"./locales/fr/ai.json":()=>Promise.resolve().then(()=>require("./ai-wRnnMW5a.js")),"./locales/it/ai.json":()=>Promise.resolve().then(()=>require("./ai-Cgn4sP2c.js"))}),`./locales/${t}/ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/communications.json":()=>Promise.resolve().then(()=>require("./communications-DBbKXpf1.js")),"./locales/en/communications.json":()=>Promise.resolve().then(()=>require("./communications-BPsS3Vfm.js")),"./locales/fr/communications.json":()=>Promise.resolve().then(()=>require("./communications-DElJaoVw.js")),"./locales/it/communications.json":()=>Promise.resolve().then(()=>require("./communications-BKaku0MU.js"))}),`./locales/${t}/communications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/entra.json":()=>Promise.resolve().then(()=>require("./entra-BadKCc7Y.js")),"./locales/en/entra.json":()=>Promise.resolve().then(()=>require("./entra-CfLYpxKq.js")),"./locales/fr/entra.json":()=>Promise.resolve().then(()=>require("./entra-Bc0Dwf7d.js")),"./locales/it/entra.json":()=>Promise.resolve().then(()=>require("./entra-DDgx1JoT.js"))}),`./locales/${t}/entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/structure.json":()=>Promise.resolve().then(()=>require("./structure-BL5cd83u.js")),"./locales/fr/structure.json":()=>Promise.resolve().then(()=>require("./structure-BblXL_QG.js"))}),`./locales/${t}/structure.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-DLJ9mTYQ.js")),"./locales/en/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-pkUX3R0G.js")),"./locales/fr/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-Di_IL1wh.js")),"./locales/it/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-B65OLntJ.js"))}),`./locales/${t}/preferences.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/groups.json":()=>Promise.resolve().then(()=>require("./groups-DGDNx8Hf.js")),"./locales/en/groups.json":()=>Promise.resolve().then(()=>require("./groups-5uqhFMN4.js")),"./locales/fr/groups.json":()=>Promise.resolve().then(()=>require("./groups-Cp2Q-pWt.js")),"./locales/it/groups.json":()=>Promise.resolve().then(()=>require("./groups-cV3gnMYo.js"))}),`./locales/${t}/groups.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/ba.json":()=>Promise.resolve().then(()=>require("./ba-9HglDm-t.js")),"./locales/fr/ba.json":()=>Promise.resolve().then(()=>require("./ba-CXlHUyjN.js"))}),`./locales/${t}/ba.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-CsRMxznf.js")),"./locales/en/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-BUnDEWjL.js")),"./locales/fr/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-DRITa5fK.js")),"./locales/it/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-qLwE7c_z.js"))}),`./locales/${t}/docs-administration-users.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BHJfnRA-.js")),"./locales/en/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-CXsWrgCA.js")),"./locales/fr/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BLmrJB-I.js")),"./locales/it/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BmiGStz4.js"))}),`./locales/${t}/docs-administration-permissions.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-Cmjpaxwy.js")),"./locales/en/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CvYnhoo5.js")),"./locales/fr/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-xhQOAORE.js")),"./locales/it/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CuHqwklv.js"))}),`./locales/${t}/docs-administration-tenants.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-CPqGrO8q.js")),"./locales/en/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-EVzVu3kS.js")),"./locales/fr/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-B0zkD6zQ.js")),"./locales/it/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-DngqfS6k.js"))}),`./locales/${t}/docs-administration-ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DRw16ooP.js")),"./locales/en/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-Da6XQxlv.js")),"./locales/fr/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-CofvuK9f.js")),"./locales/it/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DW4kFs3z.js"))}),`./locales/${t}/docs-administration-workflows.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D3hQEI3V.js")),"./locales/en/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-griadux5.js")),"./locales/fr/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-BbS4ZUu7.js")),"./locales/it/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D0KuJ7Ps.js"))}),`./locales/${t}/docs-administration-entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-C6VsiHxH.js")),"./locales/en/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-DRYyRp3S.js")),"./locales/fr/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BEepPuXf.js")),"./locales/it/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BiZBTxgS.js"))}),`./locales/${t}/docs-administration-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-BdZl4hL4.js")),"./locales/en/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-DvZxFmnH.js")),"./locales/fr/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-CXro3iiT.js")),"./locales/it/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-B1YtxR_A.js"))}),`./locales/${t}/docs-administration-configuration.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-DSMqi4PQ.js")),"./locales/en/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-C3rm7u1h.js")),"./locales/fr/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-CJsMRPaR.js")),"./locales/it/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-_LdQyRjT.js"))}),`./locales/${t}/docs-administration-configuration-license.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-HRqVNkqP.js")),"./locales/en/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-XQ-IiS31.js")),"./locales/fr/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-B3IDsztG.js")),"./locales/it/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-DKbpQgBH.js"))}),`./locales/${t}/docs-administration-tenants-template.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-BtAQiVRM.js")),"./locales/en/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-Cs4N4jrq.js")),"./locales/fr/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-XRmC4aRE.js")),"./locales/it/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-D1T8STQX.js"))}),`./locales/${t}/docs-administration-tenants-business.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DHGVmv0D.js")),"./locales/en/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-Bk0D7emY.js")),"./locales/fr/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DSnrN4MO.js")),"./locales/it/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-KFjQQGdW.js"))}),`./locales/${t}/docs-administration-tenants-personal.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-B5w2xFPJ.js")),"./locales/en/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-Dh2ohplZ.js")),"./locales/fr/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-WV4RsrVj.js")),"./locales/it/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-DeZKiNkH.js"))}),`./locales/${t}/docs-administration-tenants-other.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-BbAfGAzk.js")),"./locales/en/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-cv88prRo.js")),"./locales/fr/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Clm4Yhy7.js")),"./locales/it/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Xtrdol6a.js"))}),`./locales/${t}/docs-administration-permissions-assignments.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-BXTwlVt_.js")),"./locales/en/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DxKx9YEc.js")),"./locales/fr/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DehK43TA.js")),"./locales/it/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-D2SCJxWE.js"))}),`./locales/${t}/docs-administration-tenants-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-CMJEiBDZ.js")),"./locales/en/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-BDCjPv_a.js")),"./locales/fr/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-DXBq6rZX.js")),"./locales/it/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-7mBPVsvv.js"))}),`./locales/${t}/docs-administration-tenants-access-requests.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DV-_MnD2.js")),"./locales/en/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BJS2qchs.js")),"./locales/fr/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DDPYmh_7.js")),"./locales/it/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BWchU3XZ.js"))}),`./locales/${t}/docs-administration-tenants-organisations.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-nvIWiI_l.js")),"./locales/en/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-yc0oKKrD.js")),"./locales/fr/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-jObWdig-.js")),"./locales/it/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-BtPIdbRr.js"))}),`./locales/${t}/docs-platform-support-tickets.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-D6Oy2YkN.js")),"./locales/en/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-sPBt_1c4.js")),"./locales/fr/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-BVpRmDsI.js")),"./locales/it/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-lQ9K3m9K.js"))}),`./locales/${t}/docs-administration-users-dashboard.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Du_ykq8Q.js")),"./locales/en/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-CNWOU2Wq.js")),"./locales/fr/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Dc8nUoSy.js")),"./locales/it/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-C5YUKBpW.js"))}),`./locales/${t}/docs-administration-users-references.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-WmOKFuUm.js")),"./locales/en/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-C6xh7MWi.js")),"./locales/fr/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-DgWpE7cP.js")),"./locales/it/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-7NuH5xFT.js"))}),`./locales/${t}/docs-administration-users-groups.json`,4).catch(()=>({default:{}}))]);return{common:s.default||{},navigation:r.default||{},auth:a.default||{},admin:o.default||{},support:c.default||{},docs:i.default||{},ai:d.default||{},communications:u.default||{},entra:m.default||{},structure:p.default||{},preferences:x.default||{},groups:f.default||{},ba:b.default||{},docsAdministrationUsers:g.default||{},docsAdministrationPermissions:y.default||{},docsAdministrationTenants:h.default||{},docsAdministrationAi:j.default||{},docsAdministrationWorkflows:v.default||{},docsAdministrationEntra:S.default||{},docsAdministrationApplications:N.default||{},docsAdministrationConfiguration:I.default||{},docsAdministrationConfigurationLicense:P.default||{},docsAdministrationTenantsTemplate:k.default||{},docsAdministrationTenantsBusiness:A.default||{},docsAdministrationTenantsPersonal:R.default||{},docsAdministrationTenantsOther:$.default||{},docsAdministrationPermissionsAssignments:U.default||{},docsAdministrationTenantsApplications:C.default||{},docsAdministrationTenantsAccessRequests:D.default||{},docsAdministrationTenantsOrganisations:Y.default||{},docsPlatformSupportTickets:T.default||{},docsAdministrationUsersDashboard:B.default||{},docsAdministrationUsersReferences:Z.default||{},docsAdministrationUsersGroups:H.default||{}}}catch(s){return console.warn(`Failed to load language: ${t}`,s),null}},Mn={},On=()=>{const t=localStorage.getItem("i18nextLng");if(t&&["en","fr","de","it"].includes(t))return t;const s=navigator.language.split("-")[0];return["en","fr","de","it"].includes(s)?s:"en"},Rt=On();Lt.use(Qa).use(ne.initReactI18next).init({resources:Mn,lng:Rt,fallbackLng:"en",defaultNS:"common",ns:["common","navigation","auth","admin","support","docs","ai","communications","entra","structure","preferences","groups","ba","docsAdministrationUsers","docsAdministrationPermissions","docsAdministrationTenants","docsAdministrationAi","docsAdministrationWorkflows","docsAdministrationEntra","docsAdministrationApplications","docsAdministrationConfiguration","docsAdministrationConfigurationLicense","docsAdministrationTenantsTemplate","docsAdministrationTenantsBusiness","docsAdministrationTenantsPersonal","docsAdministrationTenantsOther","docsAdministrationPermissionsAssignments","docsAdministrationTenantsApplications","docsAdministrationTenantsAccessRequests","docsAdministrationTenantsOrganisations","docsPlatformSupportTickets","docsAdministrationUsersReferences","docsAdministrationUsersGroups"],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],caches:["localStorage"]}});const rs=(t,s)=>{Object.entries(s).forEach(([r,a])=>{Lt.addResourceBundle(t,r,a,!0,!0)})},Fn=(async()=>{const t=[];Rt!=="en"&&t.push(ss("en").then(s=>{s&&rs("en",s)})),t.push(ss(Rt).then(s=>{s&&rs(Rt,s)})),await Promise.all(t)})(),hs=async t=>{if(await Fn,!Lt.hasResourceBundle(t,"common")){const s=await ss(t);s&&rs(t,s)}await Lt.changeLanguage(t)},vr=n.createContext(void 0);function _n(){if(typeof window>"u")return yt;try{const s=localStorage.getItem(gr);if(s){const r=JSON.parse(s);return{...yt,...r,borderRadius:{...yt.borderRadius,...r.borderRadius},itemPaletteKey:r.itemPaletteKey||ms,colors:{light:mt(r.accentColorKey||"indigo"),dark:pt(r.accentColorKey||"indigo")}}}}catch{}const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return{...yt,mode:t?"dark":"light"}}function At(t){const s=t.accentColorKey||"indigo",r=t.borderRadius;return{mode:t.theme||"dark",accentColorKey:s,borderRadius:{card:r?.card||"large",button:r?.button||"medium",badge:r?.badge||"medium",input:r?.input||"medium",modal:r?.modal||"xlarge",menuItem:r?.menuItem||"medium"},itemPaletteKey:t.itemPaletteKey||ms,colors:{light:mt(s),dark:pt(s)}}}function Un(t){const s=document.documentElement,r=t.mode==="dark"?t.colors.dark:t.colors.light,a=_e[t.accentColorKey]?.shades||_e.indigo.shades,o=ut[t.itemPaletteKey]||ut.neutral,c=t.mode==="dark"?o.colors.dark:o.colors.light;t.mode==="dark"?s.classList.add("dark"):s.classList.remove("dark"),s.style.setProperty("--radius-card",Qe[t.borderRadius.card]),s.style.setProperty("--radius-button",Qe[t.borderRadius.button]),s.style.setProperty("--radius-badge",Qe[t.borderRadius.badge]),s.style.setProperty("--radius-input",Qe[t.borderRadius.input]),s.style.setProperty("--radius-modal",Qe[t.borderRadius.modal]),s.style.setProperty("--radius-menu-item",Qe[t.borderRadius.menuItem]),Object.entries(a).forEach(([i,d])=>{s.style.setProperty(`--color-accent-${i}`,d)}),s.style.setProperty("--item-color-light",c.light),s.style.setProperty("--item-color-medium",c.medium),s.style.setProperty("--item-color-dark",c.dark),s.style.setProperty("--item-color-border",c.border),s.style.setProperty("--bg-app",r.backgrounds.app),s.style.setProperty("--bg-primary",r.backgrounds.primary),s.style.setProperty("--bg-secondary",r.backgrounds.secondary),s.style.setProperty("--bg-tertiary",r.backgrounds.tertiary),s.style.setProperty("--bg-card",r.backgrounds.card),s.style.setProperty("--bg-hover",r.backgrounds.hover),s.style.setProperty("--bg-active",r.backgrounds.active),s.style.setProperty("--text-primary",r.text.primary),s.style.setProperty("--text-secondary",r.text.secondary),s.style.setProperty("--text-tertiary",r.text.tertiary),s.style.setProperty("--text-muted",r.text.muted),s.style.setProperty("--text-inverse",r.text.inverse),s.style.setProperty("--border-color",r.border.default),s.style.setProperty("--border-subtle",r.border.subtle),s.style.setProperty("--border-strong",r.border.strong),s.style.setProperty("--success-bg",r.status.success.bg),s.style.setProperty("--success-text",r.status.success.text),s.style.setProperty("--success-border",r.status.success.border),s.style.setProperty("--success-dot",r.status.success.dot),s.style.setProperty("--warning-bg",r.status.warning.bg),s.style.setProperty("--warning-text",r.status.warning.text),s.style.setProperty("--warning-border",r.status.warning.border),s.style.setProperty("--warning-dot",r.status.warning.dot),s.style.setProperty("--error-bg",r.status.error.bg),s.style.setProperty("--error-text",r.status.error.text),s.style.setProperty("--error-border",r.status.error.border),s.style.setProperty("--error-dot",r.status.error.dot),s.style.setProperty("--info-bg",r.status.info.bg),s.style.setProperty("--info-text",r.status.info.text),s.style.setProperty("--info-border",r.status.info.border),s.style.setProperty("--info-dot",r.status.info.dot),s.style.setProperty("--accent-bg",r.accentTransparent.bg),s.style.setProperty("--accent-text",r.accentTransparent.text),s.style.setProperty("--accent-border",r.accentTransparent.border)}function yr({children:t}){const[s,r]=n.useState(_n),[a,o]=n.useState(!1),[c,i]=n.useState(null),[d,u]=n.useState(void 0),[m,p]=n.useState([]),{i18n:x}=ne.useTranslation(),f=n.useRef(null),b=n.useRef(!0),g=n.useRef(!1),y=n.useRef(!1),h=n.useCallback(async(T,B=void 0)=>{if(!localStorage.getItem("token")||y.current)return;let H=null;const J=localStorage.getItem("currentTenantId");if(B===void 0)J?H=J:H=null;else{if(B!==null&&J&&B!==J)return;H=B}try{o(!0),await Ft.preferences.updateTheme({mode:T.mode,accentColorKey:T.accentColorKey,borderRadius:{card:T.borderRadius.card,button:T.borderRadius.button,badge:T.borderRadius.badge,input:T.borderRadius.input,modal:T.borderRadius.modal,menuItem:T.borderRadius.menuItem},itemPaletteKey:T.itemPaletteKey,targetTenantId:H}),H&&!m.includes(H)&&p(fe=>[...fe,H])}catch(fe){console.error("[ThemeContext] ❌ Failed to save theme to server:",{error:fe,targetTenantId:H,mode:T.mode,accentColorKey:T.accentColorKey,localStorage_currentTenantId:localStorage.getItem("currentTenantId"),localStorage_currentTenantSlug:localStorage.getItem("currentTenantSlug")})}finally{o(!1)}},[m]),j=n.useCallback((T,B=void 0)=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{h(T,B)},1e3)},[h]);n.useLayoutEffect(()=>{Un(s)},[s]),n.useEffect(()=>{const T={mode:s.mode,borderRadius:s.borderRadius,accentColorKey:s.accentColorKey,itemPaletteKey:s.itemPaletteKey};localStorage.setItem(gr,JSON.stringify(T)),!y.current&&!b.current&&j(s,d),b.current=!1},[s,j,d]),n.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const v=n.useCallback(async T=>{const B=localStorage.getItem("token"),Z=localStorage.getItem("currentTenantSlug");if(!B)return;const H=T==="global";if(!(!H&&!Z))try{o(!0);const J=H?await Ne.preferences.getGlobal():await Ne.preferences.get();i(J.scope);const fe=At(J);b.current=!0,r(fe),g.current=!0,J.language&&J.language!==x.language&&(await hs(J.language),document.documentElement.lang=J.language)}catch(J){console.error("[ThemeContext] Failed to load theme from server:",J)}finally{o(!1)}},[x]),S=n.useCallback(async()=>{const T=localStorage.getItem("token"),B=localStorage.getItem("currentTenantSlug");if(!(!T||!B))try{o(!0);const Z=await Ne.preferences.applyToTenant();i(Z.scope)}catch(Z){throw console.error("[ThemeContext] Failed to create tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),N=n.useCallback(async()=>{const T=localStorage.getItem("token"),B=localStorage.getItem("currentTenantSlug");if(!(!T||!B))try{o(!0);const Z=await Ne.preferences.deleteTenantOverride();i(Z.scope);const H=At(Z);b.current=!0,r(H)}catch(Z){throw console.error("[ThemeContext] Failed to delete tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),I=n.useCallback(async()=>{if(localStorage.getItem("token"))try{const B=await Ne.preferences.getThemeOverrides();p(B)}catch(B){console.error("[ThemeContext] Failed to load tenant overrides:",B)}},[]),P=n.useCallback(async(T,B=!1)=>{if(f.current&&(clearTimeout(f.current),f.current=null),y.current=!0,g.current=!0,b.current=!0,u(T),B){y.current=!1;return}if(!localStorage.getItem("token")){y.current=!1;return}try{if(o(!0),T===null){const H=await Ne.preferences.getGlobal();i(H.scope);const J=At(H);b.current=!0,r(J)}else{const H=await Ne.preferences.getForTenant(T);i(H.scope);const J=At(H);b.current=!0,r(J)}}catch(H){console.error("[ThemeContext] Failed to load preferences for tenant:",H)}finally{o(!1),y.current=!1}},[]),k=n.useCallback(()=>{r(T=>({...T,mode:T.mode==="light"?"dark":"light",colors:{light:mt(T.accentColorKey),dark:pt(T.accentColorKey)}}))},[]),A=n.useCallback(T=>{r(B=>({...B,mode:T}))},[]),R=n.useCallback((T,B)=>{r(Z=>({...Z,borderRadius:{...Z.borderRadius,[T]:B}}))},[]),$=n.useCallback(T=>{_e[T]&&r(B=>({...B,accentColorKey:T,colors:{light:mt(T),dark:pt(T)}}))},[]),U=n.useCallback(T=>{ut[T]&&r(B=>({...B,itemPaletteKey:T}))},[]),C=n.useCallback(T=>{r(B=>{const Z=T.accentColorKey||B.accentColorKey;return{...B,...T,borderRadius:{...B.borderRadius,...T.borderRadius},accentColorKey:Z,itemPaletteKey:T.itemPaletteKey||B.itemPaletteKey,colors:{light:mt(Z),dark:pt(Z)}}})},[]),D=n.useCallback(()=>{r(yt)},[]),Y=n.useCallback(T=>Qe[s.borderRadius[T]],[s.borderRadius]);return e.jsx(vr.Provider,{value:{config:s,mode:s.mode,toggleMode:k,setMode:A,setBorderRadius:R,setAccentColor:$,setItemPalette:U,applyPreset:C,resetToDefault:D,getBorderRadius:Y,loadFromServer:v,isSyncing:a,scopeInfo:c,applyToTenant:S,resetToGlobal:N,selectedThemeTenant:d,setSelectedThemeTenant:P,tenantOverrides:m,loadTenantOverrides:I},children:t})}function wt(){const t=n.useContext(vr);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}let ft=null,at=null;const qn={async getFeatureConfig(t){return ft||at||(at=(async()=>{try{return ft=(await us.get("/api/config/features",{timeout:1e4,signal:t,headers:{"Content-Type":"application/json"}})).data,ft}finally{at=null}})(),at)},clearCache(){ft=null,at=null}},jr=n.createContext(void 0);function Bn({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(!0);n.useEffect(()=>{const i=new AbortController;return qn.getFeatureConfig(i.signal).then(d=>{i.signal.aborted||r(d)}).catch(d=>{d.name==="CanceledError"||i.signal.aborted||(console.error("Failed to load feature config:",d),r({multiTenantEnabled:!0,enableB2B:!0,enableB2C:!0,useUrlRouting:!0}))}).finally(()=>{i.signal.aborted||o(!1)}),()=>i.abort()},[]);const c={config:s,isLoading:a,isMultiTenant:!0,isHybridMode:s?.multiTenantEnabled===!0&&s?.enableB2B===!1&&s?.enableB2C===!0,enableB2B:s?.enableB2B??!0,enableB2C:s?.enableB2C??!0,useUrlRouting:s?.useUrlRouting??!0};return e.jsx(jr.Provider,{value:c,children:t})}function _t(){const t=n.useContext(jr);if(!t)throw new Error("useFeatureConfig must be used within FeatureConfigProvider");return t}const Nr="*";function Ut(t,s){const r=t.toLowerCase(),a=s.toLowerCase();if(r==="*"||r===a)return!0;if(r.endsWith(".*")){const o=r.slice(0,-2);return a.startsWith(o+".")||a===o}return!1}function wr(t,s){if(t.includes(s))return!0;for(const r of t)if(Ut(r,s))return!0;return!1}function $t(t){return t.includes(Nr)}function Sr(t,s){if(!s||$t(t))return!0;const r=s.toLowerCase(),a=r+".";for(const o of t){const c=o.toLowerCase();if(c==="*"||c===r||c.startsWith(a))return!0;if(c.endsWith(".*")){const i=c.slice(0,-1);if(r.startsWith(i)||a.startsWith(i))return!0}}return!1}const gs=n.createContext(void 0),nt="token",ot="user";function Cr({children:t}){const[s,r]=n.useState(()=>{if(typeof window<"u"){const m=localStorage.getItem(ot);if(m)try{return JSON.parse(m)}catch{return null}}return null}),[a,o]=n.useState(!0),c=n.useCallback((m,p)=>{localStorage.setItem(nt,m),localStorage.setItem(ot,JSON.stringify(p)),r(p)},[]),i=n.useCallback(async()=>{try{localStorage.getItem(nt)&&await E.post("/api/auth/logout")}catch{}localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot),r(null),window.location.href="/login"},[]),d=n.useCallback(m=>s?wr(s.permissions,m):!1,[s]),u=n.useCallback(async()=>{if(localStorage.getItem(nt))try{const p=await E.get("/api/auth/me");r(p),localStorage.setItem(ot,JSON.stringify(p))}catch(p){console.error("Failed to refresh permissions:",p)}},[]);return n.useEffect(()=>{localStorage.getItem(nt)&&!s?E.get("/api/auth/me").then(p=>{r(p),localStorage.setItem(ot,JSON.stringify(p))}).catch(()=>{localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot)}).finally(()=>o(!1)):o(!1)},[s]),e.jsx(gs.Provider,{value:{user:s,isAuthenticated:!!s,isLoading:a,login:c,logout:i,hasPermission:d,refreshPermissions:u},children:t})}function Pe(){const t=n.useContext(gs);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}function zn(){return n.useContext(gs)??null}function kr(t){return t.includes("*")}const Ar=n.createContext(void 0);function Pr({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(null),[c,i]=n.useState(!0),[d,u]=n.useState(null),m=n.useRef(null),p=n.useCallback(async g=>{try{i(!0),u(null);const[y,h]=await Promise.all([E.get("/api/administration/license",{signal:g}),E.get("/api/administration/license/usage",{signal:g}).catch(()=>null)]);g?.aborted||(r(y),o(h))}catch(y){if(y instanceof Error&&y.name==="CanceledError"||g?.aborted)return;u(y instanceof Error?y.message:"Failed to load license info"),console.error("Failed to fetch license:",y)}finally{g?.aborted||i(!1)}},[]);n.useEffect(()=>{m.current?.abort();const g=new AbortController;return m.current=g,p(g.signal),()=>g.abort()},[p]);const x=n.useCallback(g=>s?kr(s.enabledFeatures)?!0:s.enabledFeatures.some(y=>y.toLowerCase()===g.toLowerCase()):!1,[s]),f=n.useCallback(async()=>{m.current?.abort();const g=new AbortController;m.current=g,await p(g.signal)},[p]),b=n.useCallback(async(g,y)=>{try{const h=await E.post("/api/administration/license/activate",{licenseKey:g,apiKey:y||null});return h.success?(await f(),{success:!0}):{success:!1,error:h.errorMessage||"Activation failed"}}catch(h){return{success:!1,error:h instanceof Error?h.message:"Activation failed"}}},[f]);return e.jsx(Ar.Provider,{value:{license:s,usage:a,isLoading:c,error:d,isFeatureEnabled:x,isReadOnlyMode:s?.isReadOnlyMode??!1,isServerDowntimeBlocked:s?.isServerDowntimeBlocked??!1,refreshLicense:f,activateLicense:b},children:t})}function He(){const t=n.useContext(Ar);if(t===void 0)throw new Error("useLicense must be used within a LicenseProvider");return t}const Tr=n.createContext(void 0),Xe="currentTenantId",Ye="currentTenantSlug",ze="isGlobalView";function Gn({children:t}){const{isAuthenticated:s,user:r,refreshPermissions:a}=Pe(),{isLoading:o}=_t(),[c,i]=n.useState(null),[d,u]=n.useState([]),[m,p]=n.useState(!0),[x,f]=n.useState(null),[b,g]=n.useState(()=>localStorage.getItem(ze)==="true"),y=n.useRef(!1),h=n.useRef(""),j=d.filter(C=>C.type==="Business"),v=d.find(C=>C.type==="Personal")||null,S=n.useCallback((C,D)=>{if(u(C),C.length===0){i(null),g(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(ze),p(!1);return}const Y=localStorage.getItem(Xe),T=Y?C.find(J=>J.id===Y):null;if(T?.status==="Active"){i(T),g(!1),localStorage.setItem(Xe,T.id),localStorage.setItem(Ye,T.slug),localStorage.removeItem(ze),p(!1);return}if(localStorage.getItem(ze)==="true"){g(!0),i(null),p(!1);return}const Z=C.find(J=>J.isDefault&&J.status==="Active");if(Z){i(Z),g(!1),localStorage.setItem(Xe,Z.id),localStorage.setItem(Ye,Z.slug),localStorage.removeItem(ze),p(!1);return}if(D){g(!0),i(null),localStorage.setItem(ze,"true"),p(!1);return}const H=C.find(J=>J.status==="Active");i(H||null),H&&(localStorage.setItem(Xe,H.id),localStorage.setItem(Ye,H.slug)),p(!1)},[]),N=n.useCallback(async C=>{const D=d.find(Y=>Y.id===C);if(!D)throw new Error("Tenant not found");if(D.status!=="Active")throw new Error("Cannot switch to inactive tenant");g(!1),localStorage.removeItem(ze),i(D),localStorage.setItem(Xe,C),localStorage.setItem(Ye,D.slug),await a()},[d,a]),I=n.useCallback(async()=>{g(!0),localStorage.setItem(ze,"true"),i(null),localStorage.removeItem(Xe),localStorage.removeItem(Ye),await a()},[a]),P=n.useCallback(async()=>{g(!1),localStorage.removeItem(ze);const C=d.find(T=>T.isDefault&&T.status==="Active"),D=d.find(T=>T.status==="Active"),Y=C||D||null;Y&&(i(Y),localStorage.setItem(Xe,Y.id),localStorage.setItem(Ye,Y.slug)),await a()},[d,a]),k=n.useCallback(async C=>{try{await Ne.myTenants.setDefault(C),u(D=>D.map(T=>({...T,isDefault:T.id===C}))),await N(C)}catch(D){throw console.error("[TenantContext] Failed to set default tenant:",D),D}},[N]),A=n.useCallback(async()=>{try{await Ne.myTenants.clearDefault(),u(C=>C.map(D=>({...D,isDefault:!1}))),await I()}catch(C){throw console.error("[TenantContext] Failed to clear default tenant:",C),C}},[I]),R=n.useCallback(async()=>{p(!0),f(null);try{await a()}catch(C){console.error("Failed to refresh tenants:",C),f("Failed to refresh tenants")}finally{p(!1)}},[a]);n.useEffect(()=>{if(!s||!r){y.current&&(u([]),i(null),p(!1),y.current=!1,h.current="");return}const C=r.tenants||[],D=C.map(Y=>`${Y.id}:${Y.status}:${Y.isDefault}`).sort((Y,T)=>Y.localeCompare(T)).join(",");if(!y.current||D!==h.current){y.current=!0,h.current=D;const Y=$t(r.permissions||[]);S(C,Y),localStorage.getItem(Ye)&&a().catch(B=>console.error("[TenantContext] Failed to refresh permissions after tenant init:",B))}},[s,r,S,a]),n.useEffect(()=>{s||(i(null),u([]),g(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(ze))},[s]);const $=r?$t(r.permissions||[]):!1,U={currentTenant:c,userTenants:d,b2bTenants:j,personalTenant:v,isLoading:m||o,error:x,switchTenant:N,setDefaultTenant:k,clearDefaultTenant:A,refreshTenants:R,hasMultipleTenants:d.filter(C=>C.status==="Active").length>1,isCurrentTenantOwner:c?.isOwner??!1,hasGlobalRoles:$,isGlobalView:b,enterGlobalView:I,exitGlobalView:P};return e.jsx(Tr.Provider,{value:U,children:t})}function Ee(){const t=n.useContext(Tr);if(t===void 0)throw new Error("useTenant must be used within a TenantProvider");return t}const Pt=5,Rr=n.createContext(null);function Er({children:t}){const{i18n:s}=ne.useTranslation(),{isAuthenticated:r}=Pe(),{currentTenant:a,isLoading:o}=Ee(),[c,i]=n.useState([]),[d,u]=n.useState(!1),[m,p]=n.useState(null),[x,f]=n.useState(!1),b=n.useCallback(()=>{f(!0)},[]),g=n.useCallback(()=>{f(!1)},[]),y=n.useCallback(async()=>{try{u(!0),p(null);const A=(await E.get("/api/navigation/module-favorites")).map(R=>({id:R.id,code:R.code,label:R.label,icon:R.icon||"Star",route:R.route||"",applicationId:R.applicationId,applicationCode:R.applicationCode,applicationLabel:R.applicationLabel,displayOrder:R.displayOrder}));i(A)}catch(k){console.error("Failed to load favorite modules:",k),p("Erreur lors du chargement des favoris"),i([])}finally{u(!1)}},[]);n.useEffect(()=>{r&&!o?y():r||(i([]),p(null))},[r,o,a,y]),n.useEffect(()=>{const k=()=>{r&&!o&&y()};return s.on("languageChanged",k),()=>{s.off("languageChanged",k)}},[s,r,o,y]);const h=n.useCallback(async k=>{if(c.length>=Pt||c.some(A=>A.id===k.id))return!1;try{return p(null),await E.post(`/api/navigation/module-favorites/${k.id}`),i(A=>[...A,{...k,displayOrder:A.length+1}]),!0}catch(A){return console.error("Failed to add favorite module:",A),await y(),!1}},[c,y]),j=n.useCallback(async k=>{try{return p(null),await E.delete(`/api/navigation/module-favorites/${k}`),i(A=>A.filter(R=>R.id!==k)),!0}catch(A){return console.error("Failed to remove favorite module:",A),await y(),!1}},[y]),v=n.useCallback(k=>c.some(A=>A.id===k),[c]),S=n.useCallback(async k=>v(k.id)?await j(k.id):await h(k),[v,j,h]),N=n.useCallback(async k=>{const A=k.slice(0,Pt),R=A.map(U=>U.id),$=[...c];i(A.map((U,C)=>({...U,displayOrder:C+1})));try{return p(null),await E.put("/api/navigation/module-favorites/reorder",R),!0}catch(U){return console.error("Failed to reorder favorite modules:",U),i($),!1}},[c]),I=c.length<Pt;return e.jsx(Rr.Provider,{value:{favorites:c,loading:d,error:m,addFavorite:h,removeFavorite:j,toggleFavorite:S,isFavorite:v,reorderFavorites:N,canAddMore:I,maxFavorites:Pt,reload:y,expandFavorites:x,triggerExpand:b,clearExpand:g,requiresTenant:!1},children:t})}function Ke(){const t=n.useContext(Rr);if(!t)throw new Error("useFavorites must be used within a FavoritesProvider");return t}const Ir="smartstack-sidebar-collapsed",Lr=n.createContext(void 0);function Kn(){if(typeof window>"u")return!1;try{return localStorage.getItem(Ir)==="true"}catch{return!1}}function $r({children:t}){const[s,r]=n.useState(Kn);n.useEffect(()=>{localStorage.setItem(Ir,String(s))},[s]);const a=n.useCallback(()=>{r(i=>!i)},[]),o=n.useCallback(i=>{r(i)},[]),c=s?64:256;return e.jsx(Lr.Provider,{value:{isCollapsed:s,toggleCollapsed:a,setCollapsed:o,sidebarWidth:c},children:t})}function qt(){const t=n.useContext(Lr);if(t===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return t}const Dr=["login","callback","logout","onboarding","system","applications","notifications"],Mr=n.createContext(void 0);function Hn(t){let s=t.split("/").filter(Boolean);return s.length>=2&&s[0]==="t"&&(s=s.slice(2)),s.length===0?{app:null,module:null}:Dr.includes(s[0])?{app:null,module:null}:{app:s[0]||null,module:s[1]||null}}function fs({children:t}){const s=w.useLocation(),{i18n:r}=ne.useTranslation(),{currentTenant:a,isLoading:o,isGlobalView:c}=Ee(),[i,d]=n.useState(null),[u,m]=n.useState([]),[p,x]=n.useState(!0),f=n.useRef(!1),b=n.useRef(void 0),g=n.useRef(0),y=c?"global":a?.id??"none";f.current&&y!==b.current&&!p&&x(!0);const{app:h,module:j}=Hn(s.pathname),v=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/menu");d(C)}catch(C){console.error("Failed to fetch menu:",C)}},[]),S=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/favorites");m(C)}catch(C){console.error("Failed to fetch favorites:",C)}},[]),N=n.useCallback(async()=>{const C=++g.current;if(x(!0),await v(),C===g.current){if(a){if(await S(),C!==g.current)return}else m([]);x(!1)}},[v,S,a]);n.useEffect(()=>{const C=localStorage.getItem("token"),D=c?"global":a?.id??"none";if(!(!C||o)){if(!f.current){f.current=!0,b.current=D,N();return}D!==b.current&&(b.current=D,N())}},[a?.id,c,o]),n.useEffect(()=>{const C=()=>{localStorage.getItem("token")&&N()};return r.on("languageChanged",C),()=>{r.off("languageChanged",C)}},[r,N]);const I=n.useCallback(C=>C.startsWith("core_")?C.slice(5):C.startsWith("ext_")?C.slice(4):C,[]),P=n.useCallback((C,D)=>C&&C.split("/").filter(Boolean)[D]||null,[]),k=n.useCallback(()=>i?.applications.find(C=>P(C.route,0)===h||I(C.code)===h),[i,h,P,I]),A=n.useCallback(()=>k()?.modules.find(D=>P(D.route,1)===j||I(D.code)===j),[k,j,P,I]),R=n.useCallback(C=>i?.applications.filter(D=>D.zone===C)||[],[i]),$=n.useCallback(C=>u.some(D=>D.id===C),[u]),U=n.useCallback(async C=>{if(a)try{$(C)?(await E.delete(`/api/navigation/favorites/${C}`),m(D=>D.filter(Y=>Y.id!==C))):(await E.post(`/api/navigation/favorites/${C}`,{}),await S())}catch(D){console.error("Failed to toggle favorite:",D)}},[a,$,S]);return e.jsx(Mr.Provider,{value:{menu:i,favorites:u,currentAppCode:h,currentModuleCode:j,isLoading:p,getCurrentApplication:k,getCurrentModule:A,getApplicationsByZone:R,getApplicationsForContext:R,toggleFavorite:U,isFavorite:$,refreshMenu:N},children:t})}function Ce(){const t=n.useContext(Mr);if(t===void 0)throw new Error("useNavigation must be used within a NavigationProvider");return t}const Or=n.createContext(null);function Fr({children:t}){const{isAuthenticated:s,refreshPermissions:r}=Pe(),{refreshMenu:a}=Ce(),o=n.useRef(null),[c,i]=n.useState(oe.HubConnectionState.Disconnected),d=n.useRef(new Set),u=n.useRef(new Set),m=n.useRef(!1),p=n.useCallback(async()=>{if(!m.current){m.current=!0;try{await Promise.all([r(),a()])}catch(h){console.error("[SignalR] Failed to refresh permissions:",h)}finally{m.current=!1}}},[r,a]),x=n.useCallback(async()=>{const h=localStorage.getItem("token");if(h&&!(o.current?.state===oe.HubConnectionState.Connected||o.current?.state===oe.HubConnectionState.Connecting))try{const j=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>h}).withAutomaticReconnect({nextRetryDelayInMilliseconds:v=>v.previousRetryCount===0?0:v.previousRetryCount===1?2e3:v.previousRetryCount===2?1e4:v.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();j.on("ReceiveNotification",v=>{d.current.forEach(S=>S(v))}),j.on("UnreadCountUpdate",v=>{u.current.forEach(S=>S(v))}),j.on("PermissionsChanged",p),j.onreconnecting(()=>{i(oe.HubConnectionState.Reconnecting)}),j.onreconnected(()=>{i(oe.HubConnectionState.Connected)}),j.onclose(()=>{i(oe.HubConnectionState.Disconnected)}),await j.start(),o.current=j,i(oe.HubConnectionState.Connected)}catch(j){console.error("[SignalR] Failed to connect:",j),i(oe.HubConnectionState.Disconnected)}},[p]),f=n.useCallback(async()=>{if(o.current)try{await o.current.stop(),o.current=null,i(oe.HubConnectionState.Disconnected)}catch(h){console.error("[SignalR] Failed to disconnect:",h)}},[]);n.useEffect(()=>(s?x():f(),()=>{f()}),[s,x,f]);const b=n.useCallback(h=>(d.current.add(h),()=>{d.current.delete(h)}),[]),g=n.useCallback(h=>(u.current.add(h),()=>{u.current.delete(h)}),[]),y={isConnected:c===oe.HubConnectionState.Connected,connectionState:c,onNotification:b,onUnreadCountUpdate:g};return e.jsx(Or.Provider,{value:y,children:t})}function _r(){const t=n.useContext(Or);if(!t)throw new Error("useSignalRContext must be used within a SignalRProvider");return t}const Dt={register:async t=>E.post("/api/auth/register",t),confirmEmail:async t=>E.post("/api/auth/confirm-email",{token:t}),resendConfirmation:async t=>E.post("/api/auth/resend-confirmation",{email:t}),forgotPassword:async t=>E.post("/api/auth/forgot-password",{email:t}),resetPassword:async(t,s)=>E.post("/api/auth/reset-password",{token:t,newPassword:s}),login:async(t,s)=>{const r=await E.post("/api/auth/login",{email:t,password:s});return r.token&&(localStorage.setItem("token",r.token),localStorage.setItem("refreshToken",r.refreshToken)),r},logout:async()=>{try{await E.post("/api/auth/logout")}finally{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user")}},changePassword:async(t,s)=>E.post("/api/auth/change-password",{currentPassword:t,newPassword:s}),refreshSession:async()=>{const t=await E.post("/api/auth/refresh");return t.token&&(localStorage.setItem("token",t.token),localStorage.setItem("refreshToken",t.refreshToken)),t},getSessionInfo:async t=>E.get("/api/auth/session-info",{signal:t?.signal})};function Ur(t={}){const{checkIntervalMs:s=6e4,onSessionExpired:r,onWarningThreshold:a,enabled:o=!0}=t,[c,i]=n.useState({isActive:!0,timeRemainingSeconds:0,isWarning:!1,sessionInfo:null}),[d,u]=n.useState(!1),m=n.useRef(!1),p=n.useRef(null),x=n.useRef(null),f=n.useCallback(async g=>{if(!o)return;if(!localStorage.getItem("token")){i(h=>({...h,isActive:!1}));return}try{const h=await Dt.getSessionInfo({signal:g});if(g?.aborted)return;const j=Math.min(h.timeUntilIdleExpirySeconds,h.timeUntilAbsoluteExpirySeconds);i({isActive:!0,timeRemainingSeconds:j,isWarning:h.isWarningThreshold,sessionInfo:h}),h.isWarningThreshold&&!m.current&&(m.current=!0,a?.()),h.isWarningThreshold||(m.current=!1)}catch(h){if(h instanceof Error&&h.name==="CanceledError"||g?.aborted)return;i(j=>({...j,isActive:!1})),r?.()}},[o,r,a]),b=n.useCallback(async()=>{if(d)return!1;u(!0);try{return await Dt.refreshSession(),m.current=!1,await f(),!0}catch{return i(g=>({...g,isActive:!1})),!1}finally{u(!1)}},[d,f]);return n.useEffect(()=>{if(!o)return;x.current?.abort();const g=new AbortController;return x.current=g,f(g.signal),p.current=setInterval(()=>f(),s),()=>{g.abort(),p.current&&clearInterval(p.current)}},[o,s,f]),n.useEffect(()=>{if(!o)return;const g=()=>{c.isWarning&&f()},y=["mousedown","keydown","touchstart","scroll"];return y.forEach(h=>{window.addEventListener(h,g,{passive:!0})}),()=>{y.forEach(h=>{window.removeEventListener(h,g)})}},[o,c.isWarning,f]),{...c,isRefreshing:d,refreshSession:b,checkSession:f}}function Vn(t){if(t<=0)return"0:00";const s=Math.floor(t/60),r=t%60;if(s>=60){const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}return`${s}:${r.toString().padStart(2,"0")}`}function qr({isOpen:t,timeRemainingSeconds:s,onExtendSession:r,onLogout:a}){const{t:o}=ne.useTranslation("common"),[c,i]=n.useState(!1),[d,u]=n.useState(s);n.useEffect(()=>{u(s)},[s]),n.useEffect(()=>{if(!t||d<=0)return;const x=setInterval(()=>{u(f=>f<=1?(a(),0):f-1)},1e3);return()=>clearInterval(x)},[t,d,a]);const m=async()=>{i(!0);try{await r()||a()}finally{i(!1)}};if(!t)return null;const p=Math.max(0,Math.min(100,d/300*100));return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"relative w-full max-w-md bg-[var(--bg-card)] rounded-2xl shadow-2xl border border-amber-500/30 overflow-hidden animate-in fade-in zoom-in duration-200",children:[e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-amber-500/30 w-full",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 transition-all duration-1000 ease-linear",style:{width:`${p}%`}})}),e.jsxs("div",{className:"p-6 pt-8",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/20 flex items-center justify-center mb-4",children:e.jsx(l.Clock,{className:"w-8 h-8 text-amber-500"})}),e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)] mb-2",children:o("session.warningTitle","Session Expiring")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:o("session.warningMessage","Your session will expire due to inactivity.")}),e.jsx("div",{className:"text-4xl font-mono font-bold text-amber-500 tabular-nums",children:Vn(d)}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-2",children:o("session.remainingTime","remaining")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("button",{onClick:a,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-all font-medium",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),o("session.logout","Logout")]}),e.jsxs("button",{onClick:m,disabled:c,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl font-medium transition-all bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 shadow-lg shadow-amber-500/30 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(l.RefreshCw,{className:`w-4 h-4 ${c?"animate-spin":""}`}),c?o("session.extending","Extending..."):o("session.extend","Continue Session")]})]})]})]})})}const Wn=n.createContext(void 0);function Br({children:t}){const{isAuthenticated:s,logout:r}=Pe(),a=n.useCallback(()=>{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),window.location.href="/login?reason=session_expired"},[]),{isActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d}=Ur({enabled:s,checkIntervalMs:3e4,onSessionExpired:a}),u=n.useCallback(async()=>{try{await Dt.logout()}finally{r()}},[r]),m=n.useCallback(async()=>await d(),[d]);return e.jsxs(Wn.Provider,{value:{isSessionActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d},children:[t,e.jsx(qr,{isOpen:i&&s,timeRemainingSeconds:c,onExtendSession:m,onLogout:u})]})}const Xn=150;function Yn({children:t}){const s=zn(),r=s?.isAuthenticated??!1,a=s?.isLoading??!0,{currentTenant:o,isLoading:c,isGlobalView:i}=Ee(),{setSelectedThemeTenant:d,loadFromServer:u}=wt(),m=n.useRef(null),p=n.useRef(!1),x=n.useRef(null),f=n.useRef(null),b=n.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),g=n.useCallback(()=>m.current==="global"?!1:(b(),f.current=null,m.current="global",p.current=!0,u("global"),d(null,!0),!0),[b,u,d]),y=n.useCallback((v,S)=>{f.current=v,x.current=setTimeout(()=>{f.current===v&&(m.current=v,p.current=!0,f.current=null,d(v,!1)),x.current=null},Xn)},[d]),h=n.useCallback(()=>{if(!o)return;const v=o.id!==m.current,S=f.current!==null&&f.current!==o.id;!v&&!S||(b(),v?y(o.id,o.slug):f.current=null)},[o,b,y]),j=n.useCallback(()=>{b(),m.current=null,f.current=null,p.current=!1},[b]);return n.useEffect(()=>{if(!r){j();return}if(!(a||c)){if(i&&!o){g();return}o&&h()}},[r,a,c,o,i,g,h,j]),n.useEffect(()=>()=>{b()},[b]),e.jsx(e.Fragment,{children:t})}function Jn(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Qn(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const Zn={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function zr({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Qn()),i=Jn(t),d=Zn[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-16 h-16 rounded-full ${d.bgColor} flex items-center justify-center mb-6`,children:e.jsx(u,{className:`w-8 h-8 ${d.color}`})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-6 px-3 py-1.5 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),r("errors.home")]})]}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-tertiary)]",children:[r("errors.persistsHelp")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-[var(--color-accent-500)] hover:underline",children:r("errors.contactSupport")})]})]})})})}function eo(t,s){Te.logCritical(t,"GlobalErrorBoundary",{componentStack:s.componentStack})}function to(){window.location.reload()}function Gr({children:t}){return e.jsx(xr.ErrorBoundary,{FallbackComponent:zr,onError:eo,onReset:to,children:t})}const Bt=n.createContext(null);function Kr(){const t=n.useContext(Bt);if(!t)throw new Error("useSlotFill must be used within a SlotFillProvider");return t}function Hr({children:t,initialFills:s}){const r=n.useMemo(()=>{const o=new Map;return s&&Object.entries(s).forEach(([c,i])=>{const d=o.get(c)||[];Array.isArray(i)?o.set(c,[...d,...i]):o.set(c,[...d,i])}),o},[s]),a=n.useMemo(()=>({fills:r,registerFill:(o,c)=>{const i=r.get(o)||[];r.set(o,[...i,c])},unregisterFill:(o,c)=>{const i=r.get(o)||[];r.set(o,i.filter(d=>d!==c))},getSlotContent:o=>r.get(o)||[]}),[r]);return e.jsx(Bt.Provider,{value:a,children:t})}function Vr({name:t,context:s={},children:r,fallback:a,wrapper:o}){const i=n.useContext(Bt)?.getSlotContent(t)||[],d=n.useMemo(()=>({slotName:t,context:s}),[t,s]),u=n.useMemo(()=>i.length===0?a||null:i.map((p,x)=>{const f=`${t}-${x}`;return e.jsx(n.Fragment,{children:Xr(p,d)},f)}),[i,t,d,a]),m=e.jsxs(e.Fragment,{children:[u,r]});return o?e.jsx(o,{children:m}):e.jsx(e.Fragment,{children:m})}function Wr({slot:t,children:s}){const{registerFill:r,unregisterFill:a}=Kr();return n.useMemo(()=>(r(t,s),()=>a(t,s)),[t,s,r,a]),null}function Xr(t,s){if(t==null)return null;if(Array.isArray(t))return e.jsx(e.Fragment,{children:t.map((r,a)=>e.jsx(n.Fragment,{children:Xr(r,s)},`slot-item-${a}`))});if(n.isValidElement(t))return t;if(typeof t=="function"){const r=t;return e.jsx(r,{...s})}return t}function so(t){return(n.useContext(Bt)?.getSlotContent(t)?.length||0)>0}function ro(t){function s(a){return e.jsx(Vr,{...a,name:t})}s.displayName=`Slot(${t})`;function r({children:a}){return e.jsx(Wr,{slot:t,children:a})}return r.displayName=`Fill(${t})`,{Slot:s,Fill:r,slotName:t}}const Yr=n.createContext(null);function St(){const t=n.useContext(Yr);return t||{config:{},getPage:()=>{},getSlotContent:()=>{},getTableColumns:()=>[],getFormFields:()=>[],hasExtension:()=>!1}}function zt(t){const{getPage:s}=St();return s(t)}function ao(t){const{getTableColumns:s}=St();return s(t)}function no(t){const{getFormFields:s}=St();return s(t)}function oo(t){const{hasExtension:s}=St();return s(t)}function Jr({config:t={},children:s}){const r=n.useMemo(()=>{const{pages:a={},slots:o={},tableColumns:c={},formFields:i={}}=t;return{config:t,getPage:d=>a[d],getSlotContent:d=>o[d],getTableColumns:d=>c[d]||[],getFormFields:d=>i[d]||[],hasExtension:d=>d in a||d in o||d in c||d in i}},[t]);return e.jsx(Yr.Provider,{value:r,children:e.jsx(Hr,{initialFills:t.slots,children:s})})}class io{pages=new Map;register(s,r,a=[]){this.pages.set(s,{key:s,defaultComponent:r,slots:a})}get(s){return this.pages.get(s)}resolve(s){return this.pages.get(s)?.defaultComponent}getAll(){return Array.from(this.pages.values())}has(s){return this.pages.has(s)}getSlots(s){return this.pages.get(s)?.slots||[]}keys(){return Array.from(this.pages.keys())}}const O=new io;function lo(t,s){function r(a){const o=zt(t);return o?e.jsx(o,{...a}):e.jsx(s,{...a})}return r.displayName=`Overridable(${t})`,r}function co(t){const s=zt(t),r=O.get(t);return s||r?.defaultComponent}function uo({pageKey:t,defaultComponent:s,params:r}){const a=zt(t),o={pageKey:t,params:r};return a?e.jsx(a,{...o}):e.jsx(s,{...o})}const _={ADMIN_INDEX:"administration",ADMIN_DASHBOARD:"administration.dashboard",USERS_LIST:"administration.users.list",USERS_DETAIL:"administration.users.detail",USERS_DASHBOARD:"administration.users.dashboard",USERS_GROUPS:"administration.users.groups",USERS_GROUPS_DETAIL:"administration.users.groups.detail",USERS_REFERENCES:"administration.users.references",ROLES_LIST:"administration.permissions.roles",ROLES_DETAIL:"administration.permissions.roles.detail",PERMISSIONS_LIST:"administration.permissions.permissions",PERMISSIONS_DETAIL:"administration.permissions.permissions.detail",ASSIGNMENTS:"administration.permissions.assignments",APPLICATIONS_INDEX:"administration.applications",APPLICATIONS_DASHBOARD:"administration.applications.dashboard",APPLICATIONS_LIST:"administration.applications.list",APPLICATIONS_DETAIL:"administration.applications.detail",AI_DASHBOARD:"administration.ai.dashboard",AI_SETTINGS:"administration.ai.settings",AI_SKILLS_LIST:"administration.ai.skills",AI_SKILLS_DETAIL:"administration.ai.skills.detail",AI_SKILLS_CREATE:"administration.ai.skills.create",AI_SKILLS_EDIT:"administration.ai.skills.edit",AI_BLOCKS_LIST:"administration.ai.skills.blocks",AI_BLOCKS_DETAIL:"administration.ai.skills.blocks.detail",AI_BLOCKS_CREATE:"administration.ai.skills.blocks.create",AI_BLOCKS_EDIT:"administration.ai.skills.blocks.edit",AI_MONITORING:"administration.ai.monitoring",AI_AGENTS:"administration.ai.agents",AI_AGENTS_DETAIL:"administration.ai.agents.detail",AI_AGENTS_EDIT:"administration.ai.agents.edit",WORKFLOWS_LIST:"administration.workflows.list",WORKFLOWS_DETAIL:"administration.workflows.detail",WORKFLOWS_CREATE:"administration.workflows.create",WORKFLOWS_EDIT:"administration.workflows.edit",WORKFLOWS_TRIGGERS:"administration.workflows.triggers",WORKFLOWS_HISTORY:"administration.workflows.history",EMAIL_TEMPLATES_LIST:"administration.workflows.email-templates",EMAIL_TEMPLATES_DETAIL:"administration.workflows.email-templates.detail",EMAIL_TEMPLATES_CREATE:"administration.workflows.email-templates.create",EMAIL_TEMPLATES_EDIT:"administration.workflows.email-templates.edit",SMS_TEMPLATES_LIST:"administration.workflows.email-templates.sms",ENTRA_DASHBOARD:"administration.entra.dashboard",ENTRA_GROUPS:"administration.entra.groups",ENTRA_USERS:"administration.entra.users",ENTRA_CONFLICTS:"administration.entra.conflicts",ENTRA_SETTINGS:"administration.entra.settings",TENANTS_DASHBOARD:"administration.tenants.dashboard",TENANTS_LIST:"administration.tenants.list",TENANTS_DETAIL:"administration.tenants.detail",TENANTS_CREATE:"administration.tenants.create",TENANTS_SETTINGS:"administration.tenants.settings",TENANTS_TYPE_SETTINGS:"administration.tenants.type-settings",TENANTS_TEMPLATE:"administration.tenants.template",TENANTS_TEMPLATE_CREATE:"administration.tenants.template.create",TENANTS_TEMPLATE_DETAIL:"administration.tenants.template.detail",TENANTS_BUSINESS:"administration.tenants.list.enterprise",TENANTS_PERSONAL:"administration.tenants.list.personal",TENANTS_OTHER:"administration.tenants.list.other",TENANTS_ACCESS_REQUESTS:"administration.tenants.access-requests",ORGANISATIONS_LIST:"administration.tenants.organisations",ORGANISATIONS_CREATE:"administration.tenants.organisations.create",ORGANISATIONS_DETAIL:"administration.tenants.organisations.detail",SETTINGS:"administration.configuration.settings",SETTINGS_GENERAL:"administration.configuration.settings.general",SETTINGS_FILE_UPLOAD:"administration.configuration.settings.file-upload",SETTINGS_LEGAL_FILE:"administration.configuration.settings.legal-file",APPSETTINGS:"administration.configuration.appsettings",APPSETTINGS_INFRASTRUCTURE:"administration.configuration.appsettings.infrastructure",APPSETTINGS_AUTHENTICATION:"administration.configuration.appsettings.authentication",APPSETTINGS_LOGGING:"administration.configuration.appsettings.logging",APPSETTINGS_EMAIL:"administration.configuration.appsettings.email",APPSETTINGS_ENTRA:"administration.configuration.appsettings.entra",LICENSE:"administration.configuration.license",API_ACCOUNTS_LIST:"api.accounts.list",API_ACCOUNTS_CREATE:"api.accounts.create",API_ACCOUNTS_DETAIL:"api.accounts.detail",API_CATALOG:"api.apis.catalog",API_CATALOG_DETAIL:"api.apis.catalog.detail",SUPPORT_DASHBOARD:"support.tickets",TICKETS_LIST:"support.tickets.list",TICKETS_DETAIL:"support.tickets.detail",TICKETS_ESCALATION:"support.tickets.escalation",TICKETS_NEW:"support.tickets.new",MY_TICKETS_LIST:"support.my-tickets",MY_TICKETS_DETAIL:"support.my-tickets.detail",MY_TICKETS_CREATE:"support.my-tickets.create",SUPPORT_SLA:"support.admin.sla",SUPPORT_TEMPLATES:"support.admin.templates",SUPPORT_PERMISSIONS:"support.admin.permissions",SUPPORT_ASSIGNMENT:"support.assignment",SUPPORT_ASSIGNMENT_SKILLS:"support.assignment.skills",SUPPORT_ASSIGNMENT_WORKLOAD:"support.assignment.workload",MYSPACE_DASHBOARD:"myspace.dashboard",USER_PROFILE:"myspace.profile",USER_PREFERENCES:"myspace.preferences",MYSPACE_TENANTS:"myspace.tenants.workspaces",MYSPACE_ACCESS_REQUESTS:"myspace.tenants.access-requests",MYSPACE_PORTAL:"myspace.portal",NOTIFICATIONS:"notifications",APPLICATIONS_HUB:"applications"};O.register(_.ADMIN_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsGridPage-DDysNWJ5.js")).then(t=>({default:t.ApplicationsGridPage}))));O.register(_.ADMIN_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-4oy2YqvT.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./UsersPage-DcwLyMAX.js")).then(t=>({default:t.UsersPage}))));O.register(_.USERS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserDetailPage-BRFowOFL.js")).then(t=>({default:t.UserDetailPage}))));O.register(_.USERS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-4oy2YqvT.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./UsersGroupsPage-DTmhzttW.js")).then(t=>({default:t.UsersGroupsPage}))));O.register(_.USERS_GROUPS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./GroupDetailPage-C-kvtd2T.js")).then(t=>({default:t.GroupDetailPage}))));O.register(_.USERS_REFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./ReferencesManagementPage-CLsaUNqA.js")).then(t=>({default:t.ReferencesManagementPage}))));O.register(_.ROLES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./RolesPage-CAcols3D.js")).then(t=>({default:t.RolesPage}))));O.register(_.ROLES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./RoleDetailPage-TUOGR1ow.js")).then(t=>({default:t.RoleDetailPage}))));O.register(_.PERMISSIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionsPage-Dbjcctuh.js")).then(t=>({default:t.PermissionsPage}))));O.register(_.PERMISSIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionDetailPage-CUNKbl7t.js")).then(t=>({default:t.PermissionDetailPage}))));O.register(_.ASSIGNMENTS,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentsPage-Bp7oQD7Q.js")).then(t=>({default:t.AssignmentsPage}))));O.register(_.APPLICATIONS_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./NavigationAppsPage-DXvpLsbt.js")).then(t=>({default:t.NavigationAppsPage}))));O.register(_.APPLICATIONS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsDashboardPage-BSsHN3Yj.js")).then(t=>({default:t.ApplicationsDashboardPage}))));O.register(_.APPLICATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsListPage-B6ZCecIl.js")).then(t=>({default:t.ApplicationsListPage}))));O.register(_.APPLICATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationDetailPage--9YwwS5A.js"))));O.register(_.AI_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiDashboardPage}))));O.register(_.AI_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiSettingsPage}))));O.register(_.AI_SKILLS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiSkillsListPage}))));O.register(_.AI_SKILLS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiSkillsDetailPage}))));O.register(_.AI_SKILLS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_SKILLS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_BLOCKS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiBlockDefinitionsListPage}))));O.register(_.AI_BLOCKS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiBlockDefinitionDetailPage}))));O.register(_.AI_BLOCKS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_BLOCKS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_MONITORING,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiMonitoringPage}))));O.register(_.AI_AGENTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiAgentsPage}))));O.register(_.AI_AGENTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiAgentDetailPage}))));O.register(_.AI_AGENTS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-D0HS542b.js")).then(t=>({default:t.AiAgentEditPage}))));O.register(_.WORKFLOWS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowsListPage}))));O.register(_.WORKFLOWS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowDetailPage}))));O.register(_.WORKFLOWS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowCreatePage}))));O.register(_.WORKFLOWS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowEditPage}))));O.register(_.WORKFLOWS_TRIGGERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowsTriggersPage}))));O.register(_.WORKFLOWS_HISTORY,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.WorkflowHistoryPage}))));O.register(_.EMAIL_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.EmailTemplatesListPage}))));O.register(_.EMAIL_TEMPLATES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.EmailTemplateDetailPage}))));O.register(_.EMAIL_TEMPLATES_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.EmailTemplateCreatePage}))));O.register(_.EMAIL_TEMPLATES_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.EmailTemplateEditPage}))));O.register(_.SMS_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-DqbVFB1H.js")).then(t=>({default:t.SmsTemplatesListPage}))));O.register(_.ENTRA_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-DUS-tunb.js")).then(t=>({default:t.EntraDashboardPage}))));O.register(_.ENTRA_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DUS-tunb.js")).then(t=>({default:t.EntraGroupsPage}))));O.register(_.ENTRA_USERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DUS-tunb.js")).then(t=>({default:t.EntraUsersPage}))));O.register(_.ENTRA_CONFLICTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DUS-tunb.js")).then(t=>({default:t.EntraConflictsPage}))));O.register(_.ENTRA_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DUS-tunb.js")).then(t=>({default:t.EntraSettingsPage}))));O.register(_.TENANTS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsDashboardPage}))));O.register(_.TENANTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsPage}))));O.register(_.TENANTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantDetailPage}))));O.register(_.TENANTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantCreatePage}))));O.register(_.TENANTS_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantSettingsPage}))));O.register(_.TENANTS_TYPE_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantTypeSettingsPage}))));O.register(_.TENANTS_TEMPLATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsTemplatePage}))));O.register(_.TENANTS_TEMPLATE_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantTemplateCreatePage}))));O.register(_.TENANTS_TEMPLATE_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantTemplateDetailPage}))));O.register(_.TENANTS_BUSINESS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsBusinessPage}))));O.register(_.TENANTS_PERSONAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsPersonalPage}))));O.register(_.TENANTS_OTHER,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantsOtherPage}))));O.register(_.TENANTS_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.TenantAccessRequestsPage}))));O.register(_.ORGANISATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.OrganisationsListPage}))));O.register(_.ORGANISATIONS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.OrganisationCreatePage}))));O.register(_.ORGANISATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CUICSveU.js")).then(t=>({default:t.OrganisationDetailPage}))));O.register(_.SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-HsAOBno4.js")).then(t=>({default:t.SettingsPage}))));O.register(_.SETTINGS_GENERAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-HsAOBno4.js")).then(t=>({default:t.GeneralSettingsSection}))));O.register(_.SETTINGS_FILE_UPLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./index-HsAOBno4.js")).then(t=>({default:t.FileUploadSettingsSection}))));O.register(_.SETTINGS_LEGAL_FILE,n.lazy(()=>Promise.resolve().then(()=>require("./index-HsAOBno4.js")).then(t=>({default:t.LegalFileSettingsSection}))));O.register(_.APPSETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.AppSettingsPage}))));O.register(_.APPSETTINGS_INFRASTRUCTURE,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.InfrastructureSection}))));O.register(_.APPSETTINGS_AUTHENTICATION,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.AuthenticationSection}))));O.register(_.APPSETTINGS_LOGGING,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.LoggingSection}))));O.register(_.APPSETTINGS_EMAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.EmailSection}))));O.register(_.APPSETTINGS_ENTRA,n.lazy(()=>Promise.resolve().then(()=>require("./index-xhRXN1Jq.js")).then(t=>({default:t.EntraSection}))));O.register(_.LICENSE,n.lazy(()=>Promise.resolve().then(()=>require("./index-DF93KQFR.js")).then(t=>({default:t.LicenseManagementPage}))));O.register(_.API_ACCOUNTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-DwqLhQ8S.js")).then(t=>({default:t.ExternalAppsListPage}))));O.register(_.API_ACCOUNTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-DwqLhQ8S.js")).then(t=>({default:t.ExternalAppCreatePage}))));O.register(_.API_ACCOUNTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-DwqLhQ8S.js")).then(t=>({default:t.ExternalAppDetailPage}))));O.register(_.API_CATALOG,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogPage-DqboIzZE.js")).then(t=>({default:t.ApiCatalogPage}))));O.register(_.API_CATALOG_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogDetailPage-DX8buBkV.js")).then(t=>({default:t.ApiCatalogDetailPage}))));O.register(_.SUPPORT_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CPArUG-S.js")).then(t=>({default:t.DashboardPage}))));O.register(_.TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./TicketsPage-Dwi2xpMI.js")).then(t=>({default:t.TicketsPage}))));O.register(_.TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./TicketDetailPage-xN3wPnFL.js")).then(t=>({default:t.TicketDetailPage}))));O.register(_.TICKETS_ESCALATION,n.lazy(()=>Promise.resolve().then(()=>require("./EscalationConfigPage-DnjLFXnL.js")).then(t=>({default:t.EscalationConfigPage}))));O.register(_.TICKETS_NEW,n.lazy(()=>Promise.resolve().then(()=>require("./CreateSupportTicketPage-C2X2mfds.js")).then(t=>({default:t.CreateSupportTicketPage}))));O.register(_.MY_TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./MyTicketsPage-DOUhaLal.js")).then(t=>({default:t.MyTicketsPage}))));O.register(_.MY_TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserTicketDetailPage-BstGk_BP.js")).then(t=>({default:t.UserTicketDetailPage}))));O.register(_.MY_TICKETS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./UserCreateTicketPage-D2a3EOey.js")).then(t=>({default:t.UserCreateTicketPage}))));O.register(_.SUPPORT_SLA,n.lazy(()=>Promise.resolve().then(()=>require("./SlaConfigPage-D5TRn7Ir.js")).then(t=>({default:t.SlaConfigPage}))));O.register(_.SUPPORT_TEMPLATES,n.lazy(()=>Promise.resolve().then(()=>require("./TemplatesPage-nTY85sNA.js")).then(t=>({default:t.TemplatesPage}))));O.register(_.SUPPORT_PERMISSIONS,n.lazy(()=>Promise.resolve().then(()=>require("./SupportPermissionsPage-UXmYLrIq.js")).then(t=>({default:t.SupportPermissionsPage}))));O.register(_.SUPPORT_ASSIGNMENT,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentRulesPage-CK4L4rBO.js")).then(t=>({default:t.AssignmentRulesPage}))));O.register(_.SUPPORT_ASSIGNMENT_SKILLS,n.lazy(()=>Promise.resolve().then(()=>require("./AgentSkillsPage-DJb49NMA.js")).then(t=>({default:t.AgentSkillsPage}))));O.register(_.SUPPORT_ASSIGNMENT_WORKLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./AgentWorkloadPage-D_nk3gKj.js")).then(t=>({default:t.AgentWorkloadPage}))));O.register(_.MYSPACE_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./UserDashboardPage-ZMsx8LWw.js")).then(t=>({default:t.UserDashboardPage}))));O.register(_.USER_PROFILE,n.lazy(()=>Promise.resolve().then(()=>require("./ProfilePage-eowQd59_.js")).then(t=>({default:t.ProfilePage}))));O.register(_.USER_PREFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./PreferencesPage-BCpuIGzv.js")).then(t=>({default:t.PreferencesPage}))));O.register(_.MYSPACE_TENANTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyTenantsPage-CZRkMbh8.js")).then(t=>({default:t.MyTenantsPage}))));O.register(_.MYSPACE_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyAccessRequestsPage-CP41FzHi.js"))));O.register(_.MYSPACE_PORTAL,n.lazy(()=>Promise.resolve().then(()=>require("./PortalDashboardPage-BeNfBZmb.js")).then(t=>({default:t.PortalDashboardPage}))));O.register(_.NOTIFICATIONS,n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-I1yCk7tk.js")).then(t=>({default:t.NotificationsPage}))));O.register(_.APPLICATIONS_HUB,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-BBaiBM--.js")).then(t=>({default:t.ApplicationsPage}))));const mo=n.createContext(null);function po({config:t,children:s}){typeof window<"u"&&(window.__SMARTSTACK_CONFIG__=t);const r=n.useMemo(()=>({config:t}),[t]);return e.jsx(mo.Provider,{value:r,children:e.jsx(Gr,{children:e.jsx(Jr,{config:t.extensions,children:e.jsx(yr,{children:e.jsx(Bn,{children:e.jsx(Cr,{children:e.jsx(Gn,{children:e.jsx(Pr,{children:e.jsx(Er,{children:e.jsx($r,{children:e.jsx(Br,{children:e.jsx(Yn,{children:e.jsx(fs,{children:e.jsx(Fr,{children:s})})})})})})})})})})})})})})}const Qr="smartstack-doc-panel-size",Zr=n.createContext(void 0);function xo(){if(typeof window>"u")return 33;try{const t=localStorage.getItem(Qr);if(t){const s=parseFloat(t);if(s>=20&&s<=60)return s}}catch{}return 33}const Is={"administration/users":"/docs/business/administration/users","administration/users/dashboard":"/docs/business/administration/users","administration/users/list":"/docs/business/administration/users","administration/users/create":"/docs/business/administration/users","administration/users/groups":"/docs/business/administration/users/groups","administration/users/references":"/docs/business/administration/users/references","administration/permissions":"/docs/business/administration/permissions","administration/permissions/roles":"/docs/business/administration/permissions","administration/permissions/permissions":"/docs/business/administration/permissions","administration/permissions/assignments":"/docs/business/administration/permissions/assignments","administration/applications":"/docs/business/administration/applications","administration/applications/list":"/docs/business/administration/applications","administration/applications/grid":"/docs/business/administration/applications","administration/applications/dashboard":"/docs/business/administration/applications","administration/tenants":"/docs/business/administration/tenants","administration/tenants/dashboard":"/docs/business/administration/tenants","administration/tenants/create":"/docs/business/administration/tenants","administration/tenants/list":"/docs/business/administration/tenants/business","administration/tenants/list/enterprise":"/docs/business/administration/tenants/business","administration/tenants/list/personal":"/docs/business/administration/tenants/personal","administration/tenants/list/other":"/docs/business/administration/tenants/other","administration/tenants/template":"/docs/business/administration/tenants/template","administration/tenants/business":"/docs/business/administration/tenants/business","administration/tenants/personal":"/docs/business/administration/tenants","administration/tenants/organisations":"/docs/business/administration/tenants/organisations","administration/tenants/organisations/create":"/docs/business/administration/tenants/organisations","administration/tenants/access-requests":"/docs/business/administration/tenants/access-requests","administration/tenants/applications":"/docs/business/administration/tenants/applications","administration/workflows":"/docs/business/administration/workflows","administration/workflows/list":"/docs/business/administration/workflows","administration/workflows/create":"/docs/business/administration/workflows","administration/workflows/triggers":"/docs/business/administration/workflows","administration/workflows/history":"/docs/business/administration/workflows","administration/workflows/email-templates":"/docs/business/administration/workflows","administration/workflows/email-templates/email":"/docs/business/administration/workflows","administration/workflows/email-templates/sms":"/docs/business/administration/workflows","administration/workflows/email-templates/create":"/docs/business/administration/workflows","administration/ai":"/docs/business/administration/ai","administration/ai/dashboard":"/docs/business/administration/ai","administration/ai/settings":"/docs/business/administration/ai","administration/ai/providers":"/docs/business/administration/ai","administration/ai/models":"/docs/business/administration/ai","administration/ai/prompts":"/docs/business/administration/ai","administration/ai/blocks":"/docs/business/administration/ai","administration/entra":"/docs/business/administration/entra","administration/entra/dashboard":"/docs/business/administration/entra","administration/entra/groups":"/docs/business/administration/entra","administration/entra/users":"/docs/business/administration/entra","administration/entra/conflicts":"/docs/business/administration/entra","administration/entra/settings":"/docs/business/administration/entra","administration/configuration":"/docs/business/administration/configuration","administration/configuration/settings":"/docs/business/administration/configuration","administration/configuration/appsettings":"/docs/business/administration/configuration","administration/configuration/license":"/docs/business/administration/configuration/license","support/tickets":"/system/docs/user/support-dashboard","support/tickets/list":"/docs/business/platform/support/tickets","support/tickets/escalation":"/system/docs/user/support-escalation","support/my-tickets":"/docs/business/platform/support/tickets","support/my-tickets/list":"/docs/business/platform/support/tickets","support/my-tickets/create":"/docs/business/platform/support/tickets","support/admin/sla":"/system/docs/user/support-sla","support/admin/templates":"/system/docs/user/support-templates","myspace/profile":"/system/docs/user/modules","myspace/preferences":"/system/docs/user/modules","myspace/tenants":"/system/docs/user/modules","myspace/portal":"/system/docs/user/modules"},Ls={administration:"/docs/business/administration/users",support:"/system/docs/user/support-dashboard",myspace:"/system/docs/user/modules"};function $s(t){const s=t.split("/").filter(Boolean),a=s[0]==="t"&&s.length>=3?2:0,o=s.slice(a),c=o[0],i=o.slice(1);if(i.length>0)for(let d=i.length;d>0;d--){const u=`${c}/${i.slice(0,d).join("/")}`;if(Is[u])return Is[u]}return c&&Ls[c]?Ls[c]:"/system/docs/user"}function ea({children:t}){const[s,r]=n.useState(!1),[a,o]=n.useState(xo),[c,i]=n.useState(null),d=w.useLocation(),u=n.useRef(d.pathname);n.useEffect(()=>{u.current!==d.pathname&&(u.current=d.pathname,r(!1))},[d.pathname]),n.useEffect(()=>{a>=20&&a<=60&&localStorage.setItem(Qr,String(a))},[a]);const m=n.useCallback(b=>{const g=b||$s(d.pathname);i(g),r(!0)},[d.pathname]),p=n.useCallback(()=>{r(!1)},[]),x=n.useCallback(()=>{if(s)r(!1);else{const b=$s(d.pathname);i(b),r(!0)}},[s,d.pathname]),f=n.useCallback(b=>{b>=20&&b<=60&&o(b)},[]);return e.jsx(Zr.Provider,{value:{isOpen:s,panelSize:a,docUrl:c,openDocPanel:m,closeDocPanel:p,toggleDocPanel:x,setPanelSize:f},children:t})}function Gt(){const t=n.useContext(Zr);if(t===void 0)throw new Error("useDocPanel must be used within a DocPanelProvider");return t}class ho{captureBrowserInfo(){const s=navigator.userAgent;return{browser:this.getBrowserName(s),browserVersion:this.getBrowserVersion(s),os:this.getOSName(s),osVersion:this.getOSVersion(s),language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`,deviceType:this.getDeviceType(s)}}getBrowserName(s){return s.includes("Firefox")?"Firefox":s.includes("Edg/")?"Microsoft Edge":s.includes("Chrome")&&!s.includes("Edg/")?"Google Chrome":s.includes("Safari")&&!s.includes("Chrome")?"Safari":s.includes("Opera")||s.includes("OPR/")?"Opera":s.includes("MSIE")||s.includes("Trident/")?"Internet Explorer":"Unknown Browser"}getBrowserVersion(s){let r=null;return s.includes("Firefox")?r=/Firefox\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Edg/")?r=/Edg\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Chrome")&&!s.includes("Edg/")?r=/Chrome\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Safari")&&!s.includes("Chrome")?r=/Version\/(\d+(?:\.\d+)*)/.exec(s):s.includes("OPR/")&&(r=/OPR\/(\d+(?:\.\d+)*)/.exec(s)),r?r[1]:"Unknown"}getOSName(s){return s.includes("Windows NT 10")?"Windows 10/11":s.includes("Windows NT 6.3")?"Windows 8.1":s.includes("Windows NT 6.2")?"Windows 8":s.includes("Windows NT 6.1")?"Windows 7":s.includes("Windows")?"Windows":s.includes("Mac OS X")?"macOS":s.includes("Linux")&&s.includes("Android")?"Android":s.includes("Linux")?"Linux":s.includes("iPhone")||s.includes("iPad")?"iOS":s.includes("CrOS")?"Chrome OS":"Unknown OS"}getWindowsVersion(s){return s==="10.0"?"10/11":s==="6.3"?"8.1":s==="6.2"?"8":s==="6.1"?"7":s}getOSVersion(s){if(s.includes("Windows NT")){const r=/Windows NT (\d+\.\d+)/.exec(s);if(r)return this.getWindowsVersion(r[1])}if(s.includes("Mac OS X")){const r=/Mac OS X (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}if(s.includes("Android")){const r=/Android (\d+(?:\.\d+)*)/.exec(s);if(r)return r[1]}if(s.includes("iPhone OS")||s.includes("iPad")){const r=/(?:iPhone|iPad|CPU) OS (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}return"Unknown"}getDeviceType(s){return/Tablet|iPad/i.test(s)?"Tablet":/Mobile|iPhone|Android.*Mobile/i.test(s)?"Mobile":"Desktop"}formatForDescription(s){return[`Browser: ${s.browser} ${s.browserVersion}`,`OS: ${s.os} ${s.osVersion}`,`Device: ${s.deviceType}`,`Screen: ${s.screenResolution}`,`Language: ${s.language}`].join(`
2
+ `)}}const ta=new ho;function go(){return{captureContext:n.useCallback(()=>{const s=ta.captureBrowserInfo(),r=Te.getRecentErrors().slice(0,5);return{sourceUrl:window.location.href,browser:{name:s.browser,version:s.browserVersion,language:s.language},os:{name:s.os,version:s.osVersion},device:{type:s.deviceType,screenResolution:s.screenResolution},recentErrors:r.map(a=>({message:a.message,stack:a.stack,component:a.component,timestamp:a.timestamp.toISOString()}))}},[])}}function fo(){const[t,s]=n.useState(new Set),[r,a]=n.useState(new Set),o=n.useCallback(p=>{s(x=>{const f=new Set(x);return f.has(p)?f.delete(p):f.add(p),f})},[]),c=n.useCallback(p=>{a(x=>{const f=new Set(x);return f.has(p)?f.delete(p):f.add(p),f})},[]),i=n.useCallback(()=>{s(new Set),a(new Set)},[]),d=n.useCallback((p,x)=>{s(new Set(p)),a(new Set(x))},[]),u=n.useCallback(p=>t.has(p),[t]),m=n.useCallback(p=>r.has(p),[r]);return{collapsedContexts:t,collapsedApps:r,toggleContext:o,toggleApp:c,expandAll:i,collapseAll:d,isContextCollapsed:u,isAppCollapsed:m}}const bs="/api/myspace/application-tracking",bo="00000000-0000-0000-0000-000000000000",Ds=t=>!!t&&t!==bo,sa=t=>{const s=/^\/t\/[^/]+(\/.*)$/.exec(t);return s?s[1]:t},vo=t=>{const s=sa(t);return s.startsWith("/administration/")||s.startsWith("/support/")||s.startsWith("/myspace/")},ra=(t,s)=>{if(!t||typeof t!="object"||!("status"in t))return!0;const r=t.status;return!s.includes(r??-1)},yo=async(t,s)=>{const r=new Date,a=Math.floor((r.getTime()-s.getTime())/1e3);try{await E.post(`${bs}/end`,{accessId:t,endedAt:r.toISOString(),durationSeconds:a})}catch(o){ra(o,[401,408])&&console.error("Failed to end page tracking:",o)}},jo=async t=>{const s=new Date;try{return(await E.post(`${bs}/start`,{route:t,accessedAt:s.toISOString()})).accessId}catch(r){return ra(r,[401])&&console.error("Failed to track page access:",r),null}},No=(t,s)=>{const r=localStorage.getItem("token");if(!r)return;const a=new Date,o=Math.floor((a.getTime()-s.getTime())/1e3);fetch(`${bs}/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({accessId:t,endedAt:a.toISOString(),durationSeconds:o}),keepalive:!0}).catch(()=>{})};function aa(){const t=w.useLocation(),s=n.useRef(new Date),r=n.useRef(null),a=n.useRef(!1);n.useEffect(()=>a.current?void 0:((async()=>{const c=sa(t.pathname);vo(c)&&(a.current=!0,Ds(r.current)&&await yo(r.current,s.current),s.current=new Date,r.current=await jo(c),a.current=!1)})(),()=>{Ds(r.current)&&No(r.current,s.current)}),[t.pathname])}function wo(t={}){const{canEditSystemRoles:s=!1}=t,{t:r,i18n:a}=ne.useTranslation("admin"),[o,c]=n.useState(!0),[i,d]=n.useState(null),[u,m]=n.useState(null),[p,x]=n.useState(!1),[f,b]=n.useState(!1),[g,y]=n.useState([]),[h,j]=n.useState([]),[v,S]=n.useState(new Map),[N,I]=n.useState({}),[P,k]=n.useState({}),[A,R]=n.useState({}),[$,U]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all",categoryFilter:"all"}),C=n.useRef(null),D=n.useRef(new Map),Y=n.useCallback((q,W,ee)=>{const te=q.has(ee),se=W.get(ee);if(!se)return{isDirect:te,isInherited:!1};const me=se.path.toLowerCase();let ie,ve,be=1/0;for(const Me of Array.from(q)){const Le=W.get(Me);if(!Le||Me===ee)continue;const Be=Le.path.toLowerCase();if((Le.isWildcard||Be.endsWith(".*"))&&Ut(Be,me)){const We=Be.split(".").length;We<be&&(be=We,ie=Le.path,ve=Le.id)}}return{isDirect:te,isInherited:ie!==void 0,inheritedFromPath:ie,inheritedFromId:ve}},[]),T=n.useCallback((q,W)=>{const ee={};return Object.entries(q).forEach(([te,se])=>{const me=new Map;W.forEach((ie,ve)=>{const be=Y(se,W,ve);me.set(ve,be)}),ee[te]=me}),ee},[Y]),B=(q,W,ee,te)=>{const se=[],me=[];return q.resources.forEach(ie=>{const ve=ie.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),be=te.get(ve)||[],Ie={id:ie.id,path:ie.permissionPath,label:ie.label,applicationLabel:ee.label,moduleLabel:ie.label,parentModuleLabel:W.label,parentModuleId:W.id,parentSectionLabel:q.label,parentSectionId:q.id,level:"resource",permissions:be,totalPermissions:be.length};se.push(Ie),me.push(Ie)}),{childResources:se,nodes:me}},Z=(q,W,ee)=>{const te=[],se=[];return q.sections.forEach(me=>{const ie=me.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),ve=ee.get(ie)||[],{childResources:be,nodes:Ie}=B(me,q,W,ee),Me=be.reduce((et,We)=>et+We.totalPermissions,0),Le=ve.length+Me,Be={id:me.id,path:me.permissionPath,label:me.label,applicationLabel:W.label,moduleLabel:me.label,parentModuleLabel:q.label,parentModuleId:q.id,level:"section",permissions:ve,totalPermissions:Le,childResources:be.length>0?be:void 0};te.push(Be),se.push(Be),se.push(...Ie)}),{childSections:te,nodes:se}},H=(q,W,ee,te)=>{const se=q.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),me=ee.get(se)||[],{childSections:ie,nodes:ve}=Z(q,W,ee),be=ie.reduce((Me,Le)=>Me+Le.totalPermissions,0),Ie=me.length+be;te.push({id:q.id,path:q.permissionPath,label:q.label,applicationLabel:W.label,moduleLabel:q.label,level:"module",permissions:me,totalPermissions:Ie,childSections:ie.length>0?ie:void 0}),te.push(...ve)},J=(q,W,ee)=>{q.modules.forEach(te=>{H(te,q,W,ee)})},fe=n.useCallback((q,W)=>{const ee=[];if(!q||!q.applications||!W||!Array.isArray(W))return ee;const te=new Map;return W.forEach(se=>{const ie=se.path.toLowerCase().split(".");if(ie.length>=2){const ve=ie.slice(0,-1).join("."),be=te.get(ve)||[];be.push({id:se.id,action:ie.at(-1),path:se.path}),te.set(ve,be)}}),q.applications.forEach(se=>{J(se,te,ee)}),ee.sort((se,me)=>{const ie=se.applicationLabel.localeCompare(me.applicationLabel);return ie!==0?ie:se.moduleLabel.localeCompare(me.moduleLabel)})},[]),z=n.useCallback(async()=>{try{c(!0),d(null);const q=await Ne.permissions.getMatrix(),W={};q.roles.forEach(ie=>{W[ie.id]=new Set(ie.permissionIds)});const ee=new Map(q.permissions.map(ie=>[ie.id,ie])),te=fe(q.tree,q.permissions),se=T(W,ee);y(q.roles),j(te),S(ee),I(W),R(se);const me=Object.entries(W).reduce((ie,[ve,be])=>(ie[ve]=new Set(Array.from(be)),ie),{});k(me),D.current.clear()}catch(q){d(q instanceof Error?q.message:"Failed to load permission matrix data")}finally{c(!1)}},[fe,T]);n.useEffect(()=>{z()},[z,a.language]),n.useEffect(()=>{if(v.size>0){const q=T(N,v);R(q)}},[N,v,T]);const Q=n.useCallback(async()=>{if(D.current.size===0)return;const q=new Map(D.current);D.current.clear(),x(!0),m(null);try{const W=Array.from(q.entries()).map(async([se,me])=>{const ie=g.find(ve=>ve.id===se);ie&&await Ne.roles.update(se,{name:ie.name,shortName:ie.shortName,category:ie.category,description:ie.description||void 0,permissionIds:Array.from(me)})});await Promise.all(W);const ee=JSON.parse(JSON.stringify(Object.fromEntries(Object.entries(N).map(([se,me])=>[se,Array.from(me)])))),te=Object.entries(ee).reduce((se,[me,ie])=>(se[me]=new Set(ie),se),{});k(te),b(!0),setTimeout(()=>{b(!1)},3e3)}catch(W){console.error("Failed to save permission changes:",W);let ee="Failed to save changes";if(W&&typeof W=="object"&&"response"in W){const te=W.response;te?.status===403?ee=r("assignments.noPermissionToEditRole"):te?.data?.message&&(ee=te.data.message)}else W instanceof Error&&(ee=W.message);m(ee),await z()}finally{x(!1)}},[g,N,z]),M=n.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{Q()},500)},[Q]),re=n.useCallback((q,W)=>{g.find(te=>te.id===q)?.isSystem&&!s||I(te=>{const se=new Set(te[q]||[]);return se.has(W)?se.delete(W):se.add(W),D.current.set(q,se),M(),{...te,[q]:se}})},[g,s,M]),F=q=>{h.forEach(W=>{W.permissions.forEach(ee=>{q.add(ee.id)})})},K=n.useCallback((q,W)=>{g.find(te=>te.id===q)?.isSystem&&!s||I(te=>{const se=new Set;return W&&F(se),D.current.set(q,se),M(),{...te,[q]:se}})},[g,s,h,M]),V=(q,W,ee)=>{W.permissions.forEach(te=>{ee?q.add(te.id):q.delete(te.id)})},ae=n.useCallback((q,W)=>{I(ee=>{const te={...ee};return g.forEach(se=>{if(se.isSystem&&!s)return;const me=new Set(te[se.id]||[]);V(me,q,W),te[se.id]=me,D.current.set(se.id,me)}),M(),te})},[g,s,M]),ue=n.useCallback(q=>{U(W=>({...W,...q}))},[]),G=n.useCallback(()=>{const q=Object.entries(P).reduce((W,[ee,te])=>(W[ee]=new Set(Array.from(te)),W),{});I(q),D.current.clear(),C.current&&clearTimeout(C.current)},[P]),ce=n.useMemo(()=>g.filter(q=>$.selectedRoleIds.length===0?!0:$.selectedRoleIds.includes(q.id)),[g,$.selectedRoleIds]),de=n.useMemo(()=>h.filter(q=>!($.resourceSearch&&!q.moduleLabel.toLowerCase().includes($.resourceSearch.toLowerCase())||$.applicationFilter!=="all"&&q.applicationLabel!==$.applicationFilter||$.moduleFilter!=="all"&&q.moduleLabel!==$.moduleFilter)),[h,$]),he=n.useMemo(()=>Array.from(Object.entries(N)).some(([q,W])=>{const ee=P[q];return ee?W.size!==ee.size?!0:Array.from(W).some(te=>!ee.has(te)):W.size>0}),[N,P]),pe=n.useMemo(()=>{const q=new Map;return h.forEach(W=>{q.has(W.applicationLabel)||q.set(W.applicationLabel,{app:W.applicationLabel,label:W.applicationLabel})}),Array.from(q.values()).sort((W,ee)=>W.label.localeCompare(ee.label))},[h]),ye=n.useMemo(()=>h.filter(q=>q.level==="module").map(q=>({app:q.applicationLabel,module:q.label,label:q.label})).sort((q,W)=>q.label.localeCompare(W.label)),[h]),Ue=n.useMemo(()=>{const q=new Set(g.map(ee=>ee.category));return["Global","Admin","Manager","Contributor","Viewer","Custom"].filter(ee=>q.has(ee))},[g]),qe=n.useCallback((q,W)=>{const ee=A[q];return ee?ee.get(W)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[A]),Ve=n.useCallback(()=>{m(null)},[]);return{loading:o,error:i,saveError:u,saving:p,saveSuccess:f,roles:g,resources:h,permissions:v,assignments:N,inheritanceMap:A,filters:$,filteredRoles:ce,filteredResources:de,hasChanges:he,canEditSystemRoles:s,applications:pe,modules:ye,categories:Ue,togglePermission:re,toggleAllForRole:K,toggleAllForResource:ae,updateFilters:ue,reloadData:z,resetChanges:G,saveChanges:Q,clearSaveError:Ve,getPermissionInheritance:qe}}function na(t={}){const s=n.useRef(null),[r,a]=n.useState(oe.HubConnectionState.Disconnected),o=n.useRef(t);o.current=t;const c=n.useCallback(()=>localStorage.getItem("token"),[]),i=n.useCallback(async()=>{const u=c();if(u&&s.current?.state!==oe.HubConnectionState.Connected)try{const m=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>u}).withAutomaticReconnect({nextRetryDelayInMilliseconds:p=>p.previousRetryCount===0?0:p.previousRetryCount===1?2e3:p.previousRetryCount===2?1e4:p.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();m.on("ReceiveNotification",p=>{o.current.onNotification?.(p)}),m.on("UnreadCountUpdate",p=>{o.current.onUnreadCountUpdate?.(p)}),m.on("PermissionsChanged",()=>{o.current.onPermissionsChanged?.()}),m.onreconnecting(()=>{a(oe.HubConnectionState.Reconnecting),o.current.onConnectionStateChange?.(oe.HubConnectionState.Reconnecting)}),m.onreconnected(()=>{a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}),m.onclose(()=>{a(oe.HubConnectionState.Disconnected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Disconnected)}),await m.start(),s.current=m,a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}catch(m){console.error("SignalR: Failed to connect",m),a(oe.HubConnectionState.Disconnected)}},[c]),d=n.useCallback(async()=>{if(s.current)try{await s.current.stop(),s.current=null,a(oe.HubConnectionState.Disconnected)}catch(u){console.error("SignalR: Failed to disconnect",u)}},[]);return n.useEffect(()=>(i(),()=>{d()}),[i,d]),n.useEffect(()=>{const u=m=>{m.key==="token"&&(m.newValue?i():d())};return window.addEventListener("storage",u),()=>window.removeEventListener("storage",u)},[i,d]),{connectionState:r,isConnected:r===oe.HubConnectionState.Connected,connect:i,disconnect:d}}function So(){const{refreshPermissions:t,user:s}=Pe(),{refreshMenu:r}=Ce(),a=n.useRef(!1),o=n.useCallback(async()=>{if(!a.current){a.current=!0;try{await Promise.all([t(),r()])}catch(d){console.error("[PermissionSync] Failed to refresh permissions:",d)}finally{a.current=!1}}},[t,r]),{isConnected:c,connectionState:i}=na({onPermissionsChanged:o});return{isConnected:c,connectionState:i,isAuthenticated:!!s}}function oa(t){const{ticketId:s,onCommentAdded:r,onTicketUpdated:a,onConnectionStateChange:o}=t,c=n.useRef(null),i=n.useRef(null),[d,u]=n.useState(oe.HubConnectionState.Disconnected),m=n.useCallback(()=>localStorage.getItem("token"),[]),p=n.useCallback(async g=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("JoinTicket",g),i.current=g}catch(y){console.error("SignalR: Failed to join ticket group",y)}},[]),x=n.useCallback(async g=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("LeaveTicket",g)}catch(y){console.error("SignalR: Failed to leave ticket group",y)}i.current=null},[]),f=n.useCallback(async()=>{const g=m();if(g){if(c.current?.state===oe.HubConnectionState.Connected)return c.current;try{const y=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>g}).withAutomaticReconnect({nextRetryDelayInMilliseconds:h=>h.previousRetryCount===0?0:h.previousRetryCount===1?2e3:h.previousRetryCount===2?1e4:h.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();return y.on("TicketCommentAdded",h=>{r?.(h)}),y.on("TicketUpdated",h=>{a?.(h)}),y.onreconnecting(()=>{u(oe.HubConnectionState.Reconnecting),o?.(oe.HubConnectionState.Reconnecting)}),y.onreconnected(async()=>{u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),i.current&&await p(i.current)}),y.onclose(()=>{u(oe.HubConnectionState.Disconnected),o?.(oe.HubConnectionState.Disconnected)}),await y.start(),c.current=y,u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),y}catch(y){return console.error("SignalR: Failed to connect",y),u(oe.HubConnectionState.Disconnected),null}}},[m,p,r,a,o]),b=n.useCallback(async()=>{if(i.current&&await x(i.current),c.current)try{await c.current.stop(),c.current=null,u(oe.HubConnectionState.Disconnected)}catch(g){console.error("SignalR: Failed to disconnect",g)}},[x]);return n.useEffect(()=>{let g=!0;return(async()=>(await f(),g&&s&&await p(s)))(),()=>{g=!1,b()}},[f,b,s,p]),n.useEffect(()=>{const g=async()=>{i.current&&i.current!==s&&await x(i.current),s&&s!==i.current&&await p(s)};c.current?.state===oe.HubConnectionState.Connected&&g()},[s,p,x]),{connectionState:d,isConnected:d===oe.HubConnectionState.Connected,joinTicket:p,leaveTicket:x}}function Co(t,s,r,a){const o=[];for(const c of a.resources)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"resource",applicationCode:t});return o}function ko(t,s,r,a){const o=[];for(const c of a.sections)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"section",applicationCode:t}),o.push(...Co(t,s,r,c));return o}function Ao(t,s,r){const a=[];for(const o of r.modules)o.route&&a.push({componentKey:o.componentKey,permissionPath:o.permissionPath,route:o.route,hasComponent:O.has(o.componentKey),requiredFeature:o.requiredFeature,isOpen:s,level:"module",applicationCode:t}),a.push(...ko(t,s,o.requiredFeature,o));return a}function Po(t){const s=[];for(const r of t)r.route&&s.push({componentKey:r.componentKey,permissionPath:r.permissionPath,route:r.route,hasComponent:O.has(r.componentKey),requiredFeature:r.requiredFeature,isOpen:r.isOpen,level:"application",applicationCode:r.code}),s.push(...Ao(r.code,r.isOpen,r));return s}function To(){const{menu:t,isLoading:s}=Ce();return n.useMemo(()=>{if(!t||s)return{entries:[],byKey:new Map,isLoading:!0,byApplication:new Map};const r=Po(t.applications),a=new Map(r.map(c=>[c.componentKey,c])),o=new Map;for(const c of r){const i=o.get(c.applicationCode)||[];i.push(c),o.set(c.applicationCode,i)}return{entries:r,byKey:a,isLoading:!1,byApplication:o}},[t,s])}const Ro=(t,s,r)=>{const a=t.has(r),o=s.get(r);if(!o)return{isDirect:a,isInherited:!1};const c=o.path;let i,d,u=1/0;for(const p of Array.from(t)){const x=s.get(p);if(!(!x||!x.isWildcard||p===r)&&Ut(x.path,c)){const f=x.path.split(".").length;f<u&&(u=f,i=x.path,d=x.id)}}return{isDirect:a,isInherited:i!==void 0,inheritedFromPath:i,inheritedFromId:d}},Ms=(t,s)=>{const r={};return Object.entries(t).forEach(([a,o])=>{const c=new Map;s.forEach((i,d)=>{const u=Ro(o,s,d);c.set(d,u)}),r[a]=c}),r},Eo=t=>{const s=new Map;return t.forEach(r=>{const o=r.path.toLowerCase().split(".");if(o.length>=2){const c=o.slice(0,-1).join("."),i=s.get(c)||[];i.push({id:r.id,action:o.at(-1),path:r.path}),s.set(c,i)}}),s},Ht=(t,s)=>{const r=s.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,"");return t.get(r)||[]};function ia(t){const{entityId:s,tenantId:r,loadEntity:a,loadRoles:o}=t,{i18n:c}=ne.useTranslation(),[i,d]=n.useState(!0),[u,m]=n.useState(null),[p,x]=n.useState(null),[f,b]=n.useState([]),[g,y]=n.useState([]),[h,j]=n.useState(new Map),[v,S]=n.useState({}),[N,I]=n.useState({}),[P,k]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all"}),A=!!r,R=n.useCallback((F,K,V,ae)=>{const ue=Ht(ae,K.permissionPath);F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:V.label,moduleLabel:K.label,level:"module",permissions:ue,totalPermissions:ue.length})},[]),$=n.useCallback((F,K,V,ae,ue)=>{const G=Ht(ue,K.permissionPath);K.resources.forEach(ce=>{const de=Ht(ue,ce.permissionPath);F.push({id:ce.id,path:ce.permissionPath,label:ce.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,parentSectionLabel:K.label,parentSectionId:K.id,level:"resource",permissions:de,totalPermissions:de.length})}),F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,level:"section",permissions:G,totalPermissions:G.length})},[]),U=n.useCallback((F,K,V,ae)=>{R(ae,F,K,V),F.sections.forEach(ue=>{$(ae,ue,F,K,V)})},[R,$]),C=n.useCallback((F,K,V)=>{F.modules.forEach(ae=>{U(ae,F,K,V)})},[U]),D=n.useCallback((F,K)=>{if(!F?.applications||!Array.isArray(K))return[];const V=Eo(K),ae=[];return F.applications.forEach(ue=>{C(ue,V,ae)}),ae.sort((ue,G)=>{const ce=ue.applicationLabel.localeCompare(G.applicationLabel);return ce!==0?ce:ue.moduleLabel.localeCompare(G.moduleLabel)})},[C]),Y=n.useCallback(async()=>{try{d(!0),m(null);const[F,K,V]=await Promise.all([a(s),o(s,r),Ne.permissions.getMatrix()]);x(F),b(K);const ae=new Set(K.map(pe=>pe.id)),ue=V.roles.filter(pe=>ae.has(pe.id)),G={};ue.forEach(pe=>{G[pe.id]=new Set(pe.permissionIds)});const ce=new Map(V.permissions.map(pe=>[pe.id,pe])),de=D(V.tree,V.permissions),he=Ms(G,ce);y(de),j(ce),S(G),I(he)}catch(F){m(F instanceof Error?F.message:"Failed to load permissions data")}finally{d(!1)}},[s,r,a,o,D]);n.useEffect(()=>{Y()},[Y,c.language]),n.useEffect(()=>{if(h.size>0){const F=Ms(v,h);I(F)}},[v,h]);const T=n.useMemo(()=>{const F=new Set;return Object.entries(N).forEach(([K,V])=>{V.forEach((ae,ue)=>{(ae.isDirect||ae.isInherited)&&F.add(ue)})}),F},[N]),B=F=>P.resourceSearch?F.label.toLowerCase().includes(P.resourceSearch.toLowerCase()):!0,Z=F=>P.applicationFilter==="all"?!0:F.applicationLabel===P.applicationFilter,H=F=>P.moduleFilter==="all"?!0:F.level==="module"?F.label===P.moduleFilter:F.parentModuleLabel===P.moduleFilter,J=n.useMemo(()=>g.filter(F=>B(F)&&Z(F)&&H(F)),[g,P]),fe=n.useMemo(()=>{const F=new Map;return g.forEach(K=>{F.has(K.applicationLabel)||F.set(K.applicationLabel,{app:K.applicationLabel,label:K.applicationLabel})}),Array.from(F.values()).sort((K,V)=>K.label.localeCompare(V.label))},[g]),z=n.useMemo(()=>g.filter(F=>F.level==="module").map(F=>({app:F.applicationLabel,module:F.label,label:F.label})).sort((F,K)=>F.label.localeCompare(K.label)),[g]),Q=n.useCallback(F=>{k(K=>({...K,...F}))},[]),M=n.useCallback((F,K)=>{const V=N[F];return V?V.get(K)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[N]),re=n.useCallback(F=>{const K=[];return f.forEach(V=>{const ae=N[V.id];if(ae){const ue=ae.get(F);ue&&(ue.isDirect||ue.isInherited)&&K.push(V)}}),K},[f,N]);return{loading:i,error:u,entity:p,roles:f,resources:g,assignments:v,inheritanceMap:N,effectivePermissions:T,filters:P,filteredResources:J,applications:fe,modules:z,updateFilters:Q,getPermissionInheritance:M,getPermissionSources:re,reloadData:Y,isTenantMode:A}}function Io(t){const{userId:s,tenantId:r}=t,[a,o]=n.useState(null),[c,i]=n.useState([]),d=!!r,u=n.useCallback(async y=>Ne.users.getById(y),[]),m=n.useCallback(async(y,h)=>{const j=await Ne.users.getById(y);let v=[];try{const N=await Ne.users.getConsolidatedRoles(y,h);if(i(N),v=N.map(I=>({id:I.roleId,name:I.roleName,shortName:I.roleShortName||I.roleName,category:"Custom",description:null})),h)try{const P=(await Ne.tenants.getMembers(h)).find(k=>k.userId===y);o(P||null)}catch{o(null)}else o(null)}catch{i([]),o(null),v=j.roles}return Array.from(new Map(v.map(N=>[N.id,N])).values())},[]),p=ia({entityId:s,tenantId:r,loadEntity:u,loadRoles:m}),x=p.entity,f=p.roles,b=n.useCallback(y=>{const h=[];return f.forEach(j=>{const v=p.inheritanceMap[j.id];if(v){const S=v.get(y);S&&(S.isDirect||S.isInherited)&&h.push(j)}}),h},[f,p.inheritanceMap]),g=n.useCallback(async y=>{if(!d||!r||!a)throw new Error("Cannot assign tenant roles: not in tenant mode or no tenant member found");await Ne.tenants.assignMemberRoles(r,a.userId,y),await p.reloadData()},[d,r,a,p]);return{loading:p.loading,error:p.error,user:x,userRoles:f,resources:p.resources,assignments:p.assignments,inheritanceMap:p.inheritanceMap,effectivePermissions:p.effectivePermissions,filters:p.filters,filteredResources:p.filteredResources,applications:p.applications,modules:p.modules,updateFilters:p.updateFilters,getPermissionInheritance:p.getPermissionInheritance,getPermissionSources:b,reloadData:p.reloadData,isTenantMode:d,tenantMember:a,assignTenantRoles:g,consolidatedRoles:c}}function Kt(){const{mode:t,toggleMode:s}=wt(),a=(t==="dark"?"dark":"light")==="light";return e.jsx("button",{onClick:s,className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300 group",style:{borderRadius:"var(--radius-button)"},"aria-label":`Basculer vers le mode ${a?"sombre":"clair"}`,children:e.jsxs("div",{className:"relative w-6 h-6",children:[e.jsx(l.Sun,{className:`absolute inset-0 w-6 h-6 text-amber-500 transition-all duration-300 ${a?"opacity-100 rotate-0 scale-100":"opacity-0 rotate-90 scale-0"}`}),e.jsx(l.Moon,{className:`absolute inset-0 w-6 h-6 text-[var(--color-accent-400)] transition-all duration-300 ${a?"opacity-0 -rotate-90 scale-0":"opacity-100 rotate-0 scale-100"}`})]})})}const Vt=[{code:"en",label:"English",short:"EN"},{code:"fr",label:"Français",short:"FR"},{code:"de",label:"Deutsch",short:"DE"},{code:"it",label:"Italiano",short:"IT"}];function vs(){const{i18n:t}=ne.useTranslation(),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1),o=n.useRef(null),c=t.language?.split("-")[0]||"en",i=Vt.find(u=>u.code===c)||Vt[0],d=async u=>{if(await hs(u),document.documentElement.lang=u,a(!1),s)try{await Ft.preferences.updateLanguage({language:u})}catch{}};return n.useEffect(()=>{const u=m=>{o.current&&!o.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),e.jsxs("div",{ref:o,className:"relative",children:[e.jsx("button",{onClick:()=>a(!r),className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300",style:{borderRadius:"var(--radius-button)"},"aria-label":"Change language",children:e.jsx("span",{className:"flex items-center justify-center w-6 h-6 text-xs font-bold text-[var(--text-secondary)]",children:i.short})}),r&&e.jsx("div",{className:"absolute right-0 mt-2 py-1 bg-[var(--bg-tertiary)] border border-[var(--border-color)] shadow-lg shadow-[var(--shadow-color)] z-50 overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:Vt.map(u=>{const m=u.code===c;return e.jsxs("button",{onClick:()=>d(u.code),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors whitespace-nowrap ${m?"bg-primary-600/10 text-primary-500":"text-[var(--text-secondary)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-primary)]"}`,children:[e.jsx("span",{className:"text-xs font-bold w-6",children:u.short}),e.jsx("span",{className:"text-sm font-medium",children:u.label}),m&&e.jsx(l.Check,{className:"w-4 h-4 ml-auto text-primary-500"})]},u.code)})})]})}function Lo(t,s){if(!s.useUrlRouting||!s.slug)return dt(t);if(t.startsWith(`/t/${s.slug}`))return t;const r=dt(t);return`/t/${s.slug}${r}`}function Os(t){const s=/^\/t\/([^/]+)/.exec(t);return s?s[1]:null}function dt(t){return t.replace(/^\/t\/[^/]+/,"")||"/"}function Ze(){const{currentTenant:t}=Ee(),{useUrlRouting:s}=_t();return n.useCallback(r=>Lo(r,{slug:t?.slug,useUrlRouting:s}),[t?.slug,s])}const Fs={background:"linear-gradient(to bottom right, var(--color-accent-500), var(--color-accent-600))"};function la(){const{t}=ne.useTranslation("navigation"),{user:s,logout:r}=Pe(),{refreshMenu:a}=Ce(),{refreshTenants:o}=Ee(),c=w.useLocation(),i=w.useNavigate(),d=Ze(),[u,m]=n.useState(!1),[p,x]=n.useState(!1),f=n.useRef(null),b=async()=>{x(!0);try{await E.post("/api/navigation/invalidate-cache").catch(()=>{}),await Promise.all([a(),o()])}catch(j){console.error("Failed to refresh cache:",j)}finally{x(!1),m(!1)}},g=j=>{const v=d(j);c.pathname!==v&&i(v),m(!1)};n.useEffect(()=>{function j(v){f.current&&!f.current.contains(v.target)&&m(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),n.useEffect(()=>{function j(v){v.key==="Escape"&&m(!1)}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);const y=()=>{if(!s)return"?";const j=s.firstName?.[0]||"",v=s.lastName?.[0]||"";return(j+v).toUpperCase()||s.email.at(0)?.toUpperCase()||"?"},h=()=>s?s.firstName||s.lastName?`${s.firstName||""} ${s.lastName||""}`.trim():s.email.split("@")[0]:"";return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 p-1.5 pr-3 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-200 group",style:{borderRadius:"var(--radius-button)"},"aria-expanded":u,"aria-haspopup":"true",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm font-medium shadow-sm",style:Fs,children:y()}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform duration-200 ${u?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute right-0 mt-2 w-72 origin-top-right transition-all duration-200 ease-out ${u?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-4 bg-gradient-to-br from-[var(--bg-secondary)] to-[var(--bg-tertiary)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center text-white text-lg font-semibold shadow-lg",style:Fs,children:y()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[var(--text-primary)] truncate",children:h()}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate",children:s?.email})]})]})}),e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>g("/applications"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.LayoutGrid,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.applications")})]}),e.jsxs("button",{onClick:()=>g("/myspace"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.User,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.mySpace")})]})]})}),e.jsx("div",{className:"p-2",children:e.jsxs("button",{onClick:b,disabled:p,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.RefreshCw,{className:`w-4 h-4 ${p?"animate-spin":""}`})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.refreshCache")})]})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>{m(!1),r()},className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-red-500/10 transition-colors group",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] group-hover:bg-red-500/20 flex items-center justify-center text-[var(--text-secondary)] group-hover:text-red-500 transition-colors",children:e.jsx(l.LogOut,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)] group-hover:text-red-500 transition-colors",children:t("avatarMenu.logout")})]})})]})})]})}const $o={settings:l.Settings,users:l.Users,key:l.Key,briefcase:l.Briefcase,folder:l.FolderOpen,file:l.FileText,box:l.Box};function Do(t){return t&&$o[t.toLowerCase()]||l.Box}function _s({app:t,isFavorite:s,showFavorite:r,onToggleFavorite:a,onSelect:o}){const c=Do(t.icon);return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{onClick:o,className:"w-full flex flex-col items-center gap-2 p-3 hover:bg-[var(--bg-tertiary)] transition-all duration-200",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-[var(--color-accent-500)]/20 to-[var(--color-accent-600)]/20 flex items-center justify-center group-hover:from-[var(--color-accent-500)]/30 group-hover:to-[var(--color-accent-600)]/30 transition-all",style:{borderRadius:"var(--radius-card)"},children:e.jsx(c,{className:"w-6 h-6 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-primary)] text-center line-clamp-2",children:t.label})]}),r&&e.jsx("button",{onClick:i=>{i.stopPropagation(),a()},className:`absolute top-1 right-1 p-1.5 transition-all duration-200 ${s?"text-amber-500 bg-amber-500/10":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-secondary)]"}`,style:{borderRadius:"var(--radius-button)"},title:s?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${s?"fill-current":""}`})})]})}function ca(){const{t}=ne.useTranslation("navigation"),{favorites:s,menu:r,toggleFavorite:a,isFavorite:o}=Ce(),{currentTenant:c}=Ee(),[i,d]=n.useState(!1),u=n.useRef(null),m=w.useNavigate(),p=Ze(),x=!!c,f=r?.applications||[];n.useEffect(()=>{function g(y){u.current&&!u.current.contains(y.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),n.useEffect(()=>{function g(y){y.key==="Escape"&&d(!1)}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const b=g=>{d(!1),g.route&&m(p(g.route))};return e.jsxs("div",{ref:u,className:"relative",children:[e.jsx("button",{onClick:()=>d(!i),className:"p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},"aria-expanded":i,"aria-haspopup":"true",title:t("appSwitcher.title","Applications"),children:e.jsx(l.LayoutGrid,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`absolute right-0 mt-2 w-80 origin-top-right transition-all duration-200 ease-out ${i?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[s.length>0&&e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500 fill-amber-500"}),t("appSwitcher.favorites","Favoris")]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2",children:s.slice(0,6).map(g=>e.jsx(_s,{app:g,isFavorite:!0,showFavorite:x,onToggleFavorite:()=>a(g.id),onSelect:()=>{d(!1),g.route&&m(p(g.route))}},g.id))})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider",children:t("appSwitcher.allApps","Toutes les applications")}),f.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2 max-h-64 overflow-y-auto",children:f.map(g=>e.jsx(_s,{app:g,isFavorite:o(g.id),showFavorite:x,onToggleFavorite:()=>a(g.id),onSelect:()=>b(g)},g.id))}):e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-6",children:t("appSwitcher.noApps","Aucune application disponible")})]})]})})]})}function Mo(){const[t,s]=n.useState([]),r=n.useCallback(async()=>{try{const c=await Ne.myTenants.getFavorites();s(c)}catch{}},[]),a=n.useCallback(async c=>{const i=t.includes(c);try{if(i){const d=await Ne.myTenants.removeFavorite(c);s(d)}else{const d=await Ne.myTenants.addFavorite(c);s(d)}}catch(d){console.error("Failed to toggle favorite:",d)}},[t]),o=n.useCallback(c=>{Ne.myTenants.recordRecent(c).catch(console.error)},[]);return{favorites:t,loadFavorites:r,toggleFavorite:a,recordRecent:o}}const Oo={Pending:"bg-blue-500",Active:"bg-emerald-500",Suspended:"bg-amber-500",Archived:"bg-gray-400"},Fo={Pending:"En attente",Active:"Actif",Suspended:"Suspendu",Archived:"Archivé"};function Wt({tenant:t,isSelected:s,isFavorite:r,hasThemeOverride:a,onSelect:o,onToggleFavorite:c,showStatus:i=!0}){const d=t.type==="Business",u=t.status==="Active",m=(p,x)=>p?"bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)]":x?"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]":"opacity-50 cursor-not-allowed text-[var(--text-tertiary)]";return e.jsxs("div",{className:"flex items-center group",children:[e.jsxs("button",{onClick:o,disabled:!u,className:`flex-1 flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${m(s,u)}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${d?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:d?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:t.name}),a&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--color-accent-500)]",title:"Thème personnalisé"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)] truncate",children:t.organisationName||t.slug}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Oo[t.status]}`}),t.status!=="Active"&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Fo[t.status]})]})]})]}),s&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"})]}),c&&u&&e.jsx("button",{onClick:p=>{p.stopPropagation(),c()},className:`p-2 transition-colors ${r?"text-amber-500":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:text-amber-500"}`,title:r?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${r?"fill-amber-500":""}`})})]})}const da="tenant_recents",as=5;function ua(){try{return JSON.parse(localStorage.getItem(da)||"[]")}catch{return[]}}function _o(t){const s=ua().filter(r=>r!==t);s.unshift(t),localStorage.setItem(da,JSON.stringify(s.slice(0,as)))}const Uo=(t,s,r)=>{const a=o=>{t.current&&!t.current.contains(o.target)&&(s(!1),r(""))};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},qo=(t,s)=>{const r=a=>{a.key==="Escape"&&(t(!1),s(""))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},Bo=(t,s,r,a,o)=>{const c=n.useMemo(()=>t.filter(u=>s.includes(u.id)&&u.status==="Active"),[t,s]),i=n.useMemo(()=>{if(o.trim())return[];const u=new Set(s);return r.map(m=>a.find(p=>p.id===m)).filter(m=>!!m&&m.status==="Active"&&!u.has(m.id)).slice(0,as)},[r,a,s,o]),d=n.useMemo(()=>{const u=new Set([...s,...r.slice(0,as)]);return t.filter(m=>!u.has(m.id))},[t,s,r]);return{favoriteTenants:c,recentTenants:i,otherTenants:d}};function zo(){const{t}=ne.useTranslation("navigation"),{refreshMenu:s}=Ce(),{currentTenant:r,userTenants:a,switchTenant:o,isLoading:c,hasMultipleTenants:i,hasGlobalRoles:d,isGlobalView:u,enterGlobalView:m}=Ee(),{tenantOverrides:p,loadTenantOverrides:x}=wt(),[f,b]=n.useState(!1),[g,y]=n.useState(""),[h]=n.useState(()=>ua()),j=n.useRef(null),v=n.useRef(null),{favorites:S,loadFavorites:N,toggleFavorite:I,recordRecent:P}=Mo();n.useEffect(()=>{f&&(N(),x())},[f,N,x]),n.useEffect(()=>{f&&v.current&&setTimeout(()=>v.current?.focus(),100)},[f]),n.useEffect(()=>Uo(j,b,y),[]),n.useEffect(()=>qo(b,y),[]);const k=n.useCallback(async T=>{if(T===r?.id&&!u){b(!1);return}try{_o(T),P(T),await o(T),b(!1),y(""),await s()}catch(B){console.error("Failed to switch tenant:",B)}},[r?.id,u,o,s,P]),A=n.useCallback(async()=>{await m(),b(!1),y(""),await s()},[m,s]),R=n.useCallback(async T=>{await I(T)},[I]),$=n.useMemo(()=>{if(!g.trim())return a;const T=g.toLowerCase();return a.filter(B=>B.name.toLowerCase().includes(T)||B.slug.toLowerCase().includes(T)||B.organisationName?.toLowerCase().includes(T))},[a,g]),{favoriteTenants:U,recentTenants:C,otherTenants:D}=Bo($,S,h,a,g);if(c)return null;if(!(i||d)&&r){const T=r.type==="Business";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-button)"},children:[T?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r.name})]})}return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{onClick:()=>b(!f),className:`flex items-center gap-2 px-3 py-1.5 border transition-colors ${u?"bg-emerald-500/10 border-emerald-500/30 hover:bg-emerald-500/20":"bg-[var(--bg-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-tertiary)]"}`,style:{borderRadius:"var(--radius-button)"},"aria-expanded":f,"aria-haspopup":"true",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-sm font-medium text-emerald-700",children:t("tenants.selector.global","Global")})]}),!u&&r&&e.jsxs(e.Fragment,{children:[r.type==="Business"?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] max-w-[120px] truncate",children:r.name})]}),!u&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Building2,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("tenants.selector.select","Select")})]}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform ${f?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute left-0 mt-2 w-80 origin-top-left transition-all duration-200 ease-out z-50 ${f?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:v,type:"text",value:g,onChange:T=>y(T.target.value),placeholder:t("tenants.selector.search","Rechercher..."),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] focus:border-[var(--color-accent-500)] focus:outline-none",style:{borderRadius:"var(--radius-input)"}})]})}),e.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d&&!g&&e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("button",{onClick:A,className:`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${u?"bg-emerald-500/10 text-emerald-700":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-emerald-500/10 flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium",children:t("tenants.selector.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:t("tenants.selector.globalDesc","Voir tous les tenants")})]}),u&&e.jsx(l.Check,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"})]})}),U.length>0&&e.jsxs("div",{className:"p-2",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500"}),t("tenants.selector.favorites","Favoris")]}),e.jsx("div",{className:"mt-1",children:U.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:!0,hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),C.length>0&&e.jsxs("div",{className:`p-2 ${U.length>0?"border-t border-[var(--border-color)]":""}`,children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),t("tenants.selector.recent","Récents")]}),e.jsx("div",{className:"mt-1",children:C.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),D.length>0&&e.jsxs("div",{className:`p-2 ${U.length>0||C.length>0?"border-t border-[var(--border-color)]":""}`,children:[!g&&e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Building2,{className:"w-3 h-3"}),t("tenants.selector.all","Tous")]}),e.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto",children:D.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),g&&$.length===0&&e.jsx("div",{className:"p-4 text-center text-sm text-[var(--text-tertiary)]",children:t("tenants.selector.noResults","Aucun résultat")})]}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs(w.Link,{to:"/myspace/tenants",className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},onClick:()=>b(!1),children:[e.jsx(l.Eye,{className:"w-4 h-4"}),t("tenants.selector.viewAll","Voir tous mes espaces")," (",a.length,")"]})})]})})]})}function ys(t,s){return t?s===t?"current":"other":"global"}const Go={getOverview:(t=30)=>E.get("/api/support/dashboard/overview",{params:{days:t}}),getByStatus:()=>E.get("/api/support/dashboard/by-status"),getByPriority:()=>E.get("/api/support/dashboard/by-priority"),getByType:(t=30)=>E.get("/api/support/dashboard/by-type",{params:{days:t}}),getAgentWorkload:()=>E.get("/api/support/dashboard/agent-workload"),getTrends:(t=30)=>E.get("/api/support/dashboard/trends",{params:{days:t}}),getSatisfactionStats:(t=30)=>E.get("/api/support/dashboard/satisfaction",{params:{days:t}}),getSlaCompliance:(t=30)=>E.get("/api/support/dashboard/sla-compliance",{params:{days:t}})},ma={getConfigurations:()=>E.get("/api/support/sla/configurations"),updateConfiguration:(t,s)=>E.put(`/api/support/sla/configurations/${t}`,s),getEscalationRules:()=>E.get("/api/support/sla/escalation-rules"),getBreachedTickets:(t=!0,s=!0)=>E.get("/api/support/sla/breached",{params:{responseBreached:t,resolutionBreached:s}}),getTicketsApproachingBreach:(t=60)=>E.get("/api/support/sla/approaching-breach",{params:{warningMinutes:t}}),getMetrics:(t,s)=>E.get("/api/support/sla/metrics",{params:{fromDate:t,toDate:s}}),escalateTicket:(t,s,r)=>E.post(`/api/support/sla/tickets/${t}/escalate`,{level:s,reason:r})},st={getAll:(t=1,s=20,r,a)=>E.get("/api/support/notifications",{params:{page:t,pageSize:s,isRead:r,tenantId:a}}),getUnread:(t=10)=>E.get("/api/support/notifications/unread",{params:{limit:t}}),getUnreadCount:()=>E.get("/api/support/notifications/unread/count"),markAsRead:t=>E.patch(`/api/support/notifications/${t}/read`),markAllAsRead:()=>E.patch("/api/support/notifications/read-all"),delete:t=>E.delete(`/api/support/notifications/${t}`),deleteAll:()=>E.delete("/api/support/notifications/all"),getPreferences:()=>E.get("/api/support/notifications/preferences"),updatePreferences:t=>E.put("/api/support/notifications/preferences",t)},Et={getAll:(t,s=!0,r)=>E.get("/api/support/templates",{params:{category:t,activeOnly:s,language:r}}),getById:t=>E.get(`/api/support/templates/${t}`),getCategories:()=>E.get("/api/support/templates/categories"),getByCategory:t=>E.get(`/api/support/templates/by-category/${t}`),create:t=>E.post("/api/support/templates",t),update:(t,s)=>E.put(`/api/support/templates/${t}`,s),activate:t=>E.patch(`/api/support/templates/${t}/activate`),deactivate:t=>E.patch(`/api/support/templates/${t}/deactivate`),delete:t=>E.delete(`/api/support/templates/${t}`),render:(t,s)=>E.post(`/api/support/templates/${t}/render`,{variables:s})},ns={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function Ko(t,s,r){if(r){const o=s.relatedEntityId,c=t.filter(i=>!(i.type===ns.STARTED&&i.relatedEntityId===o));return[s,...c].slice(0,10)}return t.some(o=>o.id===s.id)?t:[s,...t].slice(0,10)}function Ho(t){return{id:t.id,type:t.type,title:t.title,message:t.message,relatedEntityType:t.relatedEntityType,relatedEntityId:t.relatedEntityId,actionUrl:t.actionUrl,isRead:t.isRead,readAt:t.readAt,createdAt:t.createdAt,tenantId:t.tenantId,tenantName:t.tenantName,tenantSlug:t.tenantSlug}}function Vo(){const[t,s]=n.useState(0),[r,a]=n.useState([]),[o,c]=n.useState(!1),{isConnected:i,onNotification:d,onUnreadCountUpdate:u}=_r(),{isFeatureEnabled:m}=He(),p=m("support");n.useEffect(()=>{const h=d(v=>{const S=Ho(v),N=v.type===ns.COMPLETED||v.type===ns.FAILED;a(I=>Ko(I,S,N))}),j=u(v=>{s(v)});return()=>{h(),j()}},[d,u]),n.useEffect(()=>{if(!p)return;let h=!1;async function j(){try{const v=await st.getUnreadCount();h||s(v.count)}catch(v){h||console.error("Failed to load unread count:",v)}}return j(),()=>{h=!0}},[p]);const x=n.useCallback(async()=>{if(p)try{c(!0);const h=await st.getUnread(10);a(h)}catch(h){console.error("Failed to load notifications:",h)}finally{c(!1)}},[p]),f=n.useCallback(async h=>{try{await st.markAsRead(h),a(j=>j.map(v=>v.id===h?{...v,isRead:!0}:v)),s(j=>Math.max(0,j-1))}catch(j){console.error("Failed to mark as read:",j)}},[]),b=n.useCallback(async()=>{try{await st.markAllAsRead(),a(h=>h.map(j=>({...j,isRead:!0}))),s(0)}catch(h){console.error("Failed to mark all as read:",h)}},[]),g=n.useCallback(async h=>{try{await st.delete(h);const j=r.find(v=>v.id===h);a(v=>v.filter(S=>S.id!==h)),j&&!j.isRead&&s(v=>Math.max(0,v-1))}catch(j){console.error("Failed to delete notification:",j)}},[r]),y=n.useCallback(h=>{st.markAsRead(h),s(j=>Math.max(0,j-1))},[]);return{notifications:r,unreadCount:t,loading:o,isConnected:i,loadNotifications:x,markAsRead:f,markAllAsRead:b,deleteNotification:g,markAsReadSilent:y}}const bt={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function pa(){const t=w.useNavigate(),{currentTenant:s,hasMultipleTenants:r}=Ee(),[a,o]=n.useState(!1),c=n.useRef(null),{notifications:i,unreadCount:d,loading:u,isConnected:m,loadNotifications:p,markAsRead:x,markAllAsRead:f,deleteNotification:b,markAsReadSilent:g}=Vo(),[,y]=n.useState(0);n.useEffect(()=>{if(!i.some(R=>R.type===bt.STARTED&&!R.isRead))return;const A=setInterval(()=>{y(R=>R+1)},1e3);return()=>clearInterval(A)},[i]),n.useEffect(()=>{a&&p()},[a,p]),n.useEffect(()=>{const k=A=>{c.current&&!c.current.contains(A.target)&&o(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const h=(k,A)=>{A.stopPropagation(),x(k)},j=(k,A)=>{A.stopPropagation(),b(k)},v=k=>{k.isRead||g(k.id),o(!1),k.actionUrl&&t(k.actionUrl)},S=k=>{switch(k){case"TicketCreated":return"🎫";case"TicketAssigned":return"👤";case"TicketStatusChanged":case"StatusChanged":return"🔄";case"TicketCommented":case"CommentAdded":return"💬";case"TicketResolved":return"✅";case"TicketClosed":return"🔒";case"TicketUpdated":return"📝";case"SlaResponseBreached":case"SlaResolutionBreached":return"⚠️";case"SlaWarning":return"⏰";case"TicketEscalated":return"📈";case"SatisfactionRequested":return"⭐";case"GroupMemberAdded":return"👥";case"GroupMemberRemoved":return"🚪";case"RoleAssigned":return"🎭";case"RoleRemoved":return"🚫";case"RolePermissionsChanged":return"🔑";case"AccountUpdated":return"👤";case"SystemAnnouncement":return"📢";case bt.STARTED:return null;case bt.COMPLETED:return"✅";case bt.FAILED:return"❌";default:return"📌"}},N=k=>{const A=new Date(k).getTime(),R=Date.now(),$=Math.floor((R-A)/1e3),U=Math.floor($/60),C=$%60;return`${U.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`},I=k=>{const A=new Date(k),$=new Date().getTime()-A.getTime(),U=Math.floor($/6e4),C=Math.floor(U/60),D=Math.floor(C/24);return U<1?"Just now":U<60?`${U}m ago`:C<24?`${C}h ago`:D<7?`${D}d ago`:A.toLocaleDateString()},P=k=>{if(!r)return null;const A=ys(k.tenantId,s?.id??null);return A==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):A==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:k.tenantName}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:k.tenantName})};return e.jsxs("div",{className:"relative",ref:c,children:[e.jsxs("button",{onClick:()=>o(!a),className:"relative p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors","aria-label":"Notifications",children:[e.jsx(l.Bell,{className:"w-5 h-5"}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white text-xs font-bold rounded-full flex items-center justify-center",children:d>9?"9+":d})]}),a&&e.jsxs("div",{className:"absolute right-0 mt-2 w-96 bg-[var(--bg-primary)] rounded-lg shadow-xl border border-[var(--border-color)] z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:"Notifications"}),m?e.jsx("span",{title:"Real-time connected",children:e.jsx(l.Wifi,{className:"w-3 h-3 text-green-500"})}):e.jsx("span",{title:"Offline mode",children:e.jsx(l.WifiOff,{className:"w-3 h-3 text-gray-400"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d>0&&e.jsxs("button",{onClick:f,className:"text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1",children:[e.jsx(l.CheckCheck,{className:"w-4 h-4"}),"Mark all read"]}),e.jsx("button",{onClick:()=>o(!1),className:"p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}),!u&&i.length>0&&i.map(k=>{const A=k.type===bt.STARTED&&!k.isRead,R=S(k.type);return e.jsx("div",{role:"button",tabIndex:0,onClick:()=>v(k),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),v(k))},className:`w-full text-left p-4 border-b border-[var(--border-color)] cursor-pointer hover:bg-[var(--bg-hover)] transition-colors ${k.isRead?"":"bg-blue-50/50 dark:bg-blue-900/10"} ${A?"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20":""}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"text-xl flex-shrink-0",children:A?e.jsx(l.RefreshCw,{className:"w-5 h-5 text-[var(--color-accent-600)] animate-spin"}):R}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:`text-sm ${k.isRead?"":"font-semibold"}`,children:k.title}),P(k)]}),A?e.jsxs("span",{className:"text-xs font-mono font-bold text-[var(--color-accent-600)] flex-shrink-0 bg-[var(--color-accent-100)] px-2 py-0.5 rounded",children:["⏱ ",N(k.createdAt)]}):e.jsx("span",{className:"text-xs text-[var(--text-secondary)] flex-shrink-0",children:I(k.createdAt)})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mt-1",children:k.message})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-shrink-0",children:[!k.isRead&&!A&&e.jsx("button",{onClick:$=>h(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Mark as read",children:e.jsx(l.Check,{className:"w-4 h-4 text-green-600"})}),!A&&e.jsx("button",{onClick:$=>j(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Delete",children:e.jsx(l.Trash2,{className:"w-4 h-4 text-red-500"})})]})]})},k.id)}),!u&&i.length===0&&e.jsxs("div",{className:"py-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Bell,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No notifications"})]})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)] text-center",children:e.jsx("button",{onClick:()=>{o(!1),t("/notifications")},className:"text-sm text-[var(--color-primary-600)] hover:underline",children:"View all notifications"})})]})]})}const Wo={default:{bg:"bg-[var(--bg-tertiary)]",text:"text-[var(--text-primary)]",border:"border-[var(--border-color)]",arrow:"bg-[var(--bg-tertiary)] border-[var(--border-color)]"},error:{bg:"bg-[var(--tooltip-error-bg)]",text:"text-[var(--error-text)]",border:"border-[var(--error-border)]",arrow:"bg-[var(--tooltip-error-bg)] border-[var(--error-border)]"},warning:{bg:"bg-[var(--tooltip-warning-bg)]",text:"text-[var(--warning-text)]",border:"border-[var(--warning-border)]",arrow:"bg-[var(--tooltip-warning-bg)] border-[var(--warning-border)]"},success:{bg:"bg-[var(--tooltip-success-bg)]",text:"text-[var(--success-text)]",border:"border-[var(--success-border)]",arrow:"bg-[var(--tooltip-success-bg)] border-[var(--success-border)]"},info:{bg:"bg-[var(--tooltip-info-bg)]",text:"text-[var(--info-text)]",border:"border-[var(--info-border)]",arrow:"bg-[var(--tooltip-info-bg)] border-[var(--info-border)]"}};function xa({content:t,children:s,position:r="top",variant:a="default",delay:o=200,disabled:c=!1,className:i=""}){const d=Wo[a],[u,m]=n.useState(!1),[p,x]=n.useState({top:0,left:0}),f=n.useRef(null),b=n.useRef(null),g=n.useRef(null),y=()=>{if(!f.current||!b.current)return;const S=f.current.getBoundingClientRect(),N=b.current.getBoundingClientRect(),I=window.scrollX,P=window.scrollY,k=8;let A=0,R=0;switch(r){case"top":A=S.top+P-N.height-k,R=S.left+I+(S.width-N.width)/2;break;case"bottom":A=S.bottom+P+k,R=S.left+I+(S.width-N.width)/2;break;case"left":A=S.top+P+(S.height-N.height)/2,R=S.left+I-N.width-k;break;case"right":A=S.top+P+(S.height-N.height)/2,R=S.right+I+k;break}const $=window.innerWidth,U=window.innerHeight,C=8;R<C?R=C:R+N.width>$-C&&(R=$-N.width-C),A<C+P?A=C+P:A+N.height>U+P-C&&(A=U+P-N.height-C),x({top:A,left:R})};n.useEffect(()=>(u&&(y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}),[u,r]);const h=()=>{c||!t||(g.current=setTimeout(()=>{m(!0)},o))},j=()=>{g.current&&(clearTimeout(g.current),g.current=null),m(!1)};n.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const v=()=>{const S=`absolute w-2 h-2 ${d.arrow} transform rotate-45`;switch(r){case"top":return`${S} -bottom-1 left-1/2 -translate-x-1/2 border-r border-b`;case"bottom":return`${S} -top-1 left-1/2 -translate-x-1/2 border-l border-t`;case"left":return`${S} -right-1 top-1/2 -translate-y-1/2 border-t border-r`;case"right":return`${S} -left-1 top-1/2 -translate-y-1/2 border-b border-l`}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:f,onMouseEnter:h,onMouseLeave:j,onFocus:h,onBlur:j,className:"inline-flex",children:s}),u&&t&&Ot.createPortal(e.jsxs("div",{ref:b,role:"tooltip",style:{position:"absolute",top:p.top,left:p.left,zIndex:9999},className:`
3
3
  px-3 py-2 text-sm font-medium
4
4
  ${d.bg} ${d.text}
5
5
  border ${d.border}
@@ -8,27 +8,27 @@
8
8
  max-w-xs
9
9
  tooltip-animation
10
10
  ${i}
11
- `,children:[t,e.jsx("div",{className:v()})]}),document.body)]})}const Et="support_error_context";class Wo{async captureContext(){const s={url:window.location.href,timestamp:new Date,recentErrors:Te.getRecentErrors(),browserInfo:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,screenWidth:window.screen.width,screenHeight:window.screen.height}};try{const r=await this.captureScreenshot();s.screenshot=r}catch{Te.logError(new Error("Failed to capture screenshot"),"ErrorContextService")}return s}async captureScreenshot(){try{const r=await Ts.domToJpeg(document.body,{scale:1,quality:.85,backgroundColor:"#1a1a2e",style:{transform:"none"},filter:a=>{if(a instanceof HTMLElement){const o=a.tagName?.toUpperCase();return o!=="IFRAME"&&o!=="VIDEO"}return!0}});return r.length>4*1024*1024?await this.recompressScreenshot(r,.7):r}catch(s){console.error("[ErrorContextService] Screenshot capture failed:",s);try{return await Ts.domToJpeg(document.body,{scale:.75,quality:.8,backgroundColor:"#1a1a2e"})}catch(r){console.error("[ErrorContextService] Fallback also failed:",r);return}}}async recompressScreenshot(s,r){return new Promise(a=>{const o=new Image;o.onload=()=>{const c=document.createElement("canvas");c.width=o.width,c.height=o.height;const i=c.getContext("2d");if(i){i.drawImage(o,0,0);const d=c.toDataURL("image/jpeg",r);a(d)}else a(s)},o.onerror=()=>a(s),o.src=s})}saveContext(s){try{const r=JSON.stringify(s);try{sessionStorage.setItem(Et,r)}catch{const o={...s,screenshot:void 0};sessionStorage.setItem(Et,JSON.stringify(o))}}catch(r){console.error("[ErrorContextService] Failed to save context:",r)}}loadContext(){try{const s=sessionStorage.getItem(Et);if(s){const r=JSON.parse(s);return r.timestamp=new Date(r.timestamp),r.recentErrors=r.recentErrors.map(a=>({...a,timestamp:new Date(a.timestamp)})),r.screenshot&&!r.screenshot.startsWith("data:image/")&&(r.screenshot=void 0),r}}catch(s){console.warn("[ErrorContextService] Failed to load context:",s)}return null}clearContext(){sessionStorage.removeItem(Et)}formatErrorsForDescription(s){return s.length===0?"":s.slice(0,5).map((a,o)=>{const c=a.timestamp.toLocaleTimeString();return`${o+1}. [${c}] ${a.message}${a.component?` (${a.component})`:""}`}).join(`
12
- `)}}const $t=new Wo,Xt="ticket_drafts",_s=5,qs=7;class Xo{getDrafts(){try{const s=localStorage.getItem(Xt);return s?JSON.parse(s).map(a=>({...a,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt)})):[]}catch{return[]}}saveDrafts(s){try{const r=s.map(o=>({...o,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()})),a=JSON.stringify(r);return localStorage.setItem(Xt,a),!0}catch(r){if(console.error("[TicketDraftService] Failed to save drafts:",r),r instanceof DOMException&&r.name==="QuotaExceededError")try{const a=s.map(o=>({...o,screenshot:void 0,attachments:void 0,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()}));return localStorage.setItem(Xt,JSON.stringify(a)),!0}catch(a){console.error("[TicketDraftService] Still failed without large data:",a)}return!1}}cleanupExpiredDrafts(){const s=this.getDrafts(),r=new Date,a=qs*24*60*60*1e3,o=s.filter(c=>r.getTime()-c.updatedAt.getTime()<a);o.length!==s.length&&this.saveDrafts(o)}getAllDrafts(){return this.cleanupExpiredDrafts(),this.getDrafts().sort((s,r)=>r.updatedAt.getTime()-s.updatedAt.getTime())}getDraft(s){return this.getAllDrafts().find(a=>a.id===s)||null}createDraft(){const s=this.getAllDrafts();if(s.length>=_s){const c=s.at(-1);this.deleteDraft(c.id)}const r=new Date,a={id:crypto.randomUUID(),type:null,title:"",description:"",priority:"Medium",includeScreenshot:!0,includeErrorLogs:!0,createdAt:r,updatedAt:r},o=[a,...this.getDrafts().slice(0,_s-1)];return this.saveDrafts(o),a}updateDraft(s,r){const a=this.getDrafts(),o=a.findIndex(d=>d.id===s);if(o===-1)return{success:!1,draft:null};const c={...a[o],...r,updatedAt:new Date};a[o]=c;const i=this.saveDrafts(a);return{success:i,draft:i?c:null}}deleteDraft(s){const r=this.getDrafts(),a=r.filter(o=>o.id!==s);return a.length===r.length?!1:(this.saveDrafts(a),!0)}getDraftCount(){return this.getAllDrafts().length}hasDrafts(){return this.getDraftCount()>0}getTimeUntilExpiration(s){const r=qs*24*60*60*1e3,a=s.updatedAt.getTime()+r,o=Math.max(0,a-Date.now()),c=Math.floor(o/(1440*60*1e3)),i=Math.floor(o%(1440*60*1e3)/(3600*1e3));return{days:c,hours:i}}}const Ge=new Xo;function pa({variant:t="icon",className:s=""}){const{t:r}=ne.useTranslation(["common","support"]),a=w.useNavigate(),{hasPermission:o}=Pe(),[c,i]=n.useState(!1),[d,u]=n.useState(!1),[m,p]=n.useState([]),g=n.useRef(null),f=o("support.my-tickets.create");n.useEffect(()=>{d&&p(Ge.getAllDrafts())},[d]),n.useEffect(()=>{const S=N=>{g.current&&!g.current.contains(N.target)&&u(!1)};return d&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[d]);const b=async S=>{i(!0),u(!1);const I=(S?Ge.getDraft(S):null)?.screenshot;let P=null;if(I)$t.clearContext();else try{P=await $t.captureContext(),$t.saveContext(P)}catch{}i(!1);const k=S?`/support/my-tickets/create?draft=${S}`:"/support/my-tickets/create";a(k)},h=async()=>{const S=Ge.getAllDrafts();S.length>0?(p(S),u(!0)):await b()},y=(S,N)=>{S.stopPropagation(),Ge.deleteDraft(N);const I=Ge.getAllDrafts();p(I),I.length===0&&u(!1)},x=S=>S.title?S.title.length>30?S.title.substring(0,30)+"...":S.title:S.type?r(`support:tickets.types.${S.type}`):r("common:drafts.untitled"),j=S=>{const I=new Date().getTime()-S.getTime(),P=Math.floor(I/6e4),k=Math.floor(I/36e5),A=Math.floor(I/864e5);return P<1?r("common:drafts.justNow"):P<60?r("common:drafts.minutesAgo",{count:P}):k<24?r("common:drafts.hoursAgo",{count:k}):r("common:drafts.daysAgo",{count:A})};if(!f)return null;const v=()=>e.jsxs("div",{ref:g,className:"absolute right-0 top-full mt-2 w-80 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl z-50",children:[e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"font-medium text-sm",children:r("common:drafts.existingDrafts")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r("common:drafts.selectOrCreate")})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:m.map(S=>{const N=Ge.getTimeUntilExpiration(S);return e.jsxs("button",{type:"button",onClick:()=>b(S.id),className:"w-full p-3 flex items-start gap-3 hover:bg-[var(--bg-hover)] transition-colors text-left border-b border-[var(--border-color)] last:border-b-0 cursor-pointer",children:[e.jsx(l.FileEdit,{className:"w-4 h-4 text-[var(--text-secondary)] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:x(S)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mt-1 flex-wrap",children:[S.tenantName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] truncate max-w-[120px]",children:S.tenantName}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"})]}),e.jsx(l.Clock,{className:"w-3 h-3"}),e.jsx("span",{children:j(S.updatedAt)}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:N.days>0?r("common:drafts.expiresInDays",{count:N.days}):r("common:drafts.expiresInHours",{count:N.hours})})]})]}),e.jsx("button",{onClick:I=>y(I,S.id),className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] transition-colors",title:r("common:actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]},S.id)})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>b(),className:"w-full flex items-center justify-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors text-sm",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),r("common:drafts.createNew")]})})]});return t==="icon"?e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(ma,{content:r("common:actions.createTicket"),position:"bottom",children:e.jsx("button",{onClick:h,disabled:c,className:`p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-50 ${s}`,children:c?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Headset,{className:"w-5 h-5"})})}),d&&v()]}):e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:h,disabled:c,className:`flex items-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors disabled:opacity-50 ${s}`,children:[c?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Headset,{className:"w-4 h-4"}),r("common:actions.createTicket")]}),d&&v()]})}function Nt({onMenuToggle:t}){const{t:s}=ne.useTranslation("navigation"),[r,a]=n.useState(!1),o=Ze(),{menu:c}=Ce(),{logout:i}=Pe(),d=c?.applications||[];return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx("button",{onClick:t,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.Menu,{className:"w-5 h-5"})}),e.jsxs(w.Link,{to:o("/applications"),className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 animated-gradient flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zo,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(ia,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(bs,{}),e.jsx(Kt,{}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 pl-3 border-l border-[var(--border-color)]",children:[!1,e.jsx(pa,{}),e.jsx(ua,{}),e.jsx(oa,{})]}),e.jsx("button",{onClick:()=>a(!r),className:"sm:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"sm:hidden py-4 border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[d.map(u=>e.jsx(w.Link,{to:o(u.route||"#"),className:"px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},onClick:()=>a(!1),children:u.label},u.id)),e.jsx("hr",{className:"my-2 border-[var(--border-color)]"}),e.jsxs("button",{onClick:()=>{a(!1),i()},className:"flex items-center gap-2 px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors text-red-500",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),s("header.logout")]})]})})]})})}function os({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function is(t){if(!t)return l.Box;const s=xt;if(s[t])return s[t];const r=t.toLowerCase(),a=Object.keys(s).find(o=>o.toLowerCase()===r);return a?s[a]:l.Box}function Yo({module:t,isActive:s,isCollapsed:r,onClose:a,buildUrl:o}){const[c,i]=n.useState(!1),[d,u]=n.useState({top:0,left:0}),m=n.useRef(null),p=n.useRef(null),g=()=>{if(r){if(m.current&&(clearTimeout(m.current),m.current=null),p.current){const b=p.current.getBoundingClientRect();u({top:b.top,left:b.right+8})}i(!0)}},f=()=>{r&&(m.current=setTimeout(()=>{i(!1)},150))};return n.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),e.jsxs("div",{ref:p,className:"relative",onMouseEnter:g,onMouseLeave:f,children:[e.jsxs(w.Link,{to:o(t.route),onClick:a,className:`flex items-center transition-colors ${r?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${s?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:r?`${t.label} (${t.applicationLabel})`:void 0,children:[e.jsx(os,{name:t.icon,className:"w-4 h-4 flex-shrink-0"}),!r&&e.jsx("span",{className:"text-sm font-medium truncate",children:t.label})]}),r&&c&&Ft.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:d.top,left:d.left},onMouseEnter:g,onMouseLeave:f,children:e.jsx("div",{className:"px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg whitespace-nowrap",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.label})})}),document.body)]})}function Jo({module:t,isExpanded:s,onToggle:r,onNavigate:a,currentPath:o,isCollapsed:c}){const[i,d]=n.useState(!1),[u,m]=n.useState({top:0,left:0}),[p,g]=n.useState(new Set),f=n.useRef(null),b=n.useRef(null),h=is(t.icon),y=t.route?o===t.route:o.includes(`/${t.code}`),x=(t.sections?.length??0)>0,j=t.label;n.useEffect(()=>{if(!t.sections)return;const P=t.sections.find(k=>k.resources?.some(A=>A.route&&o.startsWith(A.route)));P&&!p.has(P.id)&&g(k=>new Set([...k,P.id]))},[o,t.sections,p]);const v=P=>{g(k=>{const A=new Set(k);return A.has(P)?A.delete(P):A.add(P),A})},S=()=>{if(c){if(f.current&&(clearTimeout(f.current),f.current=null),b.current){const P=b.current.getBoundingClientRect();m({top:P.top,left:P.right+8})}d(!0)}},N=()=>{c&&(f.current=setTimeout(()=>{d(!1)},150))};n.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const I=()=>{x&&!c?r():t.route&&a(t.route)};return e.jsxs("div",{ref:b,className:"relative",onMouseEnter:S,onMouseLeave:N,children:[e.jsxs("button",{onClick:I,className:`w-full flex items-center transition-all duration-200 ${c?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${y?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:c&&!x?j:void 0,children:[e.jsx(h,{className:"w-5 h-5 flex-shrink-0"}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left font-medium text-sm truncate",children:j}),x&&(s?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}))]})]}),c&&i&&Ft.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:u.top,left:u.left},onMouseEnter:S,onMouseLeave:N,children:e.jsxs("div",{className:"min-w-[200px] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"px-3 py-2 border-b border-[var(--border-color)]",children:e.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:j})}),e.jsx("div",{className:"p-1.5",children:x?t.sections.map(P=>{const k=is(P.icon),A=P.route&&o===P.route;return e.jsxs("button",{onClick:()=>P.route&&a(P.route),className:`w-full flex items-center gap-2.5 px-2.5 py-2 transition-colors ${A?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(k,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:P.label})]},P.id)}):t.route&&e.jsxs("button",{onClick:()=>a(t.route),className:"w-full flex items-center gap-2.5 px-2.5 py-2 hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(h,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:"Ouvrir"})]})})]})}),document.body),!c&&s&&x&&e.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--border-color)] mt-1 space-y-1",children:t.sections.map(P=>e.jsx(Qo,{section:P,currentPath:o,onNavigate:a,isCollapsed:c,isExpanded:p.has(P.id),onToggle:()=>v(P.id)},P.id))})]})}function Qo({section:t,currentPath:s,onNavigate:r,isCollapsed:a,isExpanded:o,onToggle:c}){const i=is(t.icon),d=t.route&&(s===t.route||s.startsWith(t.route+"/")),u=(t.resources?.length??0)>0,m=t.label,p=g=>{g.preventDefault(),t.route&&r(t.route),u&&c()};return a?null:e.jsxs("div",{children:[e.jsxs("button",{onClick:p,className:`w-full flex items-center gap-3 px-3 py-2 transition-all duration-200 ${d?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(i,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-sm text-left",children:m}),u&&(o?e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}))]}),o&&u&&e.jsx("div",{className:"ml-4 pl-3 border-l border-[var(--border-color)] mt-1 space-y-0.5",children:t.resources.map(g=>e.jsx(Zo,{resource:g,currentPath:s,onNavigate:r},g.id))})]})}function Zo({resource:t,currentPath:s,onNavigate:r}){const a=t.route&&s.startsWith(t.route),o=c=>{c.preventDefault(),t.route&&r(t.route)};return e.jsxs("button",{onClick:o,className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 transition-all duration-200 ${a?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{className:"text-xs text-left",children:t.label})]})}const ei=(t,s)=>{if(t?.modules)return t.modules.find(r=>r.sections?.length?r.sections.some(a=>a.route&&(s===a.route||s.startsWith(a.route+"/"))):!1)},ti=(t,s)=>!!t.route&&s.startsWith(t.route)&&(t.sections?.length??0)>0,si=(t,s)=>{if(!t)return;const r=ei(t,s);return r||t.modules.find(a=>ti(a,s))};function xa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),o=w.useNavigate(),{getCurrentApplication:c,isLoading:i,currentAppCode:d,menu:u}=Ce(),{favorites:m,loading:p}=Ke(),{expandFavorites:g,clearExpand:f}=Ke(),{isCollapsed:b,toggleCollapsed:h}=Ut(),y=Ze(),[x,j]=n.useState(new Set),[v,S]=n.useState(!1);n.useEffect(()=>{g&&(queueMicrotask(()=>{S(!1)}),f())},[g,f]);const N=c(),I=n.useCallback(R=>{if(u)for(const $ of u.applications){const q=$.modules.find(C=>C.id===R.id);if(q?.sections?.length){const C=[...q.sections].sort((D,Y)=>D.displayOrder-Y.displayOrder)[0];if(C.route)return C.route}}return R.route},[u]);n.useEffect(()=>{if(!N)return;const R=si(N,a.pathname);R&&!x.has(R.id)&&queueMicrotask(()=>{j($=>new Set([...$,R.id]))})},[a.pathname,N,x]);const P=R=>{j($=>{const q=new Set($);return q.has(R)?q.delete(R):q.add(R),q})},k=R=>{o(y(R)),s()},A=N?.label??"";return N?e.jsxs(e.Fragment,{children:[t&&e.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s,"aria-label":"Close sidebar"}),e.jsxs("aside",{className:`group/sidebar fixed top-16 bottom-0 left-0 bg-[var(--bg-primary)] border-r border-[var(--border-color)] transform transition-all duration-300 z-50 overflow-visible ${b?"w-16":"w-64"} ${t?"translate-x-0":"-translate-x-full lg:translate-x-0"}`,children:[e.jsxs("button",{onClick:h,className:"hidden lg:flex absolute top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[9999]",style:{right:"-12px"},title:b?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:[e.jsx("div",{className:"absolute left-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-accent-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute right-0 w-4 h-4 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-accent-500)] group-hover/toggle:text-[var(--color-accent-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:b?e.jsx(l.ChevronRight,{className:"w-3 h-3"}):e.jsx(l.ChevronLeft,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:`${b?"p-2":"p-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between group/header",children:[b?e.jsx("div",{className:"w-full flex justify-center",children:e.jsx("div",{className:"w-10 h-10 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},title:A,children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})})}):e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 flex-shrink-0 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-[var(--text-primary)] truncate",children:A}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",style:{borderRadius:"4px"},children:[N.modules.length," ",N.modules.length===1?"module":"modules"]})})]})]}),e.jsx("button",{onClick:s,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsx("div",{className:`mt-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent ${b?"mx-1":""}`})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto overflow-x-hidden space-y-1 ${b?"p-2 pt-3":"p-3"}`,children:[!p&&m.length>0&&e.jsxs("div",{className:"mb-4",children:[!b&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 mb-1",children:[e.jsxs("button",{onClick:()=>S(!v),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`transition-transform duration-200 ${v?"":"rotate-90"}`,children:e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"})}),e.jsx(l.Star,{className:"w-3.5 h-3.5 text-amber-500"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:y("/myspace/preferences?tab=favorites"),onClick:s,className:"p-1.5 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(b||!v)&&e.jsx("div",{className:"space-y-0.5",children:m.map(R=>{const $=I(R);return e.jsx(Yo,{module:{...R,route:$},isActive:a.pathname.startsWith($),isCollapsed:b,onClose:s,buildUrl:y},R.id)})}),!b&&e.jsxs("div",{className:"mt-4 pt-4",children:[e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent mb-3"}),e.jsxs("div",{className:"flex items-center gap-2 px-3",children:[e.jsx("div",{className:"w-1 h-3.5 bg-gradient-to-b from-[var(--color-accent-500)] to-[var(--color-accent-300)] rounded-full"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider",children:r("sidebar.navigation","Navigation")})]})]}),b&&e.jsx("div",{className:"my-3 mx-1",children:e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"})})]}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[var(--color-accent-500)] border-t-transparent rounded-full animate-spin"})}),!i&&N.modules.length>0&&N.modules.map(R=>e.jsx(Jo,{module:R,isExpanded:x.has(R.id),onToggle:()=>P(R.id),onNavigate:k,currentPath:a.pathname,isCollapsed:b},R.id)),!i&&N.modules.length===0&&!b&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-8",children:r("sidebar.noModules","Aucun module disponible")})]}),!b&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"mb-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"}),e.jsxs("button",{onClick:()=>k(`/${d||"administration"}`),className:"w-full flex items-center gap-2 px-3 py-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-all",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.ChevronLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:r("sidebar.backToApps","Retour aux applications")})]})]})]})]})]}):null}const Us=60,ri=33;function ai(){const{t}=ne.useTranslation("common"),{isOpen:s,docUrl:r,closeDocPanel:a,panelSize:o,setPanelSize:c}=Gt();if(!s||!r)return null;const i=r.startsWith("http")?r:window.location.origin+r,d=i.includes("?")?"&":"?",u=`${i}${d}embedded=true`,m=o>=Us-1,p=()=>{c(m?ri:Us)};return e.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg-primary)] border-l border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsx("h3",{className:"font-semibold text-sm flex items-center gap-2",children:t("docPanel.title")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t(m?"docPanel.minimize":"docPanel.maximize"),children:m?e.jsx(l.Minimize2,{className:"w-4 h-4"}):e.jsx(l.Maximize2,{className:"w-4 h-4"})}),e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.openInNewTab"),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.close"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("iframe",{src:u,title:t("docPanel.title"),className:"w-full h-full border-0"})})]})}function ni({children:t}){const{isOpen:s,panelSize:r,setPanelSize:a}=Gt(),[o,c]=gt.useGroupCallbackRef(),i=n.useRef(r),[d,u]=n.useState(!1);if(n.useEffect(()=>{u(!!o)},[o]),n.useEffect(()=>{o&&d&&i.current!==r&&(o.setLayout({"main-content":100-r,"doc-panel":r}),i.current=r)},[r,o,d]),!s)return e.jsx(e.Fragment,{children:t});const m=g=>{i.current=g.asPercentage,a(g.asPercentage)},p={"main-content":100-r,"doc-panel":r};return e.jsxs(gt.Group,{orientation:"horizontal",className:"h-full",defaultLayout:p,groupRef:c,children:[e.jsx(gt.Panel,{id:"main-content",minSize:40,maxSize:80,children:e.jsx("div",{className:"w-full h-full overflow-auto",children:t})}),e.jsx(gt.Separator,{className:"w-1 bg-[var(--border-color)] hover:bg-[var(--color-primary-400)] transition-colors cursor-col-resize group/separator relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover/separator:bg-[var(--color-primary-100)]/20"})}),e.jsx(gt.Panel,{id:"doc-panel",minSize:20,maxSize:60,onResize:m,children:e.jsx(ai,{})})]})}function oi(){const{t}=ne.useTranslation("common"),{isOpen:s,openDocPanel:r}=Gt();return s?null:e.jsxs("button",{onClick:()=>r(),className:"hidden lg:flex fixed right-0 top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[100]",title:t("docPanel.open"),"aria-label":t("docPanel.open"),children:[e.jsx("div",{className:"absolute right-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-primary-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute left-0 -translate-x-full w-6 h-6 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-primary-500)] group-hover/toggle:text-[var(--color-primary-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:e.jsx(l.BookOpen,{className:"w-3 h-3"})}),e.jsx("div",{className:"absolute right-6 top-1/2 -translate-y-1/2 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md shadow-lg opacity-0 group-hover/toggle:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap text-xs font-medium text-[var(--text-primary)]",children:t("docPanel.title")})]})}function ii(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze(),[i,d]=n.useState(!1);if(r||!s||i)return null;const u=o?.roles?.includes("SuperAdmin")??!1,m=o?.permissions?.some(j=>j.startsWith("administration.configuration.license")||j==="administration.configuration.*"||j==="administration.*")??!1;if(!u&&!m)return null;const p=s.isInTrial&&s.trialDaysRemaining<=7,g=!s.isInTrial&&s.daysUntilExpiration<=30&&s.status==="Active";if(!(a||p||g))return null;const b=a,h=b?"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-200":"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200",y=b?l.Shield:l.AlertTriangle;let x;return a?x=t("license.alert.readOnly","Your license has expired. The platform is in read-only mode."):p?x=t("license.alert.trialExpiring","Your trial expires in {{days}} days. Activate a license to continue using the platform.",{days:s.trialDaysRemaining}):x=t("license.alert.expiringSoon","Your license expires in {{days}} days. Renew to avoid service interruption.",{days:s.daysUntilExpiration}),e.jsx("div",{className:`border-b ${h}`,children:e.jsxs("div",{className:"px-4 sm:px-6 lg:px-8 py-2 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(y,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-3 py-1 rounded-md transition-colors ${b?"bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-800/40":"bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-800/40"}`,children:t("license.alert.manage","Manage")}),e.jsx("button",{onClick:()=>d(!0),className:"p-1 rounded-md hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":t("common:dismiss","Dismiss"),children:e.jsx(l.X,{className:"w-3.5 h-3.5"})})]})]})})}function ha(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a,isServerDowntimeBlocked:o}=He(),{user:c}=Pe(),i=Ze();if(r)return null;const d=c?.roles?.includes("SuperAdmin")??!1,u=c?.permissions?.some(h=>h.startsWith("administration.configuration.license")||h==="administration.configuration.*"||h==="administration.*")??!1;if(!d&&!u)return null;let m,p,g;if(o)m="error",p=l.AlertTriangle,g=t("license.contentBanner.serverDowntime","The license server is unreachable. The platform is in restricted mode.");else if(s?.isInServerDowntimeGracePeriod)m="warning",p=l.Clock,g=t("license.contentBanner.serverDowntimeGracePeriod","The license server is unreachable. {{days}} days of grace period remaining. Please restore connectivity.",{days:s.serverDowntimeGracePeriodDays});else if(a)m="error",p=l.Shield,g=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="Revoked")m="error",p=l.Shield,g=t("license.contentBanner.revoked","Your license has been revoked. Please contact support or activate a new license.");else if(s?.status==="Expired")m="error",p=l.AlertTriangle,g=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="NoLicense"||!s)m="warning",p=l.Key,g=t("license.contentBanner.noLicense","No license is activated. Activate a license to use the platform without restrictions.");else if(s.isInTrial&&s.trialDaysRemaining<=7)m="warning",p=l.Clock,g=t("license.contentBanner.trialUrgent","Your trial expires in {{days}} days. Activate a license now to avoid losing access.",{days:s.trialDaysRemaining});else if(s.isInTrial&&s.trialDaysRemaining>7)m="info",p=l.Clock,g=t("license.contentBanner.trial","You are using a trial license. {{days}} days remaining. Activate a license to unlock the full platform.",{days:s.trialDaysRemaining});else return null;const f={error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",info:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]"},b={error:"bg-[var(--error-border)] hover:opacity-80 text-white",warning:"bg-[var(--warning-border)] hover:opacity-80 text-white",info:"bg-[var(--info-border)] hover:opacity-80 text-white"};return e.jsx("div",{className:`mb-4 rounded-lg border p-4 ${f[m]}`,"data-testid":"license-content-banner",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(p,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]}),e.jsx(w.Link,{to:i("/administration/configuration/license"),className:`text-xs font-medium px-4 py-1.5 rounded-md transition-opacity flex-shrink-0 ${b[m]}`,children:t("license.contentBanner.activate","Activate license")})]})})}function li(){const[t,s]=n.useState(!1),{currentAppCode:r}=Ce(),{isCollapsed:a}=Ut(),o=!!r,c=()=>o?a?"lg:pl-16":"lg:pl-64":"";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>s(!t)}),o&&e.jsx(xa,{isOpen:t,onClose:()=>s(!1)}),e.jsxs("main",{className:`pt-16 transition-all duration-300 h-[calc(100vh-4rem)] ${c()}`,children:[e.jsx(ii,{}),e.jsx(ni,{children:e.jsxs("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:[e.jsx(ha,{}),e.jsx(w.Outlet,{})]})})]}),e.jsx(oi,{})]})}function ga(){return e.jsx(Qr,{children:e.jsx(li,{})})}const ci=Object.freeze(Object.defineProperty({__proto__:null,AppLayout:ga},Symbol.toStringTag,{value:"Module"}));function di(){return e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-6 h-6 text-white"})}),e.jsx("span",{className:"text-2xl font-bold gradient-text",children:"SmartStack"})]})}),e.jsx("div",{className:"bg-[var(--bg-secondary)] rounded-2xl border border-[var(--border-color)] p-8",children:e.jsx(w.Outlet,{})})]})})}function ys(){const{t}=ne.useTranslation("navigation"),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1);return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[!1,e.jsx(bs,{}),e.jsx(Kt,{}),s?e.jsx(oa,{}):e.jsx("a",{href:"/login",className:"hidden md:inline-flex px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors",children:t("header.login")}),e.jsx("button",{onClick:()=>a(!r),className:"md:hidden p-2 rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors",children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"md:hidden py-4 border-t border-[var(--border-color)]",children:e.jsx("div",{className:"flex flex-col gap-4",children:!s&&e.jsx("a",{href:"/login",className:"px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors text-center",children:t("header.login")})})})]})})}function js(){const t=new Date().getFullYear();return e.jsx("footer",{className:"bg-[var(--bg-secondary)] border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsx("p",{className:"text-[var(--text-tertiary)] text-sm",children:"Le socle moderne pour vos applications d'entreprise."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Produit"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#features",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Fonctionnalités"})}),e.jsx("li",{children:e.jsx("a",{href:"#modules",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Modules"})}),e.jsx("li",{children:e.jsx("a",{href:"#pricing",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Tarifs"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Entreprise"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#about",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"À propos"})}),e.jsx("li",{children:e.jsx("a",{href:"#contact",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Contact"})}),e.jsx("li",{children:e.jsx("a",{href:"#careers",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Carrières"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Légal"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#privacy",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Confidentialité"})}),e.jsx("li",{children:e.jsx("a",{href:"#terms",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Conditions"})}),e.jsx("li",{children:e.jsx("a",{href:"#security",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Sécurité"})})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--border-color)] flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("p",{className:"text-[var(--text-tertiary)] text-sm",children:["© ",t," SmartStack. Tous droits réservés."]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("a",{href:"https://github.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Github,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://twitter.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Twitter,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://linkedin.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Linkedin,{className:"w-5 h-5"})})]})]})]})})}const ui=[{title:"Infrastructure",description:"Architecture technique, structure du projet et technologies utilisees",href:"/system/docs/developer/infrastructure",category:"developer",tags:[".NET 10","React 19","EF Core","SQL Server","architecture"],icon:l.Server},{title:"Installation",description:"Guide complet pour installer et configurer l'environnement de developpement",href:"/system/docs/developer/installation",category:"developer",tags:["setup","configuration","prerequisites","npm","dotnet","CLI","MCP"],icon:l.Download},{title:"Base de donnees",description:"Modele conceptuel de donnees avec schemas, tables et relations",href:"/system/docs/developer/database",category:"developer",tags:["MCD","Schemas","Relations","SQL","EF Core","migrations","ERD","diagramme","nav","auth","usr","support","ten","ai","wkf","cfg","entra","ref","loc","lic","Contexts","Applications","Modules","Sections","Resources","ContextMaintenance","Users","Roles","UserRoles","Permissions","RolePermissions","RefreshTokens","Sessions","Profiles","Preferences","Tickets","TicketComments","TicketAttachments","TicketTemplates","Notifications","Tenants","TenantApplications","TenantUsers","Providers","Models","Prompts","PromptVersions","PromptExecutions","Workflows","WorkflowSteps","WorkflowExecutions","EmailTemplates","Settings","SettingCategories","Groups","GroupMembers","SyncStates","Companies","Departments","Positions","Languages","Translations","Licenses","LicenseFeatures","Status","Type","Priority","TenantId","UserId","RoleId","PermissionId","CreatedAt","UpdatedAt","CreatedBy","UpdatedBy","IsDeleted","DeletedAt","TenantStatus","TicketStatus","TicketPriority","TicketType","UserType","Theme","Pending","Active","Suspended","Archived","Open","InProgress","Resolved","Closed","Low","Medium","High","Critical","Bug","FeatureRequest","Support","Question"],icon:l.Database},{title:"Architecture Dual-DbContext",description:"Separation Core/Extensions pour la distribution NuGet et les projets client",href:"/system/docs/developer/dual-dbcontext",category:"developer",tags:["CoreDbContext","ExtensionsDbContext","NuGet","Migrations","schema"],icon:l.Layers},{title:"FK Cross-Schema",description:"Comment referencer les entites Core depuis vos entites Extensions",href:"/system/docs/developer/cross-schema-fk",category:"developer",tags:["ICoreDataService","GUID FK","No Navigation","foreign key"],icon:l.Link2},{title:"Mode Multi-Tenant",description:"Configuration Single-Tenant vs Multi-Tenant et migration entre les modes",href:"/system/docs/developer/multi-tenant-mode",category:"developer",tags:["Single-Tenant","Multi-Tenant","Configuration","tenant","workspace"],icon:l.Building2},{title:"Integration Microsoft Teams",description:"Embarquer SmartStack dans Teams via Website Tab sans developpement",href:"/system/docs/developer/teams-integration",category:"developer",tags:["Microsoft Teams","Teams","Website Tab","iframe","SSO","embedding"],icon:l.Monitor},{title:"Architecture",description:"Vue d'ensemble de l'architecture fonctionnelle de SmartStack",href:"/system/docs/user/architecture",category:"user",tags:["architecture","modules","navigation","contextes"],icon:l.Layers},{title:"Modules",description:"Liste des modules disponibles et leur configuration",href:"/system/docs/user/modules",category:"user",tags:["modules","fonctionnalites","features"],icon:l.FileText},{title:"Module Support",description:"Documentation complete du module de ticketing et support client",href:"/system/docs/user/support",category:"user",tags:["tickets","support","SLA","escalation","templates"],icon:l.Headphones},{title:"Intelligence Artificielle",description:"Configuration des providers IA, prompts et integrations",href:"/system/docs/user/ai",category:"user",tags:["IA","AI","prompts","OpenAI","Claude","providers"],icon:l.Bot},{title:"Parametres Systeme",description:"Configuration globale et parametres de la plateforme",href:"/system/docs/user/settings",category:"user",tags:["settings","configuration","parametres","systeme"],icon:l.Settings},{title:"Presentation SmartStack",description:"Presentation interactive de la plateforme SmartStack",href:"/system/docs/presentation",category:"user",tags:["presentation","slides","demo","overview"],icon:l.Presentation}];function mi({className:t="",placeholder:s="Rechercher...",onResultClick:r}){const[a,o]=n.useState(""),[c,i]=n.useState(!1),[d,u]=n.useState(0),m=n.useRef(null),p=n.useRef(null),g=w.useNavigate(),f=n.useMemo(()=>{if(!a.trim())return[];const j=a.toLowerCase().split(" ").filter(Boolean);return ui.filter(v=>{const S=[v.title,v.description,...v.tags,v.category].join(" ").toLowerCase();return j.every(N=>S.includes(N))})},[a]);n.useEffect(()=>{u(0)},[f]);const b=j=>{if(!(!c||f.length===0))switch(j.key){case"ArrowDown":j.preventDefault(),u(v=>(v+1)%f.length);break;case"ArrowUp":j.preventDefault(),u(v=>(v-1+f.length)%f.length);break;case"Enter":j.preventDefault(),f[d]&&h(f[d]);break;case"Escape":i(!1),o(""),m.current?.blur();break}},h=j=>{g(j.href),o(""),i(!1),r?.()};n.useEffect(()=>{const j=v=>{p.current&&!p.current.contains(v.target)&&m.current&&!m.current.contains(v.target)&&i(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const y=j=>j==="developer"?"Developpeur":"Utilisateur",x=j=>j==="developer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400";return e.jsxs("div",{className:`relative ${t}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:m,type:"text",value:a,onChange:j=>{o(j.target.value),i(!0)},onFocus:()=>i(!0),onKeyDown:b,placeholder:s,className:"w-full pl-9 pr-8 py-2 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary-400)] focus:border-transparent"}),a&&e.jsx("button",{onClick:()=>{o(""),m.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-3 h-3 text-[var(--text-tertiary)]"})})]}),c&&a.trim()&&e.jsxs("div",{ref:p,className:"absolute top-full left-0 right-0 mt-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg overflow-hidden z-50 max-h-80 overflow-y-auto",children:[f.length===0?e.jsxs("div",{className:"p-4 text-center text-[var(--text-secondary)] text-sm",children:['Aucun resultat pour "',a,'"']}):e.jsx("div",{className:"py-1",children:f.map((j,v)=>{const S=j.icon;return e.jsxs("button",{onClick:()=>h(j),onMouseEnter:()=>u(v),className:`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors ${v===d?"bg-[var(--color-primary-600)]/10":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${v===d?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)]"}`,children:e.jsx(S,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:j.title}),e.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${x(j.category)}`,children:y(j.category)})]}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate mt-0.5",children:j.description})]}),e.jsx(l.ArrowRight,{className:`w-4 h-4 flex-shrink-0 mt-2 ${v===d?"text-[var(--color-primary-600)]":"text-[var(--text-tertiary)]"}`})]},j.href)})}),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border-color)] bg-[var(--bg-secondary)] text-xs text-[var(--text-tertiary)] flex items-center gap-4",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↑↓"})," naviguer"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↵"})," ouvrir"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"esc"})," fermer"]})]})]})]})}const pi=[{title:"Accueil",href:"/system/docs",icon:l.Book},{title:"Developpeur",href:"/system/docs/developer",icon:l.Code,children:[{title:"Infrastructure",href:"/system/docs/developer/infrastructure"},{title:"Installation",href:"/system/docs/developer/installation"},{title:"Base de donnees",href:"/system/docs/developer/database"},{title:"Dual-DbContext",href:"/system/docs/developer/dual-dbcontext"},{title:"FK Cross-Schema",href:"/system/docs/developer/cross-schema-fk"},{title:"Tenant",href:"/system/docs/developer/tenants",children:[{title:"Mode Multi-Tenant",href:"/system/docs/developer/tenants/multi-tenant-mode"},{title:"Tenant B2C",href:"/system/docs/developer/tenants/b2c"}]},{title:"Integration Teams",href:"/system/docs/developer/teams-integration"},{title:"Tests de Securite",href:"/system/docs/developer/testing/security"}]},{title:"Utilisateur",href:"/system/docs/user",icon:l.Users,children:[{title:"Architecture",href:"/system/docs/user/architecture"},{title:"Modules",href:"/system/docs/user/modules"}]},{title:"Analyse metier",href:"/system/docs/ba",icon:l.BarChart3}];function Yt({item:t,isChild:s=!1,depth:r=0}){const o=w.useLocation().pathname===t.href,c="icon"in t?t.icon:null;return e.jsxs(w.NavLink,{to:t.href,className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${o?"bg-[var(--color-primary-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"} ${s?"ml-6":""} ${r>1?"ml-12":""}`,children:[c&&e.jsx(c,{className:"w-4 h-4"}),!c&&s&&e.jsx(l.ChevronRight,{className:"w-3 h-3"}),t.title]})}function fa(){const[t,s]=n.useState(!1),r=w.useLocation(),[a]=w.useSearchParams(),o=a.get("embedded")==="true",c=p=>r.pathname===p.href?!0:"children"in p&&Array.isArray(p.children)?p.children.some(g=>r.pathname===g.href?!0:"children"in g&&Array.isArray(g.children)?g.children.some(f=>r.pathname===f.href):!1):!1,i=p=>r.pathname===p.href?!0:p.children?p.children.some(g=>r.pathname===g.href):!1,d=p=>p.children&&i(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(g=>e.jsx(Yt,{item:g,isChild:!0,depth:2},g.href))}):null,u=p=>p.children&&c(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(g=>e.jsxs("div",{children:[e.jsx(Yt,{item:g,isChild:!0}),d(g)]},g.href))}):null,m=()=>e.jsx("nav",{className:"space-y-1",children:pi.map(p=>e.jsxs("div",{children:[e.jsx(Yt,{item:p}),u(p)]},p.href))});return o?e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:e.jsx("main",{className:"p-4 lg:p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})}):e.jsx(gs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(ys,{}),e.jsxs("div",{className:"flex-1 flex pt-16",children:[e.jsx("button",{className:"lg:hidden fixed bottom-4 right-4 z-50 p-3 rounded-full bg-[var(--color-primary-600)] text-white shadow-lg",onClick:()=>s(!t),children:t?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})}),t&&e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-40 bg-black/50",onClick:()=>s(!1),"aria-label":"Close sidebar"}),e.jsx("aside",{className:`fixed lg:sticky top-16 z-40 lg:z-0 h-[calc(100vh-4rem)] w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] overflow-y-auto transition-transform lg:translate-x-0 ${t?"translate-x-0":"-translate-x-full"}`,children:e.jsxs("div",{className:"p-4",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(l.Book,{className:"w-5 h-5 text-[var(--color-primary-600)]"}),"Documentation"]}),e.jsx(mi,{className:"mb-4",placeholder:"Rechercher dans la doc...",onResultClick:()=>s(!1)}),e.jsx(m,{})]})}),e.jsx("main",{className:"flex-1 min-w-0 p-6 lg:p-8",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})]}),e.jsx(js,{})]})})}const xi=Object.freeze(Object.defineProperty({__proto__:null,DocsLayout:fa},Symbol.toStringTag,{value:"Module"}));function ba(){return e.jsx(gs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(ys,{}),e.jsx("main",{className:"flex-1 pt-16",children:e.jsx(w.Outlet,{})}),e.jsx(js,{})]})})}const hi=Object.freeze(Object.defineProperty({__proto__:null,PublicLayout:ba},Symbol.toStringTag,{value:"Module"}));function gi({items:t,className:s=""}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:`flex items-center gap-1 text-sm ${s}`,children:t.map((r,a)=>{const o=a===t.length-1,c=a===0;return e.jsxs("div",{className:"flex items-center gap-1",children:[a>0&&e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),o&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-primary)] font-medium",children:[r.icon,r.label]}),!o&&r.href&&e.jsxs(w.Link,{to:r.href,className:"flex items-center gap-1.5 text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[c&&!r.icon&&e.jsx(l.Home,{className:"w-4 h-4"}),r.icon,r.label]}),!o&&!r.href&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[r.icon,r.label]})]},`${a}-${r.label}`)})})}function Jt(t,s){return s.split(".").reduce((r,a)=>{if(r&&typeof r=="object"&&a in r)return r[a]},t)}function fi(t){return t==="right"?"justify-end":t==="center"?"justify-center":""}function bi(t,s){const r=s.toLowerCase();return Object.values(t).some(a=>a==null?!1:String(a).toLowerCase().includes(r))}function vi({data:t,columns:s,loading:r=!1,searchable:a=!1,searchPlaceholder:o="Rechercher...",pagination:c,onRowClick:i,getRowKey:d=(N,I)=>String(I),emptyMessage:u="Aucune donnée",emptyIcon:m,headerActions:p,striped:g=!0,compact:f=!1,className:b="",selectable:h=!1,selectedKeys:y=new Set,onSelectionChange:x,searchFilter:j=bi,defaultSortKey:v,defaultSortDirection:S="asc"}){const[N,I]=n.useState(""),[P,k]=n.useState(v||null),[A,R]=n.useState(S),[$,q]=n.useState(1),[C,D]=n.useState(c?.pageSize||10),Y=Array.isArray(t)?t:[],T=n.useMemo(()=>N?Y.filter(G=>j(G,N)):Y,[Y,N,j]),z=n.useMemo(()=>P?[...T].sort((G,ce)=>{const de=Jt(G,P),he=Jt(ce,P);if(de===he)return 0;if(de==null)return 1;if(he==null)return-1;const pe=String(de).localeCompare(String(he),void 0,{numeric:!0});return A==="asc"?pe:-pe}):T,[T,P,A]),Z=n.useMemo(()=>{if(!c)return z;const G=($-1)*C;return z.slice(G,G+C)},[z,c,$,C]),H=c?Math.ceil(z.length/C):1,J=z.length,fe=c?($-1)*C+1:1,B=c?Math.min($*C,J):J,Q=G=>{P===G?R(ce=>ce==="asc"?"desc":"asc"):(k(G),R("asc"))},M=G=>{q(Math.max(1,Math.min(G,H)))},re=()=>{if(!x)return;const G=Z.map((de,he)=>d(de,he));if(G.every(de=>y.has(de))){const de=new Set(y);G.forEach(he=>de.delete(he)),x(de)}else{const de=new Set(y);G.forEach(he=>de.add(he)),x(de)}},F=G=>{if(!x)return;const ce=new Set(y);ce.has(G)?ce.delete(G):ce.add(G),x(ce)},K=G=>{I(G),q(1)},V=f?"px-3 py-2":"px-4 py-3",ae=f?"px-3 py-2":"px-4 py-3",ue=G=>G.sortable?P===G.key?A==="asc"?e.jsx(l.ChevronUp,{className:"w-4 h-4"}):e.jsx(l.ChevronDown,{className:"w-4 h-4"}):e.jsx(l.ChevronsUpDown,{className:"w-4 h-4 opacity-30"}):null;return e.jsxs("div",{className:`${b}`,children:[(a||p)&&e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[a&&e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)] pointer-events-none"}),e.jsx("input",{type:"text",value:N,onChange:G=>K(G.target.value),placeholder:o,className:"input w-full pl-10 pr-10"}),N&&e.jsx("button",{onClick:()=>K(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),p&&e.jsx("div",{className:"flex items-center gap-2",children:p})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsxs("tr",{children:[h&&e.jsx("th",{className:`${ae} w-12`,children:e.jsx("input",{type:"checkbox",checked:Z.length>0&&Z.every((G,ce)=>y.has(d(G,ce))),onChange:re,className:"rounded border-[var(--border-color)]"})}),s.map(G=>e.jsx("th",{className:`${ae} text-${G.align||"left"} text-sm font-medium text-[var(--text-secondary)] ${G.hideOnMobile?"hidden md:table-cell":""} ${G.sortable?"cursor-pointer hover:bg-[var(--bg-tertiary)] select-none":""}`,style:{width:G.width},onClick:()=>G.sortable&&Q(G.key),children:e.jsxs("div",{className:`flex items-center gap-1 ${fi(G.align)}`,children:[e.jsx("span",{children:G.label}),ue(G)]})},G.key))]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(h?1:0),className:"py-12 text-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 mx-auto animate-spin text-[var(--color-primary-500)]"})})}),!r&&Z.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:s.length+(h?1:0),className:"py-12 text-center",children:[m&&e.jsx("div",{className:"mb-3",children:m}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:u})]})}),!r&&Z.length>0&&Z.map((G,ce)=>{const de=d(G,ce),he=y.has(de),pe=($-1)*C+ce;return e.jsxs("tr",{onClick:()=>i?.(G,pe),className:`
11
+ `,children:[t,e.jsx("div",{className:v()})]}),document.body)]})}const Tt="support_error_context";class Xo{async captureContext(){const s={url:window.location.href,timestamp:new Date,recentErrors:Te.getRecentErrors(),browserInfo:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,screenWidth:window.screen.width,screenHeight:window.screen.height}};try{const r=await this.captureScreenshot();s.screenshot=r}catch{Te.logError(new Error("Failed to capture screenshot"),"ErrorContextService")}return s}async captureScreenshot(){try{const r=await Rs.domToJpeg(document.body,{scale:1,quality:.85,backgroundColor:"#1a1a2e",style:{transform:"none"},filter:a=>{if(a instanceof HTMLElement){const o=a.tagName?.toUpperCase();return o!=="IFRAME"&&o!=="VIDEO"}return!0}});return r.length>4*1024*1024?await this.recompressScreenshot(r,.7):r}catch(s){console.error("[ErrorContextService] Screenshot capture failed:",s);try{return await Rs.domToJpeg(document.body,{scale:.75,quality:.8,backgroundColor:"#1a1a2e"})}catch(r){console.error("[ErrorContextService] Fallback also failed:",r);return}}}async recompressScreenshot(s,r){return new Promise(a=>{const o=new Image;o.onload=()=>{const c=document.createElement("canvas");c.width=o.width,c.height=o.height;const i=c.getContext("2d");if(i){i.drawImage(o,0,0);const d=c.toDataURL("image/jpeg",r);a(d)}else a(s)},o.onerror=()=>a(s),o.src=s})}saveContext(s){try{const r=JSON.stringify(s);try{sessionStorage.setItem(Tt,r)}catch{const o={...s,screenshot:void 0};sessionStorage.setItem(Tt,JSON.stringify(o))}}catch(r){console.error("[ErrorContextService] Failed to save context:",r)}}loadContext(){try{const s=sessionStorage.getItem(Tt);if(s){const r=JSON.parse(s);return r.timestamp=new Date(r.timestamp),r.recentErrors=r.recentErrors.map(a=>({...a,timestamp:new Date(a.timestamp)})),r.screenshot&&!r.screenshot.startsWith("data:image/")&&(r.screenshot=void 0),r}}catch(s){console.warn("[ErrorContextService] Failed to load context:",s)}return null}clearContext(){sessionStorage.removeItem(Tt)}formatErrorsForDescription(s){return s.length===0?"":s.slice(0,5).map((a,o)=>{const c=a.timestamp.toLocaleTimeString();return`${o+1}. [${c}] ${a.message}${a.component?` (${a.component})`:""}`}).join(`
12
+ `)}}const It=new Xo,Xt="ticket_drafts",Us=5,qs=7;class Yo{getDrafts(){try{const s=localStorage.getItem(Xt);return s?JSON.parse(s).map(a=>({...a,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt)})):[]}catch{return[]}}saveDrafts(s){try{const r=s.map(o=>({...o,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()})),a=JSON.stringify(r);return localStorage.setItem(Xt,a),!0}catch(r){if(console.error("[TicketDraftService] Failed to save drafts:",r),r instanceof DOMException&&r.name==="QuotaExceededError")try{const a=s.map(o=>({...o,screenshot:void 0,attachments:void 0,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()}));return localStorage.setItem(Xt,JSON.stringify(a)),!0}catch(a){console.error("[TicketDraftService] Still failed without large data:",a)}return!1}}cleanupExpiredDrafts(){const s=this.getDrafts(),r=new Date,a=qs*24*60*60*1e3,o=s.filter(c=>r.getTime()-c.updatedAt.getTime()<a);o.length!==s.length&&this.saveDrafts(o)}getAllDrafts(){return this.cleanupExpiredDrafts(),this.getDrafts().sort((s,r)=>r.updatedAt.getTime()-s.updatedAt.getTime())}getDraft(s){return this.getAllDrafts().find(a=>a.id===s)||null}createDraft(){const s=this.getAllDrafts();if(s.length>=Us){const c=s.at(-1);this.deleteDraft(c.id)}const r=new Date,a={id:xs(),type:null,title:"",description:"",priority:"Medium",includeScreenshot:!0,includeErrorLogs:!0,createdAt:r,updatedAt:r},o=[a,...this.getDrafts().slice(0,Us-1)];return this.saveDrafts(o),a}updateDraft(s,r){const a=this.getDrafts(),o=a.findIndex(d=>d.id===s);if(o===-1)return{success:!1,draft:null};const c={...a[o],...r,updatedAt:new Date};a[o]=c;const i=this.saveDrafts(a);return{success:i,draft:i?c:null}}deleteDraft(s){const r=this.getDrafts(),a=r.filter(o=>o.id!==s);return a.length===r.length?!1:(this.saveDrafts(a),!0)}getDraftCount(){return this.getAllDrafts().length}hasDrafts(){return this.getDraftCount()>0}getTimeUntilExpiration(s){const r=qs*24*60*60*1e3,a=s.updatedAt.getTime()+r,o=Math.max(0,a-Date.now()),c=Math.floor(o/(1440*60*1e3)),i=Math.floor(o%(1440*60*1e3)/(3600*1e3));return{days:c,hours:i}}}const Ge=new Yo;function ha({variant:t="icon",className:s=""}){const{t:r}=ne.useTranslation(["common","support"]),a=w.useNavigate(),{hasPermission:o}=Pe(),[c,i]=n.useState(!1),[d,u]=n.useState(!1),[m,p]=n.useState([]),x=n.useRef(null),f=o("support.my-tickets.create");n.useEffect(()=>{d&&p(Ge.getAllDrafts())},[d]),n.useEffect(()=>{const S=N=>{x.current&&!x.current.contains(N.target)&&u(!1)};return d&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[d]);const b=async S=>{i(!0),u(!1);const I=(S?Ge.getDraft(S):null)?.screenshot;let P=null;if(I)It.clearContext();else try{P=await It.captureContext(),It.saveContext(P)}catch{}i(!1);const k=S?`/support/my-tickets/create?draft=${S}`:"/support/my-tickets/create";a(k)},g=async()=>{const S=Ge.getAllDrafts();S.length>0?(p(S),u(!0)):await b()},y=(S,N)=>{S.stopPropagation(),Ge.deleteDraft(N);const I=Ge.getAllDrafts();p(I),I.length===0&&u(!1)},h=S=>S.title?S.title.length>30?S.title.substring(0,30)+"...":S.title:S.type?r(`support:tickets.types.${S.type}`):r("common:drafts.untitled"),j=S=>{const I=new Date().getTime()-S.getTime(),P=Math.floor(I/6e4),k=Math.floor(I/36e5),A=Math.floor(I/864e5);return P<1?r("common:drafts.justNow"):P<60?r("common:drafts.minutesAgo",{count:P}):k<24?r("common:drafts.hoursAgo",{count:k}):r("common:drafts.daysAgo",{count:A})};if(!f)return null;const v=()=>e.jsxs("div",{ref:x,className:"absolute right-0 top-full mt-2 w-80 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl z-50",children:[e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"font-medium text-sm",children:r("common:drafts.existingDrafts")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r("common:drafts.selectOrCreate")})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:m.map(S=>{const N=Ge.getTimeUntilExpiration(S);return e.jsxs("button",{type:"button",onClick:()=>b(S.id),className:"w-full p-3 flex items-start gap-3 hover:bg-[var(--bg-hover)] transition-colors text-left border-b border-[var(--border-color)] last:border-b-0 cursor-pointer",children:[e.jsx(l.FileEdit,{className:"w-4 h-4 text-[var(--text-secondary)] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:h(S)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mt-1 flex-wrap",children:[S.tenantName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] truncate max-w-[120px]",children:S.tenantName}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"})]}),e.jsx(l.Clock,{className:"w-3 h-3"}),e.jsx("span",{children:j(S.updatedAt)}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:N.days>0?r("common:drafts.expiresInDays",{count:N.days}):r("common:drafts.expiresInHours",{count:N.hours})})]})]}),e.jsx("button",{onClick:I=>y(I,S.id),className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] transition-colors",title:r("common:actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]},S.id)})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>b(),className:"w-full flex items-center justify-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors text-sm",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),r("common:drafts.createNew")]})})]});return t==="icon"?e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(xa,{content:r("common:actions.createTicket"),position:"bottom",children:e.jsx("button",{onClick:g,disabled:c,className:`p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-50 ${s}`,children:c?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Headset,{className:"w-5 h-5"})})}),d&&v()]}):e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:g,disabled:c,className:`flex items-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors disabled:opacity-50 ${s}`,children:[c?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Headset,{className:"w-4 h-4"}),r("common:actions.createTicket")]}),d&&v()]})}function jt({onMenuToggle:t}){const{t:s}=ne.useTranslation("navigation"),[r,a]=n.useState(!1),o=Ze(),{menu:c}=Ce(),{logout:i}=Pe(),d=c?.applications||[];return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx("button",{onClick:t,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.Menu,{className:"w-5 h-5"})}),e.jsxs(w.Link,{to:o("/applications"),className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 animated-gradient flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zo,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(ca,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(vs,{}),e.jsx(Kt,{}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 pl-3 border-l border-[var(--border-color)]",children:[!1,e.jsx(ha,{}),e.jsx(pa,{}),e.jsx(la,{})]}),e.jsx("button",{onClick:()=>a(!r),className:"sm:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"sm:hidden py-4 border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[d.map(u=>e.jsx(w.Link,{to:o(u.route||"#"),className:"px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},onClick:()=>a(!1),children:u.label},u.id)),e.jsx("hr",{className:"my-2 border-[var(--border-color)]"}),e.jsxs("button",{onClick:()=>{a(!1),i()},className:"flex items-center gap-2 px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors text-red-500",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),s("header.logout")]})]})})]})})}function os({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function is(t){if(!t)return l.Box;const s=xt;if(s[t])return s[t];const r=t.toLowerCase(),a=Object.keys(s).find(o=>o.toLowerCase()===r);return a?s[a]:l.Box}function Jo({module:t,isActive:s,isCollapsed:r,onClose:a,buildUrl:o}){const[c,i]=n.useState(!1),[d,u]=n.useState({top:0,left:0}),m=n.useRef(null),p=n.useRef(null),x=()=>{if(r){if(m.current&&(clearTimeout(m.current),m.current=null),p.current){const b=p.current.getBoundingClientRect();u({top:b.top,left:b.right+8})}i(!0)}},f=()=>{r&&(m.current=setTimeout(()=>{i(!1)},150))};return n.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),e.jsxs("div",{ref:p,className:"relative",onMouseEnter:x,onMouseLeave:f,children:[e.jsxs(w.Link,{to:o(t.route),onClick:a,className:`flex items-center transition-colors ${r?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${s?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:r?`${t.label} (${t.applicationLabel})`:void 0,children:[e.jsx(os,{name:t.icon,className:"w-4 h-4 flex-shrink-0"}),!r&&e.jsx("span",{className:"text-sm font-medium truncate",children:t.label})]}),r&&c&&Ot.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:d.top,left:d.left},onMouseEnter:x,onMouseLeave:f,children:e.jsx("div",{className:"px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg whitespace-nowrap",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.label})})}),document.body)]})}function Qo({module:t,isExpanded:s,onToggle:r,onNavigate:a,currentPath:o,isCollapsed:c}){const[i,d]=n.useState(!1),[u,m]=n.useState({top:0,left:0}),[p,x]=n.useState(new Set),f=n.useRef(null),b=n.useRef(null),g=is(t.icon),y=t.route?o===t.route:o.includes(`/${t.code}`),h=(t.sections?.length??0)>0,j=t.label;n.useEffect(()=>{if(!t.sections)return;const P=t.sections.find(k=>k.resources?.some(A=>A.route&&o.startsWith(A.route)));P&&!p.has(P.id)&&x(k=>new Set([...k,P.id]))},[o,t.sections,p]);const v=P=>{x(k=>{const A=new Set(k);return A.has(P)?A.delete(P):A.add(P),A})},S=()=>{if(c){if(f.current&&(clearTimeout(f.current),f.current=null),b.current){const P=b.current.getBoundingClientRect();m({top:P.top,left:P.right+8})}d(!0)}},N=()=>{c&&(f.current=setTimeout(()=>{d(!1)},150))};n.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const I=()=>{h&&!c?r():t.route&&a(t.route)};return e.jsxs("div",{ref:b,className:"relative",onMouseEnter:S,onMouseLeave:N,children:[e.jsxs("button",{onClick:I,className:`w-full flex items-center transition-all duration-200 ${c?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${y?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:c&&!h?j:void 0,children:[e.jsx(g,{className:"w-5 h-5 flex-shrink-0"}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left font-medium text-sm truncate",children:j}),h&&(s?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}))]})]}),c&&i&&Ot.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:u.top,left:u.left},onMouseEnter:S,onMouseLeave:N,children:e.jsxs("div",{className:"min-w-[200px] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"px-3 py-2 border-b border-[var(--border-color)]",children:e.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:j})}),e.jsx("div",{className:"p-1.5",children:h?t.sections.map(P=>{const k=is(P.icon),A=P.route&&o===P.route;return e.jsxs("button",{onClick:()=>P.route&&a(P.route),className:`w-full flex items-center gap-2.5 px-2.5 py-2 transition-colors ${A?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(k,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:P.label})]},P.id)}):t.route&&e.jsxs("button",{onClick:()=>a(t.route),className:"w-full flex items-center gap-2.5 px-2.5 py-2 hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(g,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:"Ouvrir"})]})})]})}),document.body),!c&&s&&h&&e.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--border-color)] mt-1 space-y-1",children:t.sections.map(P=>e.jsx(Zo,{section:P,currentPath:o,onNavigate:a,isCollapsed:c,isExpanded:p.has(P.id),onToggle:()=>v(P.id)},P.id))})]})}function Zo({section:t,currentPath:s,onNavigate:r,isCollapsed:a,isExpanded:o,onToggle:c}){const i=is(t.icon),d=t.route&&(s===t.route||s.startsWith(t.route+"/")),u=(t.resources?.length??0)>0,m=t.label,p=x=>{x.preventDefault(),t.route&&r(t.route),u&&c()};return a?null:e.jsxs("div",{children:[e.jsxs("button",{onClick:p,className:`w-full flex items-center gap-3 px-3 py-2 transition-all duration-200 ${d?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(i,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-sm text-left",children:m}),u&&(o?e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}))]}),o&&u&&e.jsx("div",{className:"ml-4 pl-3 border-l border-[var(--border-color)] mt-1 space-y-0.5",children:t.resources.map(x=>e.jsx(ei,{resource:x,currentPath:s,onNavigate:r},x.id))})]})}function ei({resource:t,currentPath:s,onNavigate:r}){const a=t.route&&s.startsWith(t.route),o=c=>{c.preventDefault(),t.route&&r(t.route)};return e.jsxs("button",{onClick:o,className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 transition-all duration-200 ${a?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{className:"text-xs text-left",children:t.label})]})}const ti=(t,s)=>{if(t?.modules)return t.modules.find(r=>r.sections?.length?r.sections.some(a=>a.route&&(s===a.route||s.startsWith(a.route+"/"))):!1)},si=(t,s)=>!!t.route&&s.startsWith(t.route)&&(t.sections?.length??0)>0,ri=(t,s)=>{if(!t)return;const r=ti(t,s);return r||t.modules.find(a=>si(a,s))};function ga({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),o=w.useNavigate(),{getCurrentApplication:c,isLoading:i,currentAppCode:d,menu:u}=Ce(),{favorites:m,loading:p}=Ke(),{expandFavorites:x,clearExpand:f}=Ke(),{isCollapsed:b,toggleCollapsed:g}=qt(),y=Ze(),[h,j]=n.useState(new Set),[v,S]=n.useState(!1);n.useEffect(()=>{x&&(queueMicrotask(()=>{S(!1)}),f())},[x,f]);const N=c(),I=n.useCallback(R=>{if(u)for(const $ of u.applications){const U=$.modules.find(C=>C.id===R.id);if(U?.sections?.length){const C=[...U.sections].sort((D,Y)=>D.displayOrder-Y.displayOrder)[0];if(C.route)return C.route}}return R.route},[u]);n.useEffect(()=>{if(!N)return;const R=ri(N,a.pathname);R&&!h.has(R.id)&&queueMicrotask(()=>{j($=>new Set([...$,R.id]))})},[a.pathname,N,h]);const P=R=>{j($=>{const U=new Set($);return U.has(R)?U.delete(R):U.add(R),U})},k=R=>{o(y(R)),s()},A=N?.label??"";return N?e.jsxs(e.Fragment,{children:[t&&e.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s,"aria-label":"Close sidebar"}),e.jsxs("aside",{className:`group/sidebar fixed top-16 bottom-0 left-0 bg-[var(--bg-primary)] border-r border-[var(--border-color)] transform transition-all duration-300 z-50 overflow-visible ${b?"w-16":"w-64"} ${t?"translate-x-0":"-translate-x-full lg:translate-x-0"}`,children:[e.jsxs("button",{onClick:g,className:"hidden lg:flex absolute top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[9999]",style:{right:"-12px"},title:b?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:[e.jsx("div",{className:"absolute left-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-accent-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute right-0 w-4 h-4 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-accent-500)] group-hover/toggle:text-[var(--color-accent-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:b?e.jsx(l.ChevronRight,{className:"w-3 h-3"}):e.jsx(l.ChevronLeft,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:`${b?"p-2":"p-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between group/header",children:[b?e.jsx("div",{className:"w-full flex justify-center",children:e.jsx("div",{className:"w-10 h-10 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},title:A,children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})})}):e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 flex-shrink-0 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-[var(--text-primary)] truncate",children:A}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",style:{borderRadius:"4px"},children:[N.modules.length," ",N.modules.length===1?"module":"modules"]})})]})]}),e.jsx("button",{onClick:s,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsx("div",{className:`mt-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent ${b?"mx-1":""}`})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto overflow-x-hidden space-y-1 ${b?"p-2 pt-3":"p-3"}`,children:[!p&&m.length>0&&e.jsxs("div",{className:"mb-4",children:[!b&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 mb-1",children:[e.jsxs("button",{onClick:()=>S(!v),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`transition-transform duration-200 ${v?"":"rotate-90"}`,children:e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"})}),e.jsx(l.Star,{className:"w-3.5 h-3.5 text-amber-500"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:y("/myspace/preferences?tab=favorites"),onClick:s,className:"p-1.5 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(b||!v)&&e.jsx("div",{className:"space-y-0.5",children:m.map(R=>{const $=I(R);return e.jsx(Jo,{module:{...R,route:$},isActive:a.pathname.startsWith($),isCollapsed:b,onClose:s,buildUrl:y},R.id)})}),!b&&e.jsxs("div",{className:"mt-4 pt-4",children:[e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent mb-3"}),e.jsxs("div",{className:"flex items-center gap-2 px-3",children:[e.jsx("div",{className:"w-1 h-3.5 bg-gradient-to-b from-[var(--color-accent-500)] to-[var(--color-accent-300)] rounded-full"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider",children:r("sidebar.navigation","Navigation")})]})]}),b&&e.jsx("div",{className:"my-3 mx-1",children:e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"})})]}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[var(--color-accent-500)] border-t-transparent rounded-full animate-spin"})}),!i&&N.modules.length>0&&N.modules.map(R=>e.jsx(Qo,{module:R,isExpanded:h.has(R.id),onToggle:()=>P(R.id),onNavigate:k,currentPath:a.pathname,isCollapsed:b},R.id)),!i&&N.modules.length===0&&!b&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-8",children:r("sidebar.noModules","Aucun module disponible")})]}),!b&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"mb-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"}),e.jsxs("button",{onClick:()=>k(`/${d||"administration"}`),className:"w-full flex items-center gap-2 px-3 py-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-all",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.ChevronLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:r("sidebar.backToApps","Retour aux applications")})]})]})]})]})]}):null}const Bs=60,ai=33;function ni(){const{t}=ne.useTranslation("common"),{isOpen:s,docUrl:r,closeDocPanel:a,panelSize:o,setPanelSize:c}=Gt();if(!s||!r)return null;const i=r.startsWith("http")?r:window.location.origin+r,d=i.includes("?")?"&":"?",u=`${i}${d}embedded=true`,m=o>=Bs-1,p=()=>{c(m?ai:Bs)};return e.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg-primary)] border-l border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsx("h3",{className:"font-semibold text-sm flex items-center gap-2",children:t("docPanel.title")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t(m?"docPanel.minimize":"docPanel.maximize"),children:m?e.jsx(l.Minimize2,{className:"w-4 h-4"}):e.jsx(l.Maximize2,{className:"w-4 h-4"})}),e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.openInNewTab"),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.close"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("iframe",{src:u,title:t("docPanel.title"),className:"w-full h-full border-0"})})]})}function oi({children:t}){const{isOpen:s,panelSize:r,setPanelSize:a}=Gt(),[o,c]=gt.useGroupCallbackRef(),i=n.useRef(r),[d,u]=n.useState(!1);if(n.useEffect(()=>{u(!!o)},[o]),n.useEffect(()=>{o&&d&&i.current!==r&&(o.setLayout({"main-content":100-r,"doc-panel":r}),i.current=r)},[r,o,d]),!s)return e.jsx(e.Fragment,{children:t});const m=x=>{i.current=x.asPercentage,a(x.asPercentage)},p={"main-content":100-r,"doc-panel":r};return e.jsxs(gt.Group,{orientation:"horizontal",className:"h-full",defaultLayout:p,groupRef:c,children:[e.jsx(gt.Panel,{id:"main-content",minSize:40,maxSize:80,children:e.jsx("div",{className:"w-full h-full overflow-auto",children:t})}),e.jsx(gt.Separator,{className:"w-1 bg-[var(--border-color)] hover:bg-[var(--color-primary-400)] transition-colors cursor-col-resize group/separator relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover/separator:bg-[var(--color-primary-100)]/20"})}),e.jsx(gt.Panel,{id:"doc-panel",minSize:20,maxSize:60,onResize:m,children:e.jsx(ni,{})})]})}function ii(){const{t}=ne.useTranslation("common"),{isOpen:s,openDocPanel:r}=Gt();return s?null:e.jsxs("button",{onClick:()=>r(),className:"hidden lg:flex fixed right-0 top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[100]",title:t("docPanel.open"),"aria-label":t("docPanel.open"),children:[e.jsx("div",{className:"absolute right-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-primary-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute left-0 -translate-x-full w-6 h-6 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-primary-500)] group-hover/toggle:text-[var(--color-primary-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:e.jsx(l.BookOpen,{className:"w-3 h-3"})}),e.jsx("div",{className:"absolute right-6 top-1/2 -translate-y-1/2 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md shadow-lg opacity-0 group-hover/toggle:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap text-xs font-medium text-[var(--text-primary)]",children:t("docPanel.title")})]})}function li(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze(),[i,d]=n.useState(!1);if(r||!s||i)return null;const u=o?.roles?.includes("SuperAdmin")??!1,m=o?.permissions?.some(j=>j.startsWith("administration.configuration.license")||j==="administration.configuration.*"||j==="administration.*")??!1;if(!u&&!m)return null;const p=s.isInTrial&&s.trialDaysRemaining<=7,x=!s.isInTrial&&s.daysUntilExpiration<=30&&s.status==="Active";if(!(a||p||x))return null;const b=a,g=b?"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-200":"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200",y=b?l.Shield:l.AlertTriangle;let h;return a?h=t("license.alert.readOnly","Your license has expired. The platform is in read-only mode."):p?h=t("license.alert.trialExpiring","Your trial expires in {{days}} days. Activate a license to continue using the platform.",{days:s.trialDaysRemaining}):h=t("license.alert.expiringSoon","Your license expires in {{days}} days. Renew to avoid service interruption.",{days:s.daysUntilExpiration}),e.jsx("div",{className:`border-b ${g}`,children:e.jsxs("div",{className:"px-4 sm:px-6 lg:px-8 py-2 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(y,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:h})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-3 py-1 rounded-md transition-colors ${b?"bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-800/40":"bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-800/40"}`,children:t("license.alert.manage","Manage")}),e.jsx("button",{onClick:()=>d(!0),className:"p-1 rounded-md hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":t("common:dismiss","Dismiss"),children:e.jsx(l.X,{className:"w-3.5 h-3.5"})})]})]})})}function fa(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a,isServerDowntimeBlocked:o}=He(),{user:c}=Pe(),i=Ze();if(r)return null;const d=c?.roles?.includes("SuperAdmin")??!1,u=c?.permissions?.some(g=>g.startsWith("administration.configuration.license")||g==="administration.configuration.*"||g==="administration.*")??!1;if(!d&&!u)return null;let m,p,x;if(o)m="error",p=l.AlertTriangle,x=t("license.contentBanner.serverDowntime","The license server is unreachable. The platform is in restricted mode.");else if(s?.isInServerDowntimeGracePeriod)m="warning",p=l.Clock,x=t("license.contentBanner.serverDowntimeGracePeriod","The license server is unreachable. {{days}} days of grace period remaining. Please restore connectivity.",{days:s.serverDowntimeGracePeriodDays});else if(a)m="error",p=l.Shield,x=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="Revoked")m="error",p=l.Shield,x=t("license.contentBanner.revoked","Your license has been revoked. Please contact support or activate a new license.");else if(s?.status==="Expired")m="error",p=l.AlertTriangle,x=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="NoLicense"||!s)m="warning",p=l.Key,x=t("license.contentBanner.noLicense","No license is activated. Activate a license to use the platform without restrictions.");else if(s.isInTrial&&s.trialDaysRemaining<=7)m="warning",p=l.Clock,x=t("license.contentBanner.trialUrgent","Your trial expires in {{days}} days. Activate a license now to avoid losing access.",{days:s.trialDaysRemaining});else if(s.isInTrial&&s.trialDaysRemaining>7)m="info",p=l.Clock,x=t("license.contentBanner.trial","You are using a trial license. {{days}} days remaining. Activate a license to unlock the full platform.",{days:s.trialDaysRemaining});else return null;const f={error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",info:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]"},b={error:"bg-[var(--error-border)] hover:opacity-80 text-white",warning:"bg-[var(--warning-border)] hover:opacity-80 text-white",info:"bg-[var(--info-border)] hover:opacity-80 text-white"};return e.jsx("div",{className:`mb-4 rounded-lg border p-4 ${f[m]}`,"data-testid":"license-content-banner",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(p,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:x})]}),e.jsx(w.Link,{to:i("/administration/configuration/license"),className:`text-xs font-medium px-4 py-1.5 rounded-md transition-opacity flex-shrink-0 ${b[m]}`,children:t("license.contentBanner.activate","Activate license")})]})})}function ci(){const[t,s]=n.useState(!1),{currentAppCode:r}=Ce(),{isCollapsed:a}=qt(),o=!!r,c=()=>o?a?"lg:pl-16":"lg:pl-64":"";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(jt,{onMenuToggle:()=>s(!t)}),o&&e.jsx(ga,{isOpen:t,onClose:()=>s(!1)}),e.jsxs("main",{className:`pt-16 transition-all duration-300 h-[calc(100vh-4rem)] ${c()}`,children:[e.jsx(li,{}),e.jsx(oi,{children:e.jsxs("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:[e.jsx(fa,{}),e.jsx(w.Outlet,{})]})})]}),e.jsx(ii,{})]})}function ba(){return e.jsx(ea,{children:e.jsx(ci,{})})}const di=Object.freeze(Object.defineProperty({__proto__:null,AppLayout:ba},Symbol.toStringTag,{value:"Module"}));function ui(){return e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-6 h-6 text-white"})}),e.jsx("span",{className:"text-2xl font-bold gradient-text",children:"SmartStack"})]})}),e.jsx("div",{className:"bg-[var(--bg-secondary)] rounded-2xl border border-[var(--border-color)] p-8",children:e.jsx(w.Outlet,{})})]})})}function js(){const{t}=ne.useTranslation("navigation"),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1);return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[!1,e.jsx(vs,{}),e.jsx(Kt,{}),s?e.jsx(la,{}):e.jsx("a",{href:"/login",className:"hidden md:inline-flex px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors",children:t("header.login")}),e.jsx("button",{onClick:()=>a(!r),className:"md:hidden p-2 rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors",children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"md:hidden py-4 border-t border-[var(--border-color)]",children:e.jsx("div",{className:"flex flex-col gap-4",children:!s&&e.jsx("a",{href:"/login",className:"px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors text-center",children:t("header.login")})})})]})})}function Ns(){const t=new Date().getFullYear();return e.jsx("footer",{className:"bg-[var(--bg-secondary)] border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsx("p",{className:"text-[var(--text-tertiary)] text-sm",children:"Le socle moderne pour vos applications d'entreprise."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Produit"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#features",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Fonctionnalités"})}),e.jsx("li",{children:e.jsx("a",{href:"#modules",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Modules"})}),e.jsx("li",{children:e.jsx("a",{href:"#pricing",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Tarifs"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Entreprise"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#about",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"À propos"})}),e.jsx("li",{children:e.jsx("a",{href:"#contact",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Contact"})}),e.jsx("li",{children:e.jsx("a",{href:"#careers",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Carrières"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Légal"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#privacy",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Confidentialité"})}),e.jsx("li",{children:e.jsx("a",{href:"#terms",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Conditions"})}),e.jsx("li",{children:e.jsx("a",{href:"#security",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Sécurité"})})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--border-color)] flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("p",{className:"text-[var(--text-tertiary)] text-sm",children:["© ",t," SmartStack. Tous droits réservés."]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("a",{href:"https://github.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Github,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://twitter.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Twitter,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://linkedin.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Linkedin,{className:"w-5 h-5"})})]})]})]})})}const mi=[{title:"Infrastructure",description:"Architecture technique, structure du projet et technologies utilisees",href:"/system/docs/developer/infrastructure",category:"developer",tags:[".NET 10","React 19","EF Core","SQL Server","architecture"],icon:l.Server},{title:"Installation",description:"Guide complet pour installer et configurer l'environnement de developpement",href:"/system/docs/developer/installation",category:"developer",tags:["setup","configuration","prerequisites","npm","dotnet","CLI","MCP"],icon:l.Download},{title:"Base de donnees",description:"Modele conceptuel de donnees avec schemas, tables et relations",href:"/system/docs/developer/database",category:"developer",tags:["MCD","Schemas","Relations","SQL","EF Core","migrations","ERD","diagramme","nav","auth","usr","support","ten","ai","wkf","cfg","entra","ref","loc","lic","Contexts","Applications","Modules","Sections","Resources","ContextMaintenance","Users","Roles","UserRoles","Permissions","RolePermissions","RefreshTokens","Sessions","Profiles","Preferences","Tickets","TicketComments","TicketAttachments","TicketTemplates","Notifications","Tenants","TenantApplications","TenantUsers","Providers","Models","Prompts","PromptVersions","PromptExecutions","Workflows","WorkflowSteps","WorkflowExecutions","EmailTemplates","Settings","SettingCategories","Groups","GroupMembers","SyncStates","Companies","Departments","Positions","Languages","Translations","Licenses","LicenseFeatures","Status","Type","Priority","TenantId","UserId","RoleId","PermissionId","CreatedAt","UpdatedAt","CreatedBy","UpdatedBy","IsDeleted","DeletedAt","TenantStatus","TicketStatus","TicketPriority","TicketType","UserType","Theme","Pending","Active","Suspended","Archived","Open","InProgress","Resolved","Closed","Low","Medium","High","Critical","Bug","FeatureRequest","Support","Question"],icon:l.Database},{title:"Architecture Dual-DbContext",description:"Separation Core/Extensions pour la distribution NuGet et les projets client",href:"/system/docs/developer/dual-dbcontext",category:"developer",tags:["CoreDbContext","ExtensionsDbContext","NuGet","Migrations","schema"],icon:l.Layers},{title:"FK Cross-Schema",description:"Comment referencer les entites Core depuis vos entites Extensions",href:"/system/docs/developer/cross-schema-fk",category:"developer",tags:["ICoreDataService","GUID FK","No Navigation","foreign key"],icon:l.Link2},{title:"Mode Multi-Tenant",description:"Configuration Single-Tenant vs Multi-Tenant et migration entre les modes",href:"/system/docs/developer/multi-tenant-mode",category:"developer",tags:["Single-Tenant","Multi-Tenant","Configuration","tenant","workspace"],icon:l.Building2},{title:"Integration Microsoft Teams",description:"Embarquer SmartStack dans Teams via Website Tab sans developpement",href:"/system/docs/developer/teams-integration",category:"developer",tags:["Microsoft Teams","Teams","Website Tab","iframe","SSO","embedding"],icon:l.Monitor},{title:"Architecture",description:"Vue d'ensemble de l'architecture fonctionnelle de SmartStack",href:"/system/docs/user/architecture",category:"user",tags:["architecture","modules","navigation","contextes"],icon:l.Layers},{title:"Modules",description:"Liste des modules disponibles et leur configuration",href:"/system/docs/user/modules",category:"user",tags:["modules","fonctionnalites","features"],icon:l.FileText},{title:"Module Support",description:"Documentation complete du module de ticketing et support client",href:"/system/docs/user/support",category:"user",tags:["tickets","support","SLA","escalation","templates"],icon:l.Headphones},{title:"Intelligence Artificielle",description:"Configuration des providers IA, prompts et integrations",href:"/system/docs/user/ai",category:"user",tags:["IA","AI","prompts","OpenAI","Claude","providers"],icon:l.Bot},{title:"Parametres Systeme",description:"Configuration globale et parametres de la plateforme",href:"/system/docs/user/settings",category:"user",tags:["settings","configuration","parametres","systeme"],icon:l.Settings},{title:"Presentation SmartStack",description:"Presentation interactive de la plateforme SmartStack",href:"/system/docs/presentation",category:"user",tags:["presentation","slides","demo","overview"],icon:l.Presentation}];function pi({className:t="",placeholder:s="Rechercher...",onResultClick:r}){const[a,o]=n.useState(""),[c,i]=n.useState(!1),[d,u]=n.useState(0),m=n.useRef(null),p=n.useRef(null),x=w.useNavigate(),f=n.useMemo(()=>{if(!a.trim())return[];const j=a.toLowerCase().split(" ").filter(Boolean);return mi.filter(v=>{const S=[v.title,v.description,...v.tags,v.category].join(" ").toLowerCase();return j.every(N=>S.includes(N))})},[a]);n.useEffect(()=>{u(0)},[f]);const b=j=>{if(!(!c||f.length===0))switch(j.key){case"ArrowDown":j.preventDefault(),u(v=>(v+1)%f.length);break;case"ArrowUp":j.preventDefault(),u(v=>(v-1+f.length)%f.length);break;case"Enter":j.preventDefault(),f[d]&&g(f[d]);break;case"Escape":i(!1),o(""),m.current?.blur();break}},g=j=>{x(j.href),o(""),i(!1),r?.()};n.useEffect(()=>{const j=v=>{p.current&&!p.current.contains(v.target)&&m.current&&!m.current.contains(v.target)&&i(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const y=j=>j==="developer"?"Developpeur":"Utilisateur",h=j=>j==="developer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400";return e.jsxs("div",{className:`relative ${t}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:m,type:"text",value:a,onChange:j=>{o(j.target.value),i(!0)},onFocus:()=>i(!0),onKeyDown:b,placeholder:s,className:"w-full pl-9 pr-8 py-2 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary-400)] focus:border-transparent"}),a&&e.jsx("button",{onClick:()=>{o(""),m.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-3 h-3 text-[var(--text-tertiary)]"})})]}),c&&a.trim()&&e.jsxs("div",{ref:p,className:"absolute top-full left-0 right-0 mt-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg overflow-hidden z-50 max-h-80 overflow-y-auto",children:[f.length===0?e.jsxs("div",{className:"p-4 text-center text-[var(--text-secondary)] text-sm",children:['Aucun resultat pour "',a,'"']}):e.jsx("div",{className:"py-1",children:f.map((j,v)=>{const S=j.icon;return e.jsxs("button",{onClick:()=>g(j),onMouseEnter:()=>u(v),className:`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors ${v===d?"bg-[var(--color-primary-600)]/10":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${v===d?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)]"}`,children:e.jsx(S,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:j.title}),e.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${h(j.category)}`,children:y(j.category)})]}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate mt-0.5",children:j.description})]}),e.jsx(l.ArrowRight,{className:`w-4 h-4 flex-shrink-0 mt-2 ${v===d?"text-[var(--color-primary-600)]":"text-[var(--text-tertiary)]"}`})]},j.href)})}),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border-color)] bg-[var(--bg-secondary)] text-xs text-[var(--text-tertiary)] flex items-center gap-4",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↑↓"})," naviguer"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↵"})," ouvrir"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"esc"})," fermer"]})]})]})]})}const xi=[{title:"Accueil",href:"/system/docs",icon:l.Book},{title:"Developpeur",href:"/system/docs/developer",icon:l.Code,children:[{title:"Infrastructure",href:"/system/docs/developer/infrastructure"},{title:"Installation",href:"/system/docs/developer/installation"},{title:"Base de donnees",href:"/system/docs/developer/database"},{title:"Dual-DbContext",href:"/system/docs/developer/dual-dbcontext"},{title:"FK Cross-Schema",href:"/system/docs/developer/cross-schema-fk"},{title:"Tenant",href:"/system/docs/developer/tenants",children:[{title:"Mode Multi-Tenant",href:"/system/docs/developer/tenants/multi-tenant-mode"},{title:"Tenant B2C",href:"/system/docs/developer/tenants/b2c"}]},{title:"Integration Teams",href:"/system/docs/developer/teams-integration"},{title:"Tests de Securite",href:"/system/docs/developer/testing/security"}]},{title:"Utilisateur",href:"/system/docs/user",icon:l.Users,children:[{title:"Architecture",href:"/system/docs/user/architecture"},{title:"Modules",href:"/system/docs/user/modules"}]},{title:"Analyse metier",href:"/system/docs/ba",icon:l.BarChart3}];function Yt({item:t,isChild:s=!1,depth:r=0}){const o=w.useLocation().pathname===t.href,c="icon"in t?t.icon:null;return e.jsxs(w.NavLink,{to:t.href,className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${o?"bg-[var(--color-primary-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"} ${s?"ml-6":""} ${r>1?"ml-12":""}`,children:[c&&e.jsx(c,{className:"w-4 h-4"}),!c&&s&&e.jsx(l.ChevronRight,{className:"w-3 h-3"}),t.title]})}function va(){const[t,s]=n.useState(!1),r=w.useLocation(),[a]=w.useSearchParams(),o=a.get("embedded")==="true",c=p=>r.pathname===p.href?!0:"children"in p&&Array.isArray(p.children)?p.children.some(x=>r.pathname===x.href?!0:"children"in x&&Array.isArray(x.children)?x.children.some(f=>r.pathname===f.href):!1):!1,i=p=>r.pathname===p.href?!0:p.children?p.children.some(x=>r.pathname===x.href):!1,d=p=>p.children&&i(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(x=>e.jsx(Yt,{item:x,isChild:!0,depth:2},x.href))}):null,u=p=>p.children&&c(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(x=>e.jsxs("div",{children:[e.jsx(Yt,{item:x,isChild:!0}),d(x)]},x.href))}):null,m=()=>e.jsx("nav",{className:"space-y-1",children:xi.map(p=>e.jsxs("div",{children:[e.jsx(Yt,{item:p}),u(p)]},p.href))});return o?e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:e.jsx("main",{className:"p-4 lg:p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})}):e.jsx(fs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(js,{}),e.jsxs("div",{className:"flex-1 flex pt-16",children:[e.jsx("button",{className:"lg:hidden fixed bottom-4 right-4 z-50 p-3 rounded-full bg-[var(--color-primary-600)] text-white shadow-lg",onClick:()=>s(!t),children:t?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})}),t&&e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-40 bg-black/50",onClick:()=>s(!1),"aria-label":"Close sidebar"}),e.jsx("aside",{className:`fixed lg:sticky top-16 z-40 lg:z-0 h-[calc(100vh-4rem)] w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] overflow-y-auto transition-transform lg:translate-x-0 ${t?"translate-x-0":"-translate-x-full"}`,children:e.jsxs("div",{className:"p-4",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(l.Book,{className:"w-5 h-5 text-[var(--color-primary-600)]"}),"Documentation"]}),e.jsx(pi,{className:"mb-4",placeholder:"Rechercher dans la doc...",onResultClick:()=>s(!1)}),e.jsx(m,{})]})}),e.jsx("main",{className:"flex-1 min-w-0 p-6 lg:p-8",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})]}),e.jsx(Ns,{})]})})}const hi=Object.freeze(Object.defineProperty({__proto__:null,DocsLayout:va},Symbol.toStringTag,{value:"Module"}));function ya(){return e.jsx(fs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(js,{}),e.jsx("main",{className:"flex-1 pt-16",children:e.jsx(w.Outlet,{})}),e.jsx(Ns,{})]})})}const gi=Object.freeze(Object.defineProperty({__proto__:null,PublicLayout:ya},Symbol.toStringTag,{value:"Module"}));function fi({items:t,className:s=""}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:`flex items-center gap-1 text-sm ${s}`,children:t.map((r,a)=>{const o=a===t.length-1,c=a===0;return e.jsxs("div",{className:"flex items-center gap-1",children:[a>0&&e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),o&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-primary)] font-medium",children:[r.icon,r.label]}),!o&&r.href&&e.jsxs(w.Link,{to:r.href,className:"flex items-center gap-1.5 text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[c&&!r.icon&&e.jsx(l.Home,{className:"w-4 h-4"}),r.icon,r.label]}),!o&&!r.href&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[r.icon,r.label]})]},`${a}-${r.label}`)})})}function Jt(t,s){return s.split(".").reduce((r,a)=>{if(r&&typeof r=="object"&&a in r)return r[a]},t)}function bi(t){return t==="right"?"justify-end":t==="center"?"justify-center":""}function vi(t,s){const r=s.toLowerCase();return Object.values(t).some(a=>a==null?!1:String(a).toLowerCase().includes(r))}function yi({data:t,columns:s,loading:r=!1,searchable:a=!1,searchPlaceholder:o="Rechercher...",pagination:c,onRowClick:i,getRowKey:d=(N,I)=>String(I),emptyMessage:u="Aucune donnée",emptyIcon:m,headerActions:p,striped:x=!0,compact:f=!1,className:b="",selectable:g=!1,selectedKeys:y=new Set,onSelectionChange:h,searchFilter:j=vi,defaultSortKey:v,defaultSortDirection:S="asc"}){const[N,I]=n.useState(""),[P,k]=n.useState(v||null),[A,R]=n.useState(S),[$,U]=n.useState(1),[C,D]=n.useState(c?.pageSize||10),Y=Array.isArray(t)?t:[],T=n.useMemo(()=>N?Y.filter(G=>j(G,N)):Y,[Y,N,j]),B=n.useMemo(()=>P?[...T].sort((G,ce)=>{const de=Jt(G,P),he=Jt(ce,P);if(de===he)return 0;if(de==null)return 1;if(he==null)return-1;const pe=String(de).localeCompare(String(he),void 0,{numeric:!0});return A==="asc"?pe:-pe}):T,[T,P,A]),Z=n.useMemo(()=>{if(!c)return B;const G=($-1)*C;return B.slice(G,G+C)},[B,c,$,C]),H=c?Math.ceil(B.length/C):1,J=B.length,fe=c?($-1)*C+1:1,z=c?Math.min($*C,J):J,Q=G=>{P===G?R(ce=>ce==="asc"?"desc":"asc"):(k(G),R("asc"))},M=G=>{U(Math.max(1,Math.min(G,H)))},re=()=>{if(!h)return;const G=Z.map((de,he)=>d(de,he));if(G.every(de=>y.has(de))){const de=new Set(y);G.forEach(he=>de.delete(he)),h(de)}else{const de=new Set(y);G.forEach(he=>de.add(he)),h(de)}},F=G=>{if(!h)return;const ce=new Set(y);ce.has(G)?ce.delete(G):ce.add(G),h(ce)},K=G=>{I(G),U(1)},V=f?"px-3 py-2":"px-4 py-3",ae=f?"px-3 py-2":"px-4 py-3",ue=G=>G.sortable?P===G.key?A==="asc"?e.jsx(l.ChevronUp,{className:"w-4 h-4"}):e.jsx(l.ChevronDown,{className:"w-4 h-4"}):e.jsx(l.ChevronsUpDown,{className:"w-4 h-4 opacity-30"}):null;return e.jsxs("div",{className:`${b}`,children:[(a||p)&&e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[a&&e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)] pointer-events-none"}),e.jsx("input",{type:"text",value:N,onChange:G=>K(G.target.value),placeholder:o,className:"input w-full pl-10 pr-10"}),N&&e.jsx("button",{onClick:()=>K(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),p&&e.jsx("div",{className:"flex items-center gap-2",children:p})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsxs("tr",{children:[g&&e.jsx("th",{className:`${ae} w-12`,children:e.jsx("input",{type:"checkbox",checked:Z.length>0&&Z.every((G,ce)=>y.has(d(G,ce))),onChange:re,className:"rounded border-[var(--border-color)]"})}),s.map(G=>e.jsx("th",{className:`${ae} text-${G.align||"left"} text-sm font-medium text-[var(--text-secondary)] ${G.hideOnMobile?"hidden md:table-cell":""} ${G.sortable?"cursor-pointer hover:bg-[var(--bg-tertiary)] select-none":""}`,style:{width:G.width},onClick:()=>G.sortable&&Q(G.key),children:e.jsxs("div",{className:`flex items-center gap-1 ${bi(G.align)}`,children:[e.jsx("span",{children:G.label}),ue(G)]})},G.key))]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(g?1:0),className:"py-12 text-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 mx-auto animate-spin text-[var(--color-primary-500)]"})})}),!r&&Z.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:s.length+(g?1:0),className:"py-12 text-center",children:[m&&e.jsx("div",{className:"mb-3",children:m}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:u})]})}),!r&&Z.length>0&&Z.map((G,ce)=>{const de=d(G,ce),he=y.has(de),pe=($-1)*C+ce;return e.jsxs("tr",{onClick:()=>i?.(G,pe),className:`
13
13
  border-b border-[var(--border-color)] last:border-b-0
14
- ${g&&ce%2===1?"bg-[var(--bg-secondary)]/50":""}
14
+ ${x&&ce%2===1?"bg-[var(--bg-secondary)]/50":""}
15
15
  ${i?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}
16
16
  ${he?"bg-[var(--accent-bg)]":""}
17
17
  transition-colors
18
- `,children:[h&&e.jsx("td",{className:`${V} w-12`,onClick:ye=>ye.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:he,onChange:()=>F(de),className:"rounded border-[var(--border-color)]"})}),s.map(ye=>e.jsx("td",{className:`${V} text-${ye.align||"left"} ${ye.hideOnMobile?"hidden md:table-cell":""}`,children:ye.render?ye.render(G,pe):String(Jt(G,ye.key)??"")},ye.key))]},de)})]})]})}),c&&J>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[fe,"-",B," sur ",J]}),c.showSizeSelector&&e.jsx("select",{value:C,onChange:G=>{D(Number(G.target.value)),q(1)},className:"input py-1 text-sm",children:(c.pageSizeOptions||[10,25,50,100]).map(G=>e.jsxs("option",{value:G,children:[G," / page"]},G))})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>M(1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M($-1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"px-3 text-sm",children:["Page ",$," / ",H]}),e.jsx("button",{onClick:()=>M($+1),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M(H),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})]})}function yi({data:t,viewMode:s,onViewModeChange:r,renderTable:a,renderCards:o,renderKanban:c,showTableView:i=!0,showCardsView:d=!0,showKanbanView:u=!0,tableLabel:m="Table",cardsLabel:p="Cards",kanbanLabel:g="Kanban"}){const[f,b]=n.useState("table"),h=s??f,y=r??b,j=[{mode:"table",label:m,icon:l.LayoutList,show:i},{mode:"cards",label:p,icon:l.LayoutGrid,show:d},{mode:"kanban",label:g,icon:l.Columns3,show:u}].filter(v=>v.show);return e.jsxs("div",{className:"space-y-4",children:[j.length>1&&e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] w-fit",children:j.map(({mode:v,label:S,icon:N})=>e.jsxs("button",{onClick:()=>y(v),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${h===v?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(N,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:S})]},v))}),e.jsxs("div",{children:[h==="table"&&a&&a(t),h==="cards"&&o&&o(t),h==="kanban"&&c&&c(t)]})]})}function va({viewMode:t,onChange:s,showTable:r=!0,showCards:a=!0,showKanban:o=!0,tableLabel:c="Table",cardsLabel:i="Cards",kanbanLabel:d="Kanban"}){const m=[{mode:"table",label:c,icon:l.LayoutList,show:r},{mode:"cards",label:i,icon:l.LayoutGrid,show:a},{mode:"kanban",label:d,icon:l.Columns3,show:o}].filter(p=>p.show);return m.length<=1?null:e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:m.map(({mode:p,label:g,icon:f})=>e.jsxs("button",{onClick:()=>s(p),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${t===p?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(f,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:g})]},p))})}const zs=["from-violet-500 to-purple-500","from-blue-500 to-cyan-500","from-emerald-500 to-teal-500","from-orange-500 to-amber-500","from-pink-500 to-rose-500","from-indigo-500 to-blue-500","from-fuchsia-500 to-pink-500","from-cyan-500 to-blue-500"];function ji(t){let s=0;for(let r=0;r<t.length;r++)s=t.charCodeAt(r)+((s<<5)-s);return zs[Math.abs(s)%zs.length]}function Ni(t){return t.split(" ").map(s=>s.at(0)).join("").toUpperCase().slice(0,2)}function wi({name:t,size:s="md",className:r=""}){const a={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-12 h-12 text-base",xl:"w-16 h-16 text-lg"},o={xs:"",sm:"shadow-md",md:"shadow-lg shadow-primary-500/20",lg:"shadow-lg shadow-primary-500/20",xl:"shadow-xl shadow-primary-500/25"};return e.jsx("div",{className:`${a[s]} ${o[s]} rounded-full bg-gradient-to-br ${ji(t)} flex items-center justify-center text-white font-semibold ${r}`,children:Ni(t)})}function Ot({status:t,label:s,showDot:r=!0,size:a="md"}){const o={active:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",inactive:"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] border-[var(--border-color)]",pending:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]"},c={active:"bg-[var(--success-dot)]",inactive:"bg-[var(--text-muted)]",pending:"bg-[var(--warning-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-xs"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${i[a]} rounded-[var(--radius-badge)] font-medium border ${o[t]}`,children:[r&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c[t]}`}),s]})}function Si({role:t,variant:s="default",icon:r}){const a={accent:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",default:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${a[s]}`,children:[r,t]})}function ya({title:t,count:s,color:r,children:a,isDragOver:o,isDropDisabled:c,onDragOver:i,onDragLeave:d,onDrop:u}){const m={success:"bg-[var(--success-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]",default:"bg-[var(--text-muted)]"};return e.jsxs("div",{className:`min-w-[280px] flex-1 rounded-lg p-2 transition-colors ${o&&!c?"bg-[var(--color-accent-500)]/10 ring-2 ring-[var(--color-accent-500)]/50":""} ${c?"opacity-40":""}`,onDragOver:c?void 0:i,onDragLeave:d,onDrop:c?void 0:u,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m[r]}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:s})]}),e.jsx("div",{className:"space-y-3 min-h-[100px]",children:a})]})}function ja({children:t,onClick:s,draggable:r=!0,isDragging:a,onDragStart:o,onDragEnd:c}){return e.jsx("div",{draggable:r,onClick:s,onKeyDown:s?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s())}:void 0,role:s?"button":void 0,tabIndex:s?0:void 0,onDragStart:o,onDragEnd:c,className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 transition-all hover:shadow-md hover:border-[var(--color-accent-500)]/30 cursor-grab active:cursor-grabbing ${a?"opacity-50 scale-95":""}`,children:t})}function Na({page:t,totalPages:s,totalCount:r,pageSize:a=20,onPageChange:o,itemLabel:c="éléments",showInfo:i=!0,showFirstLast:d=!0}){const u=(t-1)*a+1,m=Math.min(t*a,r),p=()=>{const g=[];if(s<=7)for(let f=1;f<=s;f++)g.push(f);else{g.push(1),t>3&&g.push("ellipsis");const f=Math.max(2,t-1),b=Math.min(s-1,t+1);for(let h=f;h<=b;h++)g.includes(h)||g.push(h);t<s-2&&g.push("ellipsis"),g.includes(s)||g.push(s)}return g};return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[i&&e.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Affichage de"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:u})," ","à"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:m})," ","sur"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:r})," ",c]}),s>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[d&&e.jsx("button",{onClick:()=>o(1),disabled:t===1,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>o(Math.max(1,t-1)),disabled:t===1,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex items-center gap-1",children:p().map((g,f)=>g==="ellipsis"?e.jsx("span",{className:"px-2 text-[var(--text-muted)]",children:"..."},`ellipsis-${f}`):e.jsx("button",{onClick:()=>o(g),className:`w-10 h-10 rounded-[var(--radius-button)] text-sm font-medium transition-all ${t===g?"bg-[var(--color-accent-600)] text-white shadow-lg shadow-[var(--color-accent-500)]/30":"btn btn-secondary hover:bg-[var(--bg-hover)]"}`,children:g},`page-${g}`))}),e.jsx("button",{onClick:()=>o(Math.min(s,t+1)),disabled:t===s,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-5 h-5"})}),d&&e.jsx("button",{onClick:()=>o(s),disabled:t===s,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})})}const Bs={default:"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",primary:"bg-[var(--accent-bg)] text-[var(--color-primary-600)]",success:"bg-[var(--success-bg)] text-[var(--success-text)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)]",error:"bg-[var(--error-bg)] text-[var(--error-text)]",info:"bg-[var(--info-bg)] text-[var(--info-text)]"};function Ns({avatar:t,title:s,subtitle:r,description:a,stats:o,badge:c,links:i,actions:d,tags:u,onClick:m,className:p="",customHeader:g,customBody:f,customFooter:b}){const h=["bg-[var(--bg-card)]","border-2 border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]","rounded-[var(--radius-card)]","overflow-hidden","transition-all","hover:shadow-lg hover:border-[var(--color-accent-400)]","flex flex-col",m?"cursor-pointer":"",p].filter(Boolean).join(" "),y=()=>t?t.imageUrl?e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 shadow-lg",children:e.jsx("img",{src:t.imageUrl,alt:s,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg flex-shrink-0",style:{backgroundColor:t.color},children:t.letter}):null,x=()=>{if(!c)return null;const N=c.icon,I=c.color?{color:c.color}:{};return e.jsxs("div",{className:"group relative",children:[N&&e.jsx(N,{className:"w-5 h-5 text-[var(--color-accent-700)] dark:text-[var(--color-accent-400)]",style:I}),c.tooltip&&e.jsx("div",{className:"absolute top-full right-0 mt-1 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded text-xs text-[var(--text-secondary)] whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-10",children:c.tooltip})]})},j=()=>g||e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y(),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:s}),r&&e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:r})]})]}),x()]})}),v=()=>f||e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[a&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] line-clamp-2",children:typeof a=="string"?e.jsx("p",{children:a}):a}),o&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-3",children:typeof o=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:o.split(" ")[0]})," ",o.split(" ").slice(1).join(" ")]}):o}),(u?.length??0)>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:u?.map(N=>N.onClick?e.jsx("button",{type:"button",className:`text-xs px-2 py-1 rounded-full cursor-pointer hover:opacity-80 ${Bs[N.variant||"default"]}`,onClick:N.onClick,children:N.label},N.label):e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${Bs[N.variant||"default"]}`,children:N.label},N.label))}),(i?.length??0)>0&&e.jsx("div",{className:"space-y-1.5 pt-2 mt-3 border-t border-[var(--border-color)]",children:i?.map(N=>{const I=N.icon;return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",onClick:P=>P.stopPropagation(),children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label):e.jsxs("button",{onClick:P=>{P.stopPropagation(),N.onClick?.()},className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label)})}),e.jsx("div",{className:"flex-1 min-h-4"}),S()]}),S=()=>b||(!d||d.length===0?null:e.jsx("div",{className:"space-y-2 mt-3",children:d.map(N=>{const I=N.icon,P=N.variant||"primary",R=`btn btn-sm flex items-center justify-center gap-1 w-full ${{primary:"bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] text-white",secondary:"bg-[var(--color-accent-700)] hover:bg-[var(--color-accent-800)] text-white",ghost:"bg-transparent border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]"}[P]} ${N.disabled?"opacity-50 cursor-not-allowed":""}`,$=N.loading&&e.jsx("span",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),q=!N.loading&&I&&e.jsx(I,{className:"w-4 h-4"});return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:R,onClick:C=>C.stopPropagation(),children:[$,q,N.label]},N.label):e.jsxs("button",{onClick:C=>{C.stopPropagation(),N.onClick?.()},disabled:N.disabled||N.loading,className:R,children:[$,q,N.label]},N.label)})}));return m?e.jsxs("button",{type:"button",className:`${h} text-left w-full`,onClick:m,children:[j(),v()]}):e.jsxs("div",{className:h,children:[j(),v()]})}function Ci({name:t,code:s,description:r,modelCount:a,color:o,websiteUrl:c,docsUrl:i,apiKeyUrl:d,adminApiKeyUrl:u,hasAdminKey:m=!1,badgeIcon:p,badgeTooltip:g,onGetApiKey:f,onGetAdminApiKey:b,labels:h={}}){const{websiteLabel:y="Site officiel",docsLabel:x="Documentation API",apiKeyLabel:j="Obtenir une clé API",adminApiKeyLabel:v="Obtenir une clé API Admin",modelsLabel:S="modèle(s)"}=h,N=[];c&&N.push({icon:l.ExternalLink,label:y,href:c}),i&&N.push({icon:l.BookOpen,label:x,href:i});const I=[];return d?I.push({label:j,href:d,variant:"primary"}):f&&I.push({label:j,onClick:f,variant:"primary"}),m&&(u?I.push({label:v,href:u,variant:"secondary"}):b&&I.push({label:v,onClick:b,variant:"secondary"})),e.jsx(Ns,{avatar:{letter:t.at(0)?.toUpperCase()??"",color:o},title:t,subtitle:s,description:r,stats:`${a} ${S}`,badge:p?{icon:p,tooltip:g}:void 0,links:N,actions:I})}function ki({name:t,code:s,category:r,isActive:a=!0,isSystem:o=!1,icon:c,iconColor:i="var(--color-accent-500)",translationsCount:d,onEdit:u,onDelete:m,onClick:p,labels:g={}}){const{systemLabel:f="System",inactiveLabel:b="Inactif",activeLabel:h="Actif",editLabel:y="Modifier",deleteLabel:x="Supprimer"}=g,j=[{label:r,variant:"default"}];o&&j.push({label:f,variant:"info"});const v=[];u&&v.push({label:y,onClick:u,variant:"ghost"}),m&&!o&&v.push({label:x,onClick:m,variant:"ghost"});const S=e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[c?e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center shadow-lg",style:{backgroundColor:i},children:e.jsx(c,{className:"w-5 h-5 text-white"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg",style:{backgroundColor:i},children:t.at(0)?.toUpperCase()}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:s})]})]}),e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${a?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),a?h:b]})]})}),N=e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(I=>e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${I.variant==="info"?"bg-[var(--info-bg)] text-[var(--info-text)]":"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"}`,children:I.label},I.label))}),d!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-3 text-[var(--text-tertiary)]",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m5 8 6 6"}),e.jsx("path",{d:"m4 14 6-6 2-3"}),e.jsx("path",{d:"M2 5h12"}),e.jsx("path",{d:"M7 2h1"}),e.jsx("path",{d:"m22 22-5-10-5 10"}),e.jsx("path",{d:"M14 18h6"})]}),e.jsx("span",{className:"text-xs",children:d})]}),e.jsx("div",{className:"flex-1 min-h-4"}),v.length>0&&e.jsx("div",{className:"flex items-center justify-end gap-1 mt-3 pt-3 border-t border-[var(--border-color)]",children:v.map(I=>e.jsx("button",{onClick:P=>{P.stopPropagation(),I.onClick?.()},className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] transition-all",title:I.label,children:I.label===y?e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}):e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})},I.label))})]});return e.jsx(Ns,{title:t,subtitle:s,onClick:p,customHeader:S,customBody:N})}function Ai({columns:t,items:s,getItemId:r,getItemColumn:a,onMoveItem:o,renderCard:c,loading:i=!1,onAddItem:d,onCardClick:u,cardActions:m,emptyColumnMessage:p="Aucun élément",className:g="",columnMinWidth:f="280px",disabled:b=!1}){const[h,y]=n.useState(null),[x,j]=n.useState(null),[v,S]=n.useState(null),N=n.useCallback(C=>{C.onClick(),S(null)},[]),I=n.useCallback((C,D)=>e.jsxs("button",{onClick:Y=>{Y.stopPropagation(),N(C)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-[var(--bg-tertiary)]",children:[C.icon,C.label]},D),[N]),P=n.useCallback(C=>s.filter(D=>a(D)===C),[s,a]),k=(C,D)=>{b||(y(D),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",D))},A=(C,D)=>{b||!h||(C.preventDefault(),C.dataTransfer.dropEffect="move",j(D))},R=()=>{j(null)},$=(C,D)=>{if(b)return;C.preventDefault();const Y=C.dataTransfer.getData("text/plain");Y&&o(Y,D),y(null),j(null)},q=()=>{y(null),j(null)};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):e.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${g}`,children:t.map(C=>{const D=P(C.id),Y=x===C.id,T=C.maxItems!==void 0&&D.length>=C.maxItems;return e.jsxs("div",{className:`flex-shrink-0 flex flex-col rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)] ${Y?"ring-2 ring-[var(--color-primary-500)]":""}`,style:{minWidth:f,maxWidth:f},onDragOver:z=>A(z,C.id),onDragLeave:R,onDrop:z=>$(z,C.id),children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[C.color&&e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:C.color}}),e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:C.title}),e.jsxs("span",{className:"text-xs text-[var(--text-secondary)] px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)]",children:[D.length,C.maxItems!==void 0&&` / ${C.maxItems}`]})]}),d&&C.canAddItem!==!1&&!T&&e.jsx("button",{onClick:()=>d(C.id),className:"btn btn-ghost p-1 hover:bg-[var(--bg-tertiary)]",title:"Ajouter","aria-label":`Ajouter à ${C.title}`,children:e.jsx(l.Plus,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex-1 p-2 space-y-2 overflow-y-auto max-h-[calc(100vh-300px)]",children:[D.length===0?e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)] text-sm",children:p}):D.map((z,Z)=>{const H=r(z),J=h===H,fe=m?.(z);return e.jsxs("div",{draggable:!b,onDragStart:B=>k(B,H),onDragEnd:q,onClick:()=>u?.(z),onKeyDown:u?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),u(z))}:void 0,role:u?"button":void 0,tabIndex:u?0:void 0,className:`
18
+ `,children:[g&&e.jsx("td",{className:`${V} w-12`,onClick:ye=>ye.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:he,onChange:()=>F(de),className:"rounded border-[var(--border-color)]"})}),s.map(ye=>e.jsx("td",{className:`${V} text-${ye.align||"left"} ${ye.hideOnMobile?"hidden md:table-cell":""}`,children:ye.render?ye.render(G,pe):String(Jt(G,ye.key)??"")},ye.key))]},de)})]})]})}),c&&J>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[fe,"-",z," sur ",J]}),c.showSizeSelector&&e.jsx("select",{value:C,onChange:G=>{D(Number(G.target.value)),U(1)},className:"input py-1 text-sm",children:(c.pageSizeOptions||[10,25,50,100]).map(G=>e.jsxs("option",{value:G,children:[G," / page"]},G))})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>M(1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M($-1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"px-3 text-sm",children:["Page ",$," / ",H]}),e.jsx("button",{onClick:()=>M($+1),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M(H),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})]})}function ji({data:t,viewMode:s,onViewModeChange:r,renderTable:a,renderCards:o,renderKanban:c,showTableView:i=!0,showCardsView:d=!0,showKanbanView:u=!0,tableLabel:m="Table",cardsLabel:p="Cards",kanbanLabel:x="Kanban"}){const[f,b]=n.useState("table"),g=s??f,y=r??b,j=[{mode:"table",label:m,icon:l.LayoutList,show:i},{mode:"cards",label:p,icon:l.LayoutGrid,show:d},{mode:"kanban",label:x,icon:l.Columns3,show:u}].filter(v=>v.show);return e.jsxs("div",{className:"space-y-4",children:[j.length>1&&e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] w-fit",children:j.map(({mode:v,label:S,icon:N})=>e.jsxs("button",{onClick:()=>y(v),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${g===v?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(N,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:S})]},v))}),e.jsxs("div",{children:[g==="table"&&a&&a(t),g==="cards"&&o&&o(t),g==="kanban"&&c&&c(t)]})]})}function ja({viewMode:t,onChange:s,showTable:r=!0,showCards:a=!0,showKanban:o=!0,tableLabel:c="Table",cardsLabel:i="Cards",kanbanLabel:d="Kanban"}){const m=[{mode:"table",label:c,icon:l.LayoutList,show:r},{mode:"cards",label:i,icon:l.LayoutGrid,show:a},{mode:"kanban",label:d,icon:l.Columns3,show:o}].filter(p=>p.show);return m.length<=1?null:e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:m.map(({mode:p,label:x,icon:f})=>e.jsxs("button",{onClick:()=>s(p),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${t===p?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(f,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:x})]},p))})}const zs=["from-violet-500 to-purple-500","from-blue-500 to-cyan-500","from-emerald-500 to-teal-500","from-orange-500 to-amber-500","from-pink-500 to-rose-500","from-indigo-500 to-blue-500","from-fuchsia-500 to-pink-500","from-cyan-500 to-blue-500"];function Ni(t){let s=0;for(let r=0;r<t.length;r++)s=t.charCodeAt(r)+((s<<5)-s);return zs[Math.abs(s)%zs.length]}function wi(t){return t.split(" ").map(s=>s.at(0)).join("").toUpperCase().slice(0,2)}function Si({name:t,size:s="md",className:r=""}){const a={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-12 h-12 text-base",xl:"w-16 h-16 text-lg"},o={xs:"",sm:"shadow-md",md:"shadow-lg shadow-primary-500/20",lg:"shadow-lg shadow-primary-500/20",xl:"shadow-xl shadow-primary-500/25"};return e.jsx("div",{className:`${a[s]} ${o[s]} rounded-full bg-gradient-to-br ${Ni(t)} flex items-center justify-center text-white font-semibold ${r}`,children:wi(t)})}function Mt({status:t,label:s,showDot:r=!0,size:a="md"}){const o={active:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",inactive:"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] border-[var(--border-color)]",pending:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]"},c={active:"bg-[var(--success-dot)]",inactive:"bg-[var(--text-muted)]",pending:"bg-[var(--warning-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-xs"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${i[a]} rounded-[var(--radius-badge)] font-medium border ${o[t]}`,children:[r&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c[t]}`}),s]})}function Ci({role:t,variant:s="default",icon:r}){const a={accent:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",default:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${a[s]}`,children:[r,t]})}function Na({title:t,count:s,color:r,children:a,isDragOver:o,isDropDisabled:c,onDragOver:i,onDragLeave:d,onDrop:u}){const m={success:"bg-[var(--success-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]",default:"bg-[var(--text-muted)]"};return e.jsxs("div",{className:`min-w-[280px] flex-1 rounded-lg p-2 transition-colors ${o&&!c?"bg-[var(--color-accent-500)]/10 ring-2 ring-[var(--color-accent-500)]/50":""} ${c?"opacity-40":""}`,onDragOver:c?void 0:i,onDragLeave:d,onDrop:c?void 0:u,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m[r]}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:s})]}),e.jsx("div",{className:"space-y-3 min-h-[100px]",children:a})]})}function wa({children:t,onClick:s,draggable:r=!0,isDragging:a,onDragStart:o,onDragEnd:c}){return e.jsx("div",{draggable:r,onClick:s,onKeyDown:s?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s())}:void 0,role:s?"button":void 0,tabIndex:s?0:void 0,onDragStart:o,onDragEnd:c,className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 transition-all hover:shadow-md hover:border-[var(--color-accent-500)]/30 cursor-grab active:cursor-grabbing ${a?"opacity-50 scale-95":""}`,children:t})}function Sa({page:t,totalPages:s,totalCount:r,pageSize:a=20,onPageChange:o,itemLabel:c="éléments",showInfo:i=!0,showFirstLast:d=!0}){const u=(t-1)*a+1,m=Math.min(t*a,r),p=()=>{const x=[];if(s<=7)for(let f=1;f<=s;f++)x.push(f);else{x.push(1),t>3&&x.push("ellipsis");const f=Math.max(2,t-1),b=Math.min(s-1,t+1);for(let g=f;g<=b;g++)x.includes(g)||x.push(g);t<s-2&&x.push("ellipsis"),x.includes(s)||x.push(s)}return x};return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[i&&e.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Affichage de"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:u})," ","à"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:m})," ","sur"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:r})," ",c]}),s>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[d&&e.jsx("button",{onClick:()=>o(1),disabled:t===1,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>o(Math.max(1,t-1)),disabled:t===1,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex items-center gap-1",children:p().map((x,f)=>x==="ellipsis"?e.jsx("span",{className:"px-2 text-[var(--text-muted)]",children:"..."},`ellipsis-${f}`):e.jsx("button",{onClick:()=>o(x),className:`w-10 h-10 rounded-[var(--radius-button)] text-sm font-medium transition-all ${t===x?"bg-[var(--color-accent-600)] text-white shadow-lg shadow-[var(--color-accent-500)]/30":"btn btn-secondary hover:bg-[var(--bg-hover)]"}`,children:x},`page-${x}`))}),e.jsx("button",{onClick:()=>o(Math.min(s,t+1)),disabled:t===s,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-5 h-5"})}),d&&e.jsx("button",{onClick:()=>o(s),disabled:t===s,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})})}const Gs={default:"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",primary:"bg-[var(--accent-bg)] text-[var(--color-primary-600)]",success:"bg-[var(--success-bg)] text-[var(--success-text)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)]",error:"bg-[var(--error-bg)] text-[var(--error-text)]",info:"bg-[var(--info-bg)] text-[var(--info-text)]"};function ws({avatar:t,title:s,subtitle:r,description:a,stats:o,badge:c,links:i,actions:d,tags:u,onClick:m,className:p="",customHeader:x,customBody:f,customFooter:b}){const g=["bg-[var(--bg-card)]","border-2 border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]","rounded-[var(--radius-card)]","overflow-hidden","transition-all","hover:shadow-lg hover:border-[var(--color-accent-400)]","flex flex-col",m?"cursor-pointer":"",p].filter(Boolean).join(" "),y=()=>t?t.imageUrl?e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 shadow-lg",children:e.jsx("img",{src:t.imageUrl,alt:s,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg flex-shrink-0",style:{backgroundColor:t.color},children:t.letter}):null,h=()=>{if(!c)return null;const N=c.icon,I=c.color?{color:c.color}:{};return e.jsxs("div",{className:"group relative",children:[N&&e.jsx(N,{className:"w-5 h-5 text-[var(--color-accent-700)] dark:text-[var(--color-accent-400)]",style:I}),c.tooltip&&e.jsx("div",{className:"absolute top-full right-0 mt-1 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded text-xs text-[var(--text-secondary)] whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-10",children:c.tooltip})]})},j=()=>x||e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y(),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:s}),r&&e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:r})]})]}),h()]})}),v=()=>f||e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[a&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] line-clamp-2",children:typeof a=="string"?e.jsx("p",{children:a}):a}),o&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-3",children:typeof o=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:o.split(" ")[0]})," ",o.split(" ").slice(1).join(" ")]}):o}),(u?.length??0)>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:u?.map(N=>N.onClick?e.jsx("button",{type:"button",className:`text-xs px-2 py-1 rounded-full cursor-pointer hover:opacity-80 ${Gs[N.variant||"default"]}`,onClick:N.onClick,children:N.label},N.label):e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${Gs[N.variant||"default"]}`,children:N.label},N.label))}),(i?.length??0)>0&&e.jsx("div",{className:"space-y-1.5 pt-2 mt-3 border-t border-[var(--border-color)]",children:i?.map(N=>{const I=N.icon;return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",onClick:P=>P.stopPropagation(),children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label):e.jsxs("button",{onClick:P=>{P.stopPropagation(),N.onClick?.()},className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label)})}),e.jsx("div",{className:"flex-1 min-h-4"}),S()]}),S=()=>b||(!d||d.length===0?null:e.jsx("div",{className:"space-y-2 mt-3",children:d.map(N=>{const I=N.icon,P=N.variant||"primary",R=`btn btn-sm flex items-center justify-center gap-1 w-full ${{primary:"bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] text-white",secondary:"bg-[var(--color-accent-700)] hover:bg-[var(--color-accent-800)] text-white",ghost:"bg-transparent border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]"}[P]} ${N.disabled?"opacity-50 cursor-not-allowed":""}`,$=N.loading&&e.jsx("span",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),U=!N.loading&&I&&e.jsx(I,{className:"w-4 h-4"});return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:R,onClick:C=>C.stopPropagation(),children:[$,U,N.label]},N.label):e.jsxs("button",{onClick:C=>{C.stopPropagation(),N.onClick?.()},disabled:N.disabled||N.loading,className:R,children:[$,U,N.label]},N.label)})}));return m?e.jsxs("button",{type:"button",className:`${g} text-left w-full`,onClick:m,children:[j(),v()]}):e.jsxs("div",{className:g,children:[j(),v()]})}function ki({name:t,code:s,description:r,modelCount:a,color:o,websiteUrl:c,docsUrl:i,apiKeyUrl:d,adminApiKeyUrl:u,hasAdminKey:m=!1,badgeIcon:p,badgeTooltip:x,onGetApiKey:f,onGetAdminApiKey:b,labels:g={}}){const{websiteLabel:y="Site officiel",docsLabel:h="Documentation API",apiKeyLabel:j="Obtenir une clé API",adminApiKeyLabel:v="Obtenir une clé API Admin",modelsLabel:S="modèle(s)"}=g,N=[];c&&N.push({icon:l.ExternalLink,label:y,href:c}),i&&N.push({icon:l.BookOpen,label:h,href:i});const I=[];return d?I.push({label:j,href:d,variant:"primary"}):f&&I.push({label:j,onClick:f,variant:"primary"}),m&&(u?I.push({label:v,href:u,variant:"secondary"}):b&&I.push({label:v,onClick:b,variant:"secondary"})),e.jsx(ws,{avatar:{letter:t.at(0)?.toUpperCase()??"",color:o},title:t,subtitle:s,description:r,stats:`${a} ${S}`,badge:p?{icon:p,tooltip:x}:void 0,links:N,actions:I})}function Ai({name:t,code:s,category:r,isActive:a=!0,isSystem:o=!1,icon:c,iconColor:i="var(--color-accent-500)",translationsCount:d,onEdit:u,onDelete:m,onClick:p,labels:x={}}){const{systemLabel:f="System",inactiveLabel:b="Inactif",activeLabel:g="Actif",editLabel:y="Modifier",deleteLabel:h="Supprimer"}=x,j=[{label:r,variant:"default"}];o&&j.push({label:f,variant:"info"});const v=[];u&&v.push({label:y,onClick:u,variant:"ghost"}),m&&!o&&v.push({label:h,onClick:m,variant:"ghost"});const S=e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[c?e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center shadow-lg",style:{backgroundColor:i},children:e.jsx(c,{className:"w-5 h-5 text-white"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg",style:{backgroundColor:i},children:t.at(0)?.toUpperCase()}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:s})]})]}),e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${a?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),a?g:b]})]})}),N=e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(I=>e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${I.variant==="info"?"bg-[var(--info-bg)] text-[var(--info-text)]":"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"}`,children:I.label},I.label))}),d!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-3 text-[var(--text-tertiary)]",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m5 8 6 6"}),e.jsx("path",{d:"m4 14 6-6 2-3"}),e.jsx("path",{d:"M2 5h12"}),e.jsx("path",{d:"M7 2h1"}),e.jsx("path",{d:"m22 22-5-10-5 10"}),e.jsx("path",{d:"M14 18h6"})]}),e.jsx("span",{className:"text-xs",children:d})]}),e.jsx("div",{className:"flex-1 min-h-4"}),v.length>0&&e.jsx("div",{className:"flex items-center justify-end gap-1 mt-3 pt-3 border-t border-[var(--border-color)]",children:v.map(I=>e.jsx("button",{onClick:P=>{P.stopPropagation(),I.onClick?.()},className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] transition-all",title:I.label,children:I.label===y?e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}):e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})},I.label))})]});return e.jsx(ws,{title:t,subtitle:s,onClick:p,customHeader:S,customBody:N})}function Pi({columns:t,items:s,getItemId:r,getItemColumn:a,onMoveItem:o,renderCard:c,loading:i=!1,onAddItem:d,onCardClick:u,cardActions:m,emptyColumnMessage:p="Aucun élément",className:x="",columnMinWidth:f="280px",disabled:b=!1}){const[g,y]=n.useState(null),[h,j]=n.useState(null),[v,S]=n.useState(null),N=n.useCallback(C=>{C.onClick(),S(null)},[]),I=n.useCallback((C,D)=>e.jsxs("button",{onClick:Y=>{Y.stopPropagation(),N(C)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-[var(--bg-tertiary)]",children:[C.icon,C.label]},D),[N]),P=n.useCallback(C=>s.filter(D=>a(D)===C),[s,a]),k=(C,D)=>{b||(y(D),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",D))},A=(C,D)=>{b||!g||(C.preventDefault(),C.dataTransfer.dropEffect="move",j(D))},R=()=>{j(null)},$=(C,D)=>{if(b)return;C.preventDefault();const Y=C.dataTransfer.getData("text/plain");Y&&o(Y,D),y(null),j(null)},U=()=>{y(null),j(null)};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):e.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${x}`,children:t.map(C=>{const D=P(C.id),Y=h===C.id,T=C.maxItems!==void 0&&D.length>=C.maxItems;return e.jsxs("div",{className:`flex-shrink-0 flex flex-col rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)] ${Y?"ring-2 ring-[var(--color-primary-500)]":""}`,style:{minWidth:f,maxWidth:f},onDragOver:B=>A(B,C.id),onDragLeave:R,onDrop:B=>$(B,C.id),children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[C.color&&e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:C.color}}),e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:C.title}),e.jsxs("span",{className:"text-xs text-[var(--text-secondary)] px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)]",children:[D.length,C.maxItems!==void 0&&` / ${C.maxItems}`]})]}),d&&C.canAddItem!==!1&&!T&&e.jsx("button",{onClick:()=>d(C.id),className:"btn btn-ghost p-1 hover:bg-[var(--bg-tertiary)]",title:"Ajouter","aria-label":`Ajouter à ${C.title}`,children:e.jsx(l.Plus,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex-1 p-2 space-y-2 overflow-y-auto max-h-[calc(100vh-300px)]",children:[D.length===0?e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)] text-sm",children:p}):D.map((B,Z)=>{const H=r(B),J=g===H,fe=m?.(B);return e.jsxs("div",{draggable:!b,onDragStart:z=>k(z,H),onDragEnd:U,onClick:()=>u?.(B),onKeyDown:u?z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),u(B))}:void 0,role:u?"button":void 0,tabIndex:u?0:void 0,className:`
19
19
  relative group
20
20
  bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg
21
21
  ${b?"":"cursor-grab active:cursor-grabbing"}
22
22
  ${J?"opacity-50 ring-2 ring-[var(--color-primary-500)]":""}
23
23
  ${u?"hover:border-[var(--color-primary-500)]":""}
24
24
  transition-all
25
- `,children:[!b&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(l.GripVertical,{className:"w-4 h-4 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`p-3 ${b?"":"pl-6"}`,children:c(z,Z)}),(fe?.length??0)>0&&e.jsxs("div",{className:"absolute top-2 right-2",children:[e.jsx("button",{onClick:B=>{B.stopPropagation(),S(v===H?null:H)},className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-tertiary)]","aria-label":"Actions",children:e.jsx(l.MoreHorizontal,{className:"w-4 h-4"})}),v===H&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"fixed inset-0 z-40",onClick:()=>S(null),"aria-label":"Close menu"}),e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg shadow-lg py-1 min-w-[150px]",children:fe?.map((B,Q)=>I(B,Q))})]})]})]},H)}),Y&&D.length>0&&e.jsx("div",{className:"h-16 border-2 border-dashed border-[var(--color-primary-500)] rounded-lg bg-[var(--accent-bg)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm text-[var(--color-primary-500)]",children:"Déposer ici"})})]})]},C.id)})})}function Pi({title:t,subtitle:s,icon:r,actions:a}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r,t]}),s&&e.jsx("p",{className:"text-[var(--text-secondary)]",children:s})]}),a&&e.jsx("div",{className:"flex items-center gap-3",children:a})]})}const Qt={granted:{icon:l.Check,color:"var(--success-text)",bg:"var(--success-bg)",label:"Accordé"},denied:{icon:l.X,color:"var(--error-text)",bg:"var(--error-bg)",label:"Refusé"},partial:{icon:l.Minus,color:"var(--warning-text)",bg:"var(--warning-bg)",label:"Partiel"},inherited:{icon:l.Check,color:"var(--info-text)",bg:"var(--info-bg)",label:"Hérité"},none:{icon:l.Minus,color:"var(--text-tertiary)",bg:"transparent",label:"Non défini"}};function Ti({rows:t,columns:s,getRowId:r,getRowLabel:a,getRowGroup:o,getRowSubGroup:c,getRowIcon:i,isRowLocked:d,getRowChildCount:u,getColumnId:m,getColumnLabel:p,getColumnShortLabel:g,isColumnLocked:f,getColumnColor:b,getCellState:h,onCellClick:y,loading:x=!1,showLegend:j=!0,searchable:v=!1,rowColumnWidth:S="250px",cellWidth:N="44px",className:I="",emptyMessage:P="Aucune donnée",canEditLocked:k=!1}){const[A,R]=n.useState(new Set),[$,q]=n.useState(""),C=n.useMemo(()=>{const B=new Map;return t.forEach(Q=>{const M=o?.(Q)||"_default",re=c?.(Q);B.has(M)||B.set(M,{rows:[],subGroups:new Map});const F=B.get(M);re?(F.subGroups.has(re)||F.subGroups.set(re,[]),F.subGroups.get(re).push(Q)):F.rows.push(Q)}),B},[t,o,c]),D=n.useCallback((B,Q)=>{const M=new Map;return B.forEach((re,F)=>{const K=re.filter(V=>a(V).toLowerCase().includes(Q));K.length>0&&M.set(F,K)}),M},[a]),Y=n.useMemo(()=>{if(!$)return C;const B=$.toLowerCase(),Q=new Map;return C.forEach((M,re)=>{const F=M.rows.filter(V=>a(V).toLowerCase().includes(B)),K=D(M.subGroups,B);(F.length>0||K.size>0)&&Q.set(re,{rows:F,subGroups:K})}),Q},[C,$,a,D]),T=B=>{R(Q=>{const M=new Set(Q);return M.has(B)?M.delete(B):M.add(B),M})},z=n.useCallback((B,Q,M,re)=>{y&&(M&&!k||re&&!k||y(B,Q))},[y,k]),Z=n.useCallback((B,Q)=>!(!y||B&&!k||Q&&!k),[y,k]),H=(B,Q)=>`w-full h-full min-h-[32px] flex items-center justify-center rounded transition-colors ${B?"hover:opacity-80 cursor-pointer":"cursor-default"} ${Q!=="none"?"":"opacity-30"}`,J=n.useCallback((B,Q,M,re,F,K,V,ae)=>{const ue=re.icon,G=Z(F,K);return e.jsx("td",{className:"px-0 py-1 text-center",style:{width:N},children:e.jsx("button",{type:"button",onClick:()=>z(B,Q,F,K),disabled:!G,className:H(G,M),style:{backgroundColor:re.bg},title:`${a(V)} × ${p(ae)}: ${re.label}`,children:M!=="none"&&e.jsx(ue,{className:"w-4 h-4",style:{color:re.color}})})},`${B}-${Q}`)},[y,k,z,N,a,p,Z,H]),fe=n.useCallback((B,Q,M,re,F)=>{const K=r(B),V=d?.(B)||!1,ae=i?.(B),ue=Q%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",G=Q%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${G}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 pl-12 ${ue}`,style:{width:re},children:e.jsxs("div",{className:"flex items-center gap-2",children:[ae,V&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:a(B)})]})}),M.map(ce=>{const de=m(ce),he=f?.(ce)||!1,pe=F(K,de),ye=Qt[pe];return J(K,de,pe,ye,V,he,B,ce)})]},K)},[r,d,i,a,m,f,J]);return x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):t.length===0||s.length===0?e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:P}):e.jsxs("div",{className:`space-y-4 ${I}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[v&&e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",value:$,onChange:B=>q(B.target.value),placeholder:"Rechercher...",className:"input pl-10 w-full"})]}),j&&e.jsx("div",{className:"flex items-center gap-4 text-xs",children:Object.entries(Qt).map(([B,Q])=>{if(B==="none")return null;const M=Q.icon;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center",style:{backgroundColor:Q.bg},children:e.jsx(M,{className:"w-3 h-3",style:{color:Q.color}})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:Q.label})]},B)})})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-[var(--bg-secondary)] px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider border-b border-[var(--border-color)]",style:{width:S,minWidth:S,height:"120px",verticalAlign:"bottom",paddingBottom:"12px"},children:"Ressource"}),s.map(B=>{const Q=m(B),M=g?.(B)||p(B),re=f?.(B),F=b?.(B);return e.jsx("th",{className:"relative overflow-visible border-b border-[var(--border-color)]",style:{width:N,minWidth:N,maxWidth:N,height:"120px",padding:0,verticalAlign:"bottom"},children:e.jsx("div",{className:"absolute bottom-2 left-1/2",style:{transform:"translateX(-6px) rotate(-55deg)",transformOrigin:"bottom left",width:"100px"},children:e.jsxs("div",{className:"flex items-center gap-1",children:[re&&e.jsx(l.Lock,{className:"w-3 h-3 flex-shrink-0 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] whitespace-nowrap",style:{color:F},title:p(B),children:M})]})})},Q)})]})}),e.jsx("tbody",{children:Array.from(Y.entries()).map(([B,Q])=>{const M=A.has(B),re=B==="_default",F=Q.rows.length+Array.from(Q.subGroups.values()).reduce((K,V)=>K+V.length,0);return e.jsxs("tbody",{children:[!re&&e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-2 bg-[var(--color-accent-900)]/30",style:{width:S},children:e.jsxs("button",{onClick:()=>T(B),className:"flex items-center gap-2 w-full text-left hover:opacity-80",children:[M?e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--color-accent-400)]"}):e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase",children:B}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)]",children:["(",F,")"]})]})}),e.jsx("td",{colSpan:s.length})]}),!M&&e.jsxs(e.Fragment,{children:[Q.rows.map((K,V)=>{const ae=r(K),ue=d?.(K)||!1,G=i?.(K),ce=u?.(K),de=V%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",he=V%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${he}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 ${de}`,style:{width:S},children:e.jsxs("div",{className:"flex items-center gap-2",children:[G,ue&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:a(K)}),ce!==void 0&&e.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",ce,")"]})]})}),s.map(pe=>{const ye=m(pe),qe=f?.(pe)||!1,Ue=h(ae,ye),Ve=Qt[Ue];return J(ae,ye,Ue,Ve,ue,qe,K,pe)})]},ae)}),Array.from(Q.subGroups.entries()).map(([K,V])=>e.jsxs("tbody",{children:[e.jsxs("tr",{className:"bg-[var(--bg-tertiary)]",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-1 pl-8 bg-[var(--bg-tertiary)]",style:{width:S},children:e.jsxs("span",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase",children:[K," (",V.length,")"]})}),e.jsx("td",{colSpan:s.length})]}),V.map((ae,ue)=>fe(ae,ue,s,S,h))]},K))]})]},B)})})]})})]})}const Ri=[{size:"none",icon:"square"},{size:"small",icon:"rounded"},{size:"medium",icon:"rounded"},{size:"large",icon:"rounded"},{size:"xlarge",icon:"rounded"},{size:"xxlarge",icon:"rounded"}];function it({label:t,element:s,value:r,onChange:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ri.map(({size:o})=>e.jsx("button",{onClick:()=>a(s,o),className:`px-3 py-2 text-xs font-medium transition-all ${r===o?"bg-[var(--color-accent-500)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,style:{borderRadius:Qe[o]},children:Za[o]},o))})]})}const Ei=({selectedThemeTenant:t,setSelectedThemeTenant:s,currentTenant:r,t:a})=>e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:a("theme.scope.title","Portée du thème")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("theme.scope.description","Choisissez si ce thème s'applique à tous vos espaces ou uniquement à l'espace actuel")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>s(null),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===null?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Globe,{className:`w-5 h-5 ${t===null?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===null?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:a("theme.scope.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.globalDesc","Tous les espaces")})]}),t===null&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]}),e.jsxs("button",{type:"button",onClick:()=>s(r.id),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===r.id?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Building2,{className:`w-5 h-5 ${t===r.id?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===r.id?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:r.name}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.tenantDesc","Espace actuel uniquement")})]}),t===r.id&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]})]})]});function Ii({onSync:t,isSyncing:s=!1,syncSuccess:r=!1}){const{t:a}=ne.useTranslation("preferences"),{config:o,mode:c,setMode:i,setBorderRadius:d,setAccentColor:u,setItemPalette:m,applyPreset:p,resetToDefault:g,selectedThemeTenant:f,setSelectedThemeTenant:b}=St(),{currentTenant:h,hasMultipleTenants:y}=Ee(),x=y&&h;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)]",children:"Personnalisation"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Personnalisez l'apparence de l'interface"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs("button",{type:"button",onClick:t,disabled:s,className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{borderRadius:"var(--radius-button)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Sync..."]}),!s&&r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Check,{className:"w-4 h-4"}),"Synchronisé"]}),!s&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),"Synchroniser"]})]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(l.RotateCcw,{className:"w-4 h-4"}),"Réinitialiser"]})]})]}),x&&e.jsx(Ei,{selectedThemeTenant:f,setSelectedThemeTenant:b,currentTenant:h,t:a}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Thèmes prédéfinis"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:tn.map(j=>{const v=o.accentColorKey===j.config.accentColorKey&&JSON.stringify(o.borderRadius)===JSON.stringify(j.config.borderRadius);return e.jsxs("button",{onClick:()=>p(j.config),className:`p-4 text-left transition-all border ${v?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:j.icon}),v&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)]",children:j.name}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:j.description})]},j.id)})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Mode d'affichage"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>i("light"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="light"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Sun,{className:`w-5 h-5 ${c==="light"?"text-amber-500":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="light"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Clair"})]}),e.jsxs("button",{onClick:()=>i("dark"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="dark"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Moon,{className:`w-5 h-5 ${c==="dark"?"text-[var(--color-accent-400)]":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="dark"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Sombre"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Palette,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Couleur d'accent"})]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Object.entries(_e).map(([j,{name:v,shades:S}])=>e.jsx("button",{onClick:()=>u(j),className:`relative w-10 h-10 transition-all ${o.accentColorKey===j?"ring-2 ring-offset-2 ring-[var(--border-strong)]":""}`,style:{backgroundColor:S[500],borderRadius:"var(--radius-button)"},title:v,children:o.accentColorKey===j&&e.jsx(l.Check,{className:"absolute inset-0 m-auto w-5 h-5 text-white"})},j))}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Couleur actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:_e[o.accentColorKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Layers,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Palette des éléments"})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Choisissez une palette de couleurs pour les cards et éléments de l'interface"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:Object.entries(ut).map(([j,v])=>{const S=c==="dark"?v.colors.dark:v.colors.light,N=o.itemPaletteKey===j;return e.jsxs("button",{onClick:()=>m(j),className:`p-4 text-left transition-all border ${N?"border-[var(--color-accent-500)] ring-2 ring-[var(--color-accent-500)] ring-opacity-30":"border-[var(--border-color)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xl",children:v.icon}),N&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex h-8 mb-3 rounded overflow-hidden border",style:{borderColor:S.dark},children:[e.jsx("div",{className:"flex-1",style:{backgroundColor:S.light}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.medium}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.dark}})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)] text-sm",children:v.name})]},j)})}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Palette actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:ut[o.itemPaletteKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Square,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Style des coins"})]}),e.jsxs("div",{className:"space-y-4 p-4 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:[e.jsx(it,{label:"Cards & Containers",element:"card",value:o.borderRadius.card,onChange:d}),e.jsx(it,{label:"Boutons",element:"button",value:o.borderRadius.button,onChange:d}),e.jsx(it,{label:"Badges",element:"badge",value:o.borderRadius.badge,onChange:d}),e.jsx(it,{label:"Champs de saisie",element:"input",value:o.borderRadius.input,onChange:d}),e.jsx(it,{label:"Modales",element:"modal",value:o.borderRadius.modal,onChange:d}),e.jsx(it,{label:"Éléments de menu",element:"menuItem",value:o.borderRadius.menuItem,onChange:d})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Circle,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Aperçu"})]}),e.jsx("div",{className:"p-6 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"badge-success px-3 py-1 text-xs font-medium",children:"Succès"}),e.jsx("span",{className:"badge-warning px-3 py-1 text-xs font-medium",children:"Attention"}),e.jsx("span",{className:"badge-error px-3 py-1 text-xs font-medium",children:"Erreur"}),e.jsx("span",{className:"badge-info px-3 py-1 text-xs font-medium",children:"Info"}),e.jsx("span",{className:"badge-accent px-3 py-1 text-xs font-medium",children:"Accent"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{className:"btn btn-primary",children:"Bouton primaire"}),e.jsx("button",{className:"btn btn-secondary",children:"Bouton secondaire"}),e.jsx("button",{className:"btn btn-ghost",children:"Bouton ghost"})]}),e.jsx("div",{children:e.jsx("input",{type:"text",placeholder:"Champ de saisie exemple...",className:"input w-full"})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-600)] flex items-center justify-center text-white font-bold",style:{borderRadius:"var(--radius-button)"},children:"A"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[var(--text-primary)]",children:["Exemple de card (",ut[o.itemPaletteKey]?.name,")"]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:"Cette card utilise la palette sélectionnée"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 1"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 2"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]})]})]})})]})]})}function Li({title:t,description:s,icon:r,showBackButton:a=!0,backUrl:o,children:c}){const{t:i}=ne.useTranslation("common"),d=w.useNavigate(),u=()=>{d(o||-1)};return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:e.jsxs("div",{className:"max-w-md w-full text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 flex items-center justify-center",children:r||e.jsx(l.Construction,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-[var(--text-primary)] mb-3",children:t||i("underDevelopment.title","En cours de développement")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:s||i("underDevelopment.description","Cette fonctionnalité est actuellement en cours de développement et sera disponible prochainement.")}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("underDevelopment.workInProgress","Travail en cours")})]}),c,a&&e.jsxs("button",{onClick:u,className:"btn btn-secondary inline-flex items-center gap-2",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("common.back","Retour")]})]})})}function $i({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}const Di=[{path:"/administration",icon:l.LayoutDashboard,labelKey:"sidebar.dashboard",exact:!0},{path:"/administration/users",icon:l.Users,labelKey:"sidebar.users"},{path:"/administration/roles",icon:l.Key,labelKey:"sidebar.roles"}];function Mi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),[u,m]=n.useState(!1);n.useEffect(()=>{i&&(queueMicrotask(()=>{m(!1)}),d())},[i,d]);const p=(f,b)=>b?a.pathname===f:a.pathname.startsWith(f),g=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[u?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),!u&&e.jsx("div",{className:"space-y-0.5",children:o.map(f=>{const b=a.pathname===f.route;return e.jsxs(w.Link,{to:f.route,onClick:s,className:`flex items-center gap-3 px-3 py-2 transition-colors ${b?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:`${f.label} (${f.applicationLabel})`,children:[e.jsx($i,{name:f.icon,className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.label})]},f.id)})}),e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),Di.map(f=>{const b=f.icon,h=p(f.path,f.exact);return e.jsxs(w.Link,{to:f.path,onClick:s,className:`flex items-center gap-3 px-3 py-2.5 transition-colors ${h?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(b,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:r(f.labelKey)})]},f.path)})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden lg:block w-64 h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)]",children:g}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:g})]})]})}function Gs({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Oi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),{isCollapsed:u,toggleCollapsed:m}=Ut(),{getApplicationsByZone:p}=Ce(),[g,f]=n.useState(!1),y=p("personal").find(v=>v.code==="myspace"||v.code==="core_myspace")?.modules||[];n.useEffect(()=>{i&&(queueMicrotask(()=>{f(!1)}),d())},[i,d]);const x=(v,S)=>S?a.pathname===v:a.pathname.startsWith(v),j=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto space-y-1 ${u?"p-2":"p-4"}`,children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[!u&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>f(!g),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[g?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(u||!g)&&e.jsx("div",{className:"space-y-0.5",children:o.map(v=>{const S=a.pathname===v.route;return e.jsxs(w.Link,{to:v.route,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${S?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?`${v.label} (${v.applicationLabel})`:void 0,children:[e.jsx(Gs,{name:v.icon,className:"w-4 h-4 flex-shrink-0"}),!u&&e.jsx("span",{className:"text-sm font-medium truncate",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})}),!u&&e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),e.jsxs(w.Link,{to:"/myspace",onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${x("/myspace",!0)?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.dashboard"):void 0,children:[e.jsx(l.LayoutDashboard,{className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:r("sidebar.dashboard")}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("sidebar.dashboard")})})]}),y.map(v=>{const S=v.route||`/myspace/${v.code}`,N=x(S);return e.jsxs(w.Link,{to:S,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${N?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?v.label:void 0,children:[e.jsx(Gs,{name:v.icon||"Star",className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})]}),e.jsx("div",{className:`border-t border-[var(--border-color)] ${u?"p-2":"p-3"}`,children:e.jsx("button",{onClick:m,className:`hidden lg:flex w-full items-center transition-all text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] ${u?"justify-center px-2 py-2":"gap-2 px-3 py-2"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:u?e.jsx(l.PanelLeft,{className:"w-5 h-5"}):e.jsxs(e.Fragment,{children:[e.jsx(l.PanelLeftClose,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:r("sidebar.collapse","Réduire")})]})})})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:`hidden lg:block h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] transition-all duration-300 ${u?"w-16":"w-64"}`,children:j}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:j})]})]})}function Fi(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function _i(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const qi={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function Ui({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>_i()),i=Fi(t),d=qi[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:e.jsx("div",{className:"max-w-md w-full p-6 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-xl shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-14 h-14 rounded-full ${d.bgColor} flex items-center justify-center mb-4`,children:e.jsx(u,{className:`w-7 h-7 ${d.color}`})}),e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-4 px-2 py-1 bg-[var(--bg-tertiary)] rounded border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white text-sm font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]})]})]})})})}function zi(t,s){Te.logError(t,"RouteErrorBoundary",{componentStack:s.componentStack})}function Bi({children:t}){return e.jsx(pr.ErrorBoundary,{FallbackComponent:Ui,onError:zi,onReset:()=>{window.location.reload()},children:t})}function Gi({feature:t,children:s,fallback:r,minimal:a=!1}){const{t:o}=ne.useTranslation("admin"),{isFeatureEnabled:c,license:i,isLoading:d}=He();return d?e.jsx(e.Fragment,{children:s}):c(t)?e.jsx(e.Fragment,{children:s}):r?e.jsx(e.Fragment,{children:r}):a?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded text-sm",children:[e.jsx(l.Lock,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:o("license.featureLocked","Locked")})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:o("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:o("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:o("license.currentEdition","Current: {{edition}}",{edition:i?.edition||"Unknown"})})]})]})}function wa({open:t,onOpenChange:s}){const{t:r}=ne.useTranslation("admin"),{activateLicense:a,license:o}=He(),{refreshMenu:c}=Ce(),[i,d]=n.useState(""),[u,m]=n.useState(""),[p,g]=n.useState(!1),[f,b]=n.useState(!1),[h,y]=n.useState(null),[x,j]=n.useState(!1),v=o?.hasApiKey??!1,S=async()=>{if(!i.trim()){y(r("license.errors.keyRequired","License key is required"));return}b(!0),y(null),j(!1);const I=await a(i.trim(),u.trim()||void 0);b(!1),I.success?(j(!0),await c(),setTimeout(()=>{d(""),m(""),g(!1),j(!1),s(!1)},1500)):y(I.error||r("license.errors.activationFailed","Activation failed"))},N=()=>{f||(d(""),m(""),g(!1),y(null),j(!1),s(!1))};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:N,"aria-label":"Close dialog"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(l.Key,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("license.activateTitle","Activate License")})]}),e.jsx("button",{onClick:N,disabled:f,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50",children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("license.activateDescription","Enter your license key to activate the product. The key is a JWT token provided by AtlasHub.")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.keyLabel","License Key")}),e.jsx("textarea",{value:i,onChange:I=>{d(I.target.value),y(null)},placeholder:r("license.keyPlaceholder","eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."),rows:6,disabled:f||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-xs bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed resize-none"})]}),v&&!p?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-green-700 dark:text-green-300 flex-1",children:r("license.apiKeyConfigured","API key is already configured")}),e.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:r("license.apiKeyChange","Change")})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.apiKeyLabel","API Key")}),e.jsx("input",{type:"text",value:u,onChange:I=>{m(I.target.value),y(null)},placeholder:r("license.apiKeyPlaceholder","sslk_..."),disabled:f||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-sm bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("license.apiKeyDescription","API key provided by AtlasHub for server authentication (sslk_...).")})]}),h&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:h})]}),x&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-300",children:r("license.activationSuccess","License activated successfully!")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r("license.activationHelp","Need a license key? Contact us at")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"support@atlashub.ch"})," ",r("license.activationHelpOr","or visit")," ",e.jsx("a",{href:"https://www.atlashub.ch",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"www.atlashub.ch"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e.jsx("button",{onClick:N,disabled:f,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("common:cancel","Cancel")}),e.jsxs("button",{onClick:S,disabled:f||x||!i.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:[f&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),x&&e.jsx(l.CheckCircle,{className:"w-4 h-4"}),f?r("license.activating","Activating..."):x?r("license.activated","Activated!"):r("license.activate","Activate")]})]})]})]}):null}function Ki({showDetails:t=!1}){const{t:s}=ne.useTranslation("admin"),{license:r,isLoading:a}=He();if(a||!r)return null;const{status:o,edition:c,isInTrial:i,trialDaysRemaining:d,isReadOnlyMode:u,daysUntilExpiration:m}=r;if(u)return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.readOnlyMode","Read-only mode")})]});if(i){const p=d<=7?"text-amber-800 dark:text-amber-200 bg-amber-100 dark:bg-amber-900/30":"text-blue-800 dark:text-blue-200 bg-blue-100 dark:bg-blue-900/30";return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium ${p}`,children:[e.jsx(l.Clock,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.trialDaysRemaining","{{days}} trial days left",{days:d})})]})}return m<=30&&o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-full text-sm font-medium",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.expiresIn","Expires in {{days}} days",{days:m})})]}):o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 rounded-full text-sm font-medium",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.edition.${c.toLowerCase()}`,{defaultValue:c})}),t&&e.jsxs("span",{className:"text-xs opacity-75",children:["(",m," ",s("license.daysLeft","days left"),")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.Shield,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.status.${o.toLowerCase()}`,{defaultValue:o})})]})}function ls({reason:t,tenantName:s,permissionPath:r,applicationsUrl:a,userRoles:o,userPermissions:c}){const{t:i}=ne.useTranslation("common"),{menu:d}=Ce(),u=w.useLocation(),m=()=>{window.history.length>2?window.history.back():window.location.href="/"},p=r?.split(".")[0],g=n.useMemo(()=>c?.filter(v=>{if(v==="*")return!0;const S=v.toLowerCase();return p&&(S.startsWith(p.toLowerCase()+".")||S===p.toLowerCase())})??[],[c,p]),f=r&&(o?.length||c),b=n.useMemo(()=>{const v=u.pathname.split("/").filter(Boolean),S=v[0]==="t"?v.slice(2):v,N=S[0],I=S[1],P=S[2],k=S[3],A=T=>/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(T),R=T=>T.replace(/^(core_|ext_)/,""),$=T=>T.charAt(0).toUpperCase()+T.slice(1).replace(/-/g," "),q=d?.applications.find(T=>T.route?.split("/").filter(Boolean)[0]===N||R(T.code)===N),C=I?q?.modules.find(T=>T.route?.split("/").filter(Boolean)[1]===I||R(T.code)===I):void 0,D=P&&!A(P)?C?.sections.find(T=>T.route?.split("/").filter(Boolean)[2]===P||R(T.code)===P):void 0,Y=k&&!A(k)?D?.resources.find(T=>T.route?.split("/").filter(Boolean)[3]===k||R(T.code)===k):void 0;return{application:q?.label||(N?$(N):void 0),module:C?.label||(I&&!A(I)?$(I):void 0),section:D?.label||(P&&!A(P)?$(P):void 0),resource:Y?.label||(k&&!A(k)?$(k):void 0)}},[d,u.pathname]),h=n.useMemo(()=>{const v=[];return b.application&&v.push(`- ${i("errors.accessDenied.ticket.applicationLabel")}: ${b.application}`),b.module&&v.push(`- ${i("errors.accessDenied.ticket.moduleLabel")}: ${b.module}`),b.section&&v.push(`- ${i("errors.accessDenied.ticket.sectionLabel")}: ${b.section}`),b.resource&&v.push(`- ${i("errors.accessDenied.ticket.resourceLabel")}: ${b.resource}`),v.length===0?"":`
25
+ `,children:[!b&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(l.GripVertical,{className:"w-4 h-4 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`p-3 ${b?"":"pl-6"}`,children:c(B,Z)}),(fe?.length??0)>0&&e.jsxs("div",{className:"absolute top-2 right-2",children:[e.jsx("button",{onClick:z=>{z.stopPropagation(),S(v===H?null:H)},className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-tertiary)]","aria-label":"Actions",children:e.jsx(l.MoreHorizontal,{className:"w-4 h-4"})}),v===H&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"fixed inset-0 z-40",onClick:()=>S(null),"aria-label":"Close menu"}),e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg shadow-lg py-1 min-w-[150px]",children:fe?.map((z,Q)=>I(z,Q))})]})]})]},H)}),Y&&D.length>0&&e.jsx("div",{className:"h-16 border-2 border-dashed border-[var(--color-primary-500)] rounded-lg bg-[var(--accent-bg)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm text-[var(--color-primary-500)]",children:"Déposer ici"})})]})]},C.id)})})}function Ti({title:t,subtitle:s,icon:r,actions:a}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r,t]}),s&&e.jsx("p",{className:"text-[var(--text-secondary)]",children:s})]}),a&&e.jsx("div",{className:"flex items-center gap-3",children:a})]})}const Qt={granted:{icon:l.Check,color:"var(--success-text)",bg:"var(--success-bg)",label:"Accordé"},denied:{icon:l.X,color:"var(--error-text)",bg:"var(--error-bg)",label:"Refusé"},partial:{icon:l.Minus,color:"var(--warning-text)",bg:"var(--warning-bg)",label:"Partiel"},inherited:{icon:l.Check,color:"var(--info-text)",bg:"var(--info-bg)",label:"Hérité"},none:{icon:l.Minus,color:"var(--text-tertiary)",bg:"transparent",label:"Non défini"}};function Ri({rows:t,columns:s,getRowId:r,getRowLabel:a,getRowGroup:o,getRowSubGroup:c,getRowIcon:i,isRowLocked:d,getRowChildCount:u,getColumnId:m,getColumnLabel:p,getColumnShortLabel:x,isColumnLocked:f,getColumnColor:b,getCellState:g,onCellClick:y,loading:h=!1,showLegend:j=!0,searchable:v=!1,rowColumnWidth:S="250px",cellWidth:N="44px",className:I="",emptyMessage:P="Aucune donnée",canEditLocked:k=!1}){const[A,R]=n.useState(new Set),[$,U]=n.useState(""),C=n.useMemo(()=>{const z=new Map;return t.forEach(Q=>{const M=o?.(Q)||"_default",re=c?.(Q);z.has(M)||z.set(M,{rows:[],subGroups:new Map});const F=z.get(M);re?(F.subGroups.has(re)||F.subGroups.set(re,[]),F.subGroups.get(re).push(Q)):F.rows.push(Q)}),z},[t,o,c]),D=n.useCallback((z,Q)=>{const M=new Map;return z.forEach((re,F)=>{const K=re.filter(V=>a(V).toLowerCase().includes(Q));K.length>0&&M.set(F,K)}),M},[a]),Y=n.useMemo(()=>{if(!$)return C;const z=$.toLowerCase(),Q=new Map;return C.forEach((M,re)=>{const F=M.rows.filter(V=>a(V).toLowerCase().includes(z)),K=D(M.subGroups,z);(F.length>0||K.size>0)&&Q.set(re,{rows:F,subGroups:K})}),Q},[C,$,a,D]),T=z=>{R(Q=>{const M=new Set(Q);return M.has(z)?M.delete(z):M.add(z),M})},B=n.useCallback((z,Q,M,re)=>{y&&(M&&!k||re&&!k||y(z,Q))},[y,k]),Z=n.useCallback((z,Q)=>!(!y||z&&!k||Q&&!k),[y,k]),H=(z,Q)=>`w-full h-full min-h-[32px] flex items-center justify-center rounded transition-colors ${z?"hover:opacity-80 cursor-pointer":"cursor-default"} ${Q!=="none"?"":"opacity-30"}`,J=n.useCallback((z,Q,M,re,F,K,V,ae)=>{const ue=re.icon,G=Z(F,K);return e.jsx("td",{className:"px-0 py-1 text-center",style:{width:N},children:e.jsx("button",{type:"button",onClick:()=>B(z,Q,F,K),disabled:!G,className:H(G,M),style:{backgroundColor:re.bg},title:`${a(V)} × ${p(ae)}: ${re.label}`,children:M!=="none"&&e.jsx(ue,{className:"w-4 h-4",style:{color:re.color}})})},`${z}-${Q}`)},[y,k,B,N,a,p,Z,H]),fe=n.useCallback((z,Q,M,re,F)=>{const K=r(z),V=d?.(z)||!1,ae=i?.(z),ue=Q%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",G=Q%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${G}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 pl-12 ${ue}`,style:{width:re},children:e.jsxs("div",{className:"flex items-center gap-2",children:[ae,V&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:a(z)})]})}),M.map(ce=>{const de=m(ce),he=f?.(ce)||!1,pe=F(K,de),ye=Qt[pe];return J(K,de,pe,ye,V,he,z,ce)})]},K)},[r,d,i,a,m,f,J]);return h?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):t.length===0||s.length===0?e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:P}):e.jsxs("div",{className:`space-y-4 ${I}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[v&&e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",value:$,onChange:z=>U(z.target.value),placeholder:"Rechercher...",className:"input pl-10 w-full"})]}),j&&e.jsx("div",{className:"flex items-center gap-4 text-xs",children:Object.entries(Qt).map(([z,Q])=>{if(z==="none")return null;const M=Q.icon;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center",style:{backgroundColor:Q.bg},children:e.jsx(M,{className:"w-3 h-3",style:{color:Q.color}})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:Q.label})]},z)})})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-[var(--bg-secondary)] px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider border-b border-[var(--border-color)]",style:{width:S,minWidth:S,height:"120px",verticalAlign:"bottom",paddingBottom:"12px"},children:"Ressource"}),s.map(z=>{const Q=m(z),M=x?.(z)||p(z),re=f?.(z),F=b?.(z);return e.jsx("th",{className:"relative overflow-visible border-b border-[var(--border-color)]",style:{width:N,minWidth:N,maxWidth:N,height:"120px",padding:0,verticalAlign:"bottom"},children:e.jsx("div",{className:"absolute bottom-2 left-1/2",style:{transform:"translateX(-6px) rotate(-55deg)",transformOrigin:"bottom left",width:"100px"},children:e.jsxs("div",{className:"flex items-center gap-1",children:[re&&e.jsx(l.Lock,{className:"w-3 h-3 flex-shrink-0 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] whitespace-nowrap",style:{color:F},title:p(z),children:M})]})})},Q)})]})}),e.jsx("tbody",{children:Array.from(Y.entries()).map(([z,Q])=>{const M=A.has(z),re=z==="_default",F=Q.rows.length+Array.from(Q.subGroups.values()).reduce((K,V)=>K+V.length,0);return e.jsxs("tbody",{children:[!re&&e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-2 bg-[var(--color-accent-900)]/30",style:{width:S},children:e.jsxs("button",{onClick:()=>T(z),className:"flex items-center gap-2 w-full text-left hover:opacity-80",children:[M?e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--color-accent-400)]"}):e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase",children:z}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)]",children:["(",F,")"]})]})}),e.jsx("td",{colSpan:s.length})]}),!M&&e.jsxs(e.Fragment,{children:[Q.rows.map((K,V)=>{const ae=r(K),ue=d?.(K)||!1,G=i?.(K),ce=u?.(K),de=V%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",he=V%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${he}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 ${de}`,style:{width:S},children:e.jsxs("div",{className:"flex items-center gap-2",children:[G,ue&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:a(K)}),ce!==void 0&&e.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",ce,")"]})]})}),s.map(pe=>{const ye=m(pe),Ue=f?.(pe)||!1,qe=g(ae,ye),Ve=Qt[qe];return J(ae,ye,qe,Ve,ue,Ue,K,pe)})]},ae)}),Array.from(Q.subGroups.entries()).map(([K,V])=>e.jsxs("tbody",{children:[e.jsxs("tr",{className:"bg-[var(--bg-tertiary)]",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-1 pl-8 bg-[var(--bg-tertiary)]",style:{width:S},children:e.jsxs("span",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase",children:[K," (",V.length,")"]})}),e.jsx("td",{colSpan:s.length})]}),V.map((ae,ue)=>fe(ae,ue,s,S,g))]},K))]})]},z)})})]})})]})}const Ei=[{size:"none",icon:"square"},{size:"small",icon:"rounded"},{size:"medium",icon:"rounded"},{size:"large",icon:"rounded"},{size:"xlarge",icon:"rounded"},{size:"xxlarge",icon:"rounded"}];function it({label:t,element:s,value:r,onChange:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ei.map(({size:o})=>e.jsx("button",{onClick:()=>a(s,o),className:`px-3 py-2 text-xs font-medium transition-all ${r===o?"bg-[var(--color-accent-500)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,style:{borderRadius:Qe[o]},children:tn[o]},o))})]})}const Ii=({selectedThemeTenant:t,setSelectedThemeTenant:s,currentTenant:r,t:a})=>e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:a("theme.scope.title","Portée du thème")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("theme.scope.description","Choisissez si ce thème s'applique à tous vos espaces ou uniquement à l'espace actuel")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>s(null),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===null?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Globe,{className:`w-5 h-5 ${t===null?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===null?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:a("theme.scope.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.globalDesc","Tous les espaces")})]}),t===null&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]}),e.jsxs("button",{type:"button",onClick:()=>s(r.id),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===r.id?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Building2,{className:`w-5 h-5 ${t===r.id?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===r.id?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:r.name}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.tenantDesc","Espace actuel uniquement")})]}),t===r.id&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]})]})]});function Li({onSync:t,isSyncing:s=!1,syncSuccess:r=!1}){const{t:a}=ne.useTranslation("preferences"),{config:o,mode:c,setMode:i,setBorderRadius:d,setAccentColor:u,setItemPalette:m,applyPreset:p,resetToDefault:x,selectedThemeTenant:f,setSelectedThemeTenant:b}=wt(),{currentTenant:g,hasMultipleTenants:y}=Ee(),h=y&&g;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)]",children:"Personnalisation"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Personnalisez l'apparence de l'interface"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs("button",{type:"button",onClick:t,disabled:s,className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{borderRadius:"var(--radius-button)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Sync..."]}),!s&&r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Check,{className:"w-4 h-4"}),"Synchronisé"]}),!s&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),"Synchroniser"]})]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(l.RotateCcw,{className:"w-4 h-4"}),"Réinitialiser"]})]})]}),h&&e.jsx(Ii,{selectedThemeTenant:f,setSelectedThemeTenant:b,currentTenant:g,t:a}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Thèmes prédéfinis"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:rn.map(j=>{const v=o.accentColorKey===j.config.accentColorKey&&JSON.stringify(o.borderRadius)===JSON.stringify(j.config.borderRadius);return e.jsxs("button",{onClick:()=>p(j.config),className:`p-4 text-left transition-all border ${v?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:j.icon}),v&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)]",children:j.name}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:j.description})]},j.id)})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Mode d'affichage"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>i("light"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="light"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Sun,{className:`w-5 h-5 ${c==="light"?"text-amber-500":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="light"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Clair"})]}),e.jsxs("button",{onClick:()=>i("dark"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="dark"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Moon,{className:`w-5 h-5 ${c==="dark"?"text-[var(--color-accent-400)]":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="dark"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Sombre"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Palette,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Couleur d'accent"})]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Object.entries(_e).map(([j,{name:v,shades:S}])=>e.jsx("button",{onClick:()=>u(j),className:`relative w-10 h-10 transition-all ${o.accentColorKey===j?"ring-2 ring-offset-2 ring-[var(--border-strong)]":""}`,style:{backgroundColor:S[500],borderRadius:"var(--radius-button)"},title:v,children:o.accentColorKey===j&&e.jsx(l.Check,{className:"absolute inset-0 m-auto w-5 h-5 text-white"})},j))}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Couleur actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:_e[o.accentColorKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Layers,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Palette des éléments"})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Choisissez une palette de couleurs pour les cards et éléments de l'interface"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:Object.entries(ut).map(([j,v])=>{const S=c==="dark"?v.colors.dark:v.colors.light,N=o.itemPaletteKey===j;return e.jsxs("button",{onClick:()=>m(j),className:`p-4 text-left transition-all border ${N?"border-[var(--color-accent-500)] ring-2 ring-[var(--color-accent-500)] ring-opacity-30":"border-[var(--border-color)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xl",children:v.icon}),N&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex h-8 mb-3 rounded overflow-hidden border",style:{borderColor:S.dark},children:[e.jsx("div",{className:"flex-1",style:{backgroundColor:S.light}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.medium}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.dark}})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)] text-sm",children:v.name})]},j)})}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Palette actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:ut[o.itemPaletteKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Square,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Style des coins"})]}),e.jsxs("div",{className:"space-y-4 p-4 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:[e.jsx(it,{label:"Cards & Containers",element:"card",value:o.borderRadius.card,onChange:d}),e.jsx(it,{label:"Boutons",element:"button",value:o.borderRadius.button,onChange:d}),e.jsx(it,{label:"Badges",element:"badge",value:o.borderRadius.badge,onChange:d}),e.jsx(it,{label:"Champs de saisie",element:"input",value:o.borderRadius.input,onChange:d}),e.jsx(it,{label:"Modales",element:"modal",value:o.borderRadius.modal,onChange:d}),e.jsx(it,{label:"Éléments de menu",element:"menuItem",value:o.borderRadius.menuItem,onChange:d})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Circle,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Aperçu"})]}),e.jsx("div",{className:"p-6 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"badge-success px-3 py-1 text-xs font-medium",children:"Succès"}),e.jsx("span",{className:"badge-warning px-3 py-1 text-xs font-medium",children:"Attention"}),e.jsx("span",{className:"badge-error px-3 py-1 text-xs font-medium",children:"Erreur"}),e.jsx("span",{className:"badge-info px-3 py-1 text-xs font-medium",children:"Info"}),e.jsx("span",{className:"badge-accent px-3 py-1 text-xs font-medium",children:"Accent"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{className:"btn btn-primary",children:"Bouton primaire"}),e.jsx("button",{className:"btn btn-secondary",children:"Bouton secondaire"}),e.jsx("button",{className:"btn btn-ghost",children:"Bouton ghost"})]}),e.jsx("div",{children:e.jsx("input",{type:"text",placeholder:"Champ de saisie exemple...",className:"input w-full"})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-600)] flex items-center justify-center text-white font-bold",style:{borderRadius:"var(--radius-button)"},children:"A"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[var(--text-primary)]",children:["Exemple de card (",ut[o.itemPaletteKey]?.name,")"]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:"Cette card utilise la palette sélectionnée"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 1"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 2"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]})]})]})})]})]})}function $i({title:t,description:s,icon:r,showBackButton:a=!0,backUrl:o,children:c}){const{t:i}=ne.useTranslation("common"),d=w.useNavigate(),u=()=>{d(o||-1)};return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:e.jsxs("div",{className:"max-w-md w-full text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 flex items-center justify-center",children:r||e.jsx(l.Construction,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-[var(--text-primary)] mb-3",children:t||i("underDevelopment.title","En cours de développement")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:s||i("underDevelopment.description","Cette fonctionnalité est actuellement en cours de développement et sera disponible prochainement.")}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("underDevelopment.workInProgress","Travail en cours")})]}),c,a&&e.jsxs("button",{onClick:u,className:"btn btn-secondary inline-flex items-center gap-2",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("common.back","Retour")]})]})})}function Di({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}const Mi=[{path:"/administration",icon:l.LayoutDashboard,labelKey:"sidebar.dashboard",exact:!0},{path:"/administration/users",icon:l.Users,labelKey:"sidebar.users"},{path:"/administration/roles",icon:l.Key,labelKey:"sidebar.roles"}];function Oi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),[u,m]=n.useState(!1);n.useEffect(()=>{i&&(queueMicrotask(()=>{m(!1)}),d())},[i,d]);const p=(f,b)=>b?a.pathname===f:a.pathname.startsWith(f),x=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[u?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),!u&&e.jsx("div",{className:"space-y-0.5",children:o.map(f=>{const b=a.pathname===f.route;return e.jsxs(w.Link,{to:f.route,onClick:s,className:`flex items-center gap-3 px-3 py-2 transition-colors ${b?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:`${f.label} (${f.applicationLabel})`,children:[e.jsx(Di,{name:f.icon,className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.label})]},f.id)})}),e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),Mi.map(f=>{const b=f.icon,g=p(f.path,f.exact);return e.jsxs(w.Link,{to:f.path,onClick:s,className:`flex items-center gap-3 px-3 py-2.5 transition-colors ${g?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(b,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:r(f.labelKey)})]},f.path)})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden lg:block w-64 h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)]",children:x}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:x})]})]})}function Ks({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Fi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),{isCollapsed:u,toggleCollapsed:m}=qt(),{getApplicationsByZone:p}=Ce(),[x,f]=n.useState(!1),y=p("personal").find(v=>v.code==="myspace"||v.code==="core_myspace")?.modules||[];n.useEffect(()=>{i&&(queueMicrotask(()=>{f(!1)}),d())},[i,d]);const h=(v,S)=>S?a.pathname===v:a.pathname.startsWith(v),j=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto space-y-1 ${u?"p-2":"p-4"}`,children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[!u&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>f(!x),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[x?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(u||!x)&&e.jsx("div",{className:"space-y-0.5",children:o.map(v=>{const S=a.pathname===v.route;return e.jsxs(w.Link,{to:v.route,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${S?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?`${v.label} (${v.applicationLabel})`:void 0,children:[e.jsx(Ks,{name:v.icon,className:"w-4 h-4 flex-shrink-0"}),!u&&e.jsx("span",{className:"text-sm font-medium truncate",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})}),!u&&e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),e.jsxs(w.Link,{to:"/myspace",onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${h("/myspace",!0)?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.dashboard"):void 0,children:[e.jsx(l.LayoutDashboard,{className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:r("sidebar.dashboard")}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("sidebar.dashboard")})})]}),y.map(v=>{const S=v.route||`/myspace/${v.code}`,N=h(S);return e.jsxs(w.Link,{to:S,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${N?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?v.label:void 0,children:[e.jsx(Ks,{name:v.icon||"Star",className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})]}),e.jsx("div",{className:`border-t border-[var(--border-color)] ${u?"p-2":"p-3"}`,children:e.jsx("button",{onClick:m,className:`hidden lg:flex w-full items-center transition-all text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] ${u?"justify-center px-2 py-2":"gap-2 px-3 py-2"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:u?e.jsx(l.PanelLeft,{className:"w-5 h-5"}):e.jsxs(e.Fragment,{children:[e.jsx(l.PanelLeftClose,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:r("sidebar.collapse","Réduire")})]})})})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:`hidden lg:block h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] transition-all duration-300 ${u?"w-16":"w-64"}`,children:j}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:j})]})]})}function _i(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Ui(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const qi={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function Bi({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Ui()),i=_i(t),d=qi[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:e.jsx("div",{className:"max-w-md w-full p-6 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-xl shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-14 h-14 rounded-full ${d.bgColor} flex items-center justify-center mb-4`,children:e.jsx(u,{className:`w-7 h-7 ${d.color}`})}),e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-4 px-2 py-1 bg-[var(--bg-tertiary)] rounded border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white text-sm font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]})]})]})})})}function zi(t,s){Te.logError(t,"RouteErrorBoundary",{componentStack:s.componentStack})}function Gi({children:t}){return e.jsx(xr.ErrorBoundary,{FallbackComponent:Bi,onError:zi,onReset:()=>{window.location.reload()},children:t})}function Ki({feature:t,children:s,fallback:r,minimal:a=!1}){const{t:o}=ne.useTranslation("admin"),{isFeatureEnabled:c,license:i,isLoading:d}=He();return d?e.jsx(e.Fragment,{children:s}):c(t)?e.jsx(e.Fragment,{children:s}):r?e.jsx(e.Fragment,{children:r}):a?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded text-sm",children:[e.jsx(l.Lock,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:o("license.featureLocked","Locked")})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:o("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:o("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:o("license.currentEdition","Current: {{edition}}",{edition:i?.edition||"Unknown"})})]})]})}function Ca({open:t,onOpenChange:s}){const{t:r}=ne.useTranslation("admin"),{activateLicense:a,license:o}=He(),{refreshMenu:c}=Ce(),[i,d]=n.useState(""),[u,m]=n.useState(""),[p,x]=n.useState(!1),[f,b]=n.useState(!1),[g,y]=n.useState(null),[h,j]=n.useState(!1),v=o?.hasApiKey??!1,S=async()=>{if(!i.trim()){y(r("license.errors.keyRequired","License key is required"));return}b(!0),y(null),j(!1);const I=await a(i.trim(),u.trim()||void 0);b(!1),I.success?(j(!0),await c(),setTimeout(()=>{d(""),m(""),x(!1),j(!1),s(!1)},1500)):y(I.error||r("license.errors.activationFailed","Activation failed"))},N=()=>{f||(d(""),m(""),x(!1),y(null),j(!1),s(!1))};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:N,"aria-label":"Close dialog"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(l.Key,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("license.activateTitle","Activate License")})]}),e.jsx("button",{onClick:N,disabled:f,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50",children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("license.activateDescription","Enter your license key to activate the product. The key is a JWT token provided by AtlasHub.")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.keyLabel","License Key")}),e.jsx("textarea",{value:i,onChange:I=>{d(I.target.value),y(null)},placeholder:r("license.keyPlaceholder","eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."),rows:6,disabled:f||h,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-xs bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed resize-none"})]}),v&&!p?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-green-700 dark:text-green-300 flex-1",children:r("license.apiKeyConfigured","API key is already configured")}),e.jsx("button",{type:"button",onClick:()=>x(!0),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:r("license.apiKeyChange","Change")})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.apiKeyLabel","API Key")}),e.jsx("input",{type:"text",value:u,onChange:I=>{m(I.target.value),y(null)},placeholder:r("license.apiKeyPlaceholder","sslk_..."),disabled:f||h,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-sm bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("license.apiKeyDescription","API key provided by AtlasHub for server authentication (sslk_...).")})]}),g&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:g})]}),h&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-300",children:r("license.activationSuccess","License activated successfully!")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r("license.activationHelp","Need a license key? Contact us at")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"support@atlashub.ch"})," ",r("license.activationHelpOr","or visit")," ",e.jsx("a",{href:"https://www.atlashub.ch",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"www.atlashub.ch"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e.jsx("button",{onClick:N,disabled:f,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("common:cancel","Cancel")}),e.jsxs("button",{onClick:S,disabled:f||h||!i.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:[f&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),h&&e.jsx(l.CheckCircle,{className:"w-4 h-4"}),f?r("license.activating","Activating..."):h?r("license.activated","Activated!"):r("license.activate","Activate")]})]})]})]}):null}function Hi({showDetails:t=!1}){const{t:s}=ne.useTranslation("admin"),{license:r,isLoading:a}=He();if(a||!r)return null;const{status:o,edition:c,isInTrial:i,trialDaysRemaining:d,isReadOnlyMode:u,daysUntilExpiration:m}=r;if(u)return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.readOnlyMode","Read-only mode")})]});if(i){const p=d<=7?"text-amber-800 dark:text-amber-200 bg-amber-100 dark:bg-amber-900/30":"text-blue-800 dark:text-blue-200 bg-blue-100 dark:bg-blue-900/30";return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium ${p}`,children:[e.jsx(l.Clock,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.trialDaysRemaining","{{days}} trial days left",{days:d})})]})}return m<=30&&o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-full text-sm font-medium",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.expiresIn","Expires in {{days}} days",{days:m})})]}):o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 rounded-full text-sm font-medium",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.edition.${c.toLowerCase()}`,{defaultValue:c})}),t&&e.jsxs("span",{className:"text-xs opacity-75",children:["(",m," ",s("license.daysLeft","days left"),")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.Shield,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.status.${o.toLowerCase()}`,{defaultValue:o})})]})}function ls({reason:t,tenantName:s,permissionPath:r,applicationsUrl:a,userRoles:o,userPermissions:c}){const{t:i}=ne.useTranslation("common"),{menu:d}=Ce(),u=w.useLocation(),m=()=>{window.history.length>2?window.history.back():window.location.href="/"},p=r?.split(".")[0],x=n.useMemo(()=>c?.filter(v=>{if(v==="*")return!0;const S=v.toLowerCase();return p&&(S.startsWith(p.toLowerCase()+".")||S===p.toLowerCase())})??[],[c,p]),f=r&&(o?.length||c),b=n.useMemo(()=>{const v=u.pathname.split("/").filter(Boolean),S=v[0]==="t"?v.slice(2):v,N=S[0],I=S[1],P=S[2],k=S[3],A=T=>/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(T),R=T=>T.replace(/^(core_|ext_)/,""),$=T=>T.charAt(0).toUpperCase()+T.slice(1).replace(/-/g," "),U=d?.applications.find(T=>T.route?.split("/").filter(Boolean)[0]===N||R(T.code)===N),C=I?U?.modules.find(T=>T.route?.split("/").filter(Boolean)[1]===I||R(T.code)===I):void 0,D=P&&!A(P)?C?.sections.find(T=>T.route?.split("/").filter(Boolean)[2]===P||R(T.code)===P):void 0,Y=k&&!A(k)?D?.resources.find(T=>T.route?.split("/").filter(Boolean)[3]===k||R(T.code)===k):void 0;return{application:U?.label||(N?$(N):void 0),module:C?.label||(I&&!A(I)?$(I):void 0),section:D?.label||(P&&!A(P)?$(P):void 0),resource:Y?.label||(k&&!A(k)?$(k):void 0)}},[d,u.pathname]),g=n.useMemo(()=>{const v=[];return b.application&&v.push(`- ${i("errors.accessDenied.ticket.applicationLabel")}: ${b.application}`),b.module&&v.push(`- ${i("errors.accessDenied.ticket.moduleLabel")}: ${b.module}`),b.section&&v.push(`- ${i("errors.accessDenied.ticket.sectionLabel")}: ${b.section}`),b.resource&&v.push(`- ${i("errors.accessDenied.ticket.resourceLabel")}: ${b.resource}`),v.length===0?"":`
26
26
 
27
27
  ${i("errors.accessDenied.ticket.navigationContext")}:
28
28
  ${v.join(`
29
- `)}`},[b,i]),y=n.useMemo(()=>{if(!t||!r||!s||!a)return null;const S=`${a.replace(/\/applications$/,"")}/support/my-tickets/create`,N=t==="tenant"?"ApplicationRequest":"Support",I=r.split(".")[0],P=t==="tenant"?i("errors.accessDenied.ticket.accessSubject",{permissionPath:r,tenantName:s}):i("errors.accessDenied.ticket.permissionSubject",{permissionPath:r,tenantName:s}),A=(t==="tenant"?i("errors.accessDenied.ticket.accessBody",{appCode:I,tenantName:s,permissionPath:r}):i("errors.accessDenied.ticket.permissionBody",{permissionPath:r,tenantName:s}))+h,R=new URLSearchParams({type:N,subject:P,body:A});return`${S}?${R.toString()}`},[t,r,s,a,i,h]),j=t==="tenant"&&s?i("errors.accessDenied.tenantNotAvailable",{tenantName:s}):t==="permission"&&s?i("errors.accessDenied.permissionMissing",{tenantName:s}):s?i("errors.accessDenied.tenantDescription",{tenantName:s}):i("errors.accessDenied.description");return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6",children:e.jsx(l.ShieldX,{className:"w-8 h-8 text-red-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:i("errors.accessDenied.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:j}),f&&e.jsxs("div",{className:"w-full mb-6 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)] divide-y divide-[var(--border-color)]",children:[e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono font-medium text-red-500",children:r})]}),(o?.length??0)>0&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourRoles")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center",children:o?.map(v=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:v},v))})]}),c&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourPermissionsFor",{appCode:p??""})}),g.length>0?e.jsx("div",{className:"flex flex-col gap-1 items-start",children:g.map(v=>e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:v},v))}):e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] italic",children:i("errors.accessDenied.noPermissions")})]})]}),!f&&r&&e.jsxs("div",{className:"w-full mb-6 p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono text-[var(--text-primary)]",children:r})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[y&&e.jsxs("a",{href:y,className:"flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.TicketPlus,{className:"w-4 h-4"}),i(t==="tenant"?"errors.accessDenied.requestAccess":"errors.accessDenied.requestPermission")]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[a?e.jsxs("a",{href:a,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LayoutGrid,{className:"w-4 h-4"}),i("errors.accessDenied.goToApplications")]}):e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),i("errors.home")]})]})]})]})})})}function Hi(){const{t}=ne.useTranslation("common"),{logout:s}=Pe();return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-orange-500/10 flex items-center justify-center mb-6",children:e.jsx(l.Building2,{className:"w-8 h-8 text-orange-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.noActiveWorkspace.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.noActiveWorkspace.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("a",{href:"mailto:support@atlashub.ch",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.Mail,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.contactAdmin")]}),e.jsxs("button",{onClick:()=>{s()},className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.logout")]})]}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-6",children:t("errors.noActiveWorkspace.hint")})]})})})}function wt(){return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] w-full",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(l.Loader2,{className:"w-10 h-10 animate-spin text-[var(--color-primary-500)]"}),e.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:"Chargement..."})]})})}function Sa(){const{user:t,isLoading:s}=Pe(),r=w.useLocation(),{currentAppCode:a,currentModuleCode:o,isLoading:c,menu:i}=Ce(),{currentTenant:d,userTenants:u,isLoading:m,isGlobalView:p}=Ee(),g=d?.id||"global",f=n.useRef(null),b=(S,N)=>{const I=`${S}:${N}:${r.pathname}`;f.current!==I&&(f.current=I,E.post("/security/access-denied",{reason:S,permissionPath:N,attemptedPath:r.pathname}).catch(()=>{}))},h=n.useRef(d?.id);let y=!1;if(d?.id!==h.current&&(h.current=d?.id,y=!0),s)return e.jsx(wt,{});if(!t)return e.jsx(w.Navigate,{to:"/login",state:{from:r},replace:!0});if(y||c||m||!i)return e.jsx(wt,{});if(!d&&!p&&!u.some(N=>N.status==="Active"))return e.jsx(Hi,{});if(!a)return e.jsx(w.Outlet,{},g);if(Lr.includes(a))return e.jsx(w.Outlet,{},g);const j=(i?.applications||[]).find(S=>S.route?.split("/").filter(Boolean)[0]===a||S.code===a);if(j?.isOpen)return e.jsx(w.Outlet,{},g);if(!j){const S=[a,o].filter(Boolean).join("."),N=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("tenant",S),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"tenant",tenantName:d?.name,permissionPath:S,applicationsUrl:N,userRoles:t.roles,userPermissions:t.permissions})})})]})}const v=[a,o].filter(Boolean).join(".");if(!Nr(t.permissions,v)&&j.accessLevel!=="RequestAccess"){const S=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("permission",v),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"permission",tenantName:d?.name,permissionPath:v,applicationsUrl:S,userRoles:t.roles,userPermissions:t.permissions})})})]})}return e.jsx(w.Outlet,{},g)}function Ks(){const{slug:t}=w.useParams(),s=w.useNavigate(),r=w.useLocation(),{currentTenant:a,userTenants:o,switchTenant:c,isLoading:i,isGlobalView:d}=Ee(),{useUrlRouting:u,isLoading:m}=qt(),p=n.useRef(!1),g=n.useRef(null),f=n.useRef(null);return n.useEffect(()=>{if(i||m||!u||d)return;const b=t||Ms(r.pathname),h=b!==f.current;if(f.current=b,!!h&&b&&b!==a?.slug){const y=o.find(x=>x.slug===b&&x.status==="Active");if(y)g.current=b,c(y.id).then(()=>{g.current=null}).catch(x=>{g.current=null,console.error("[TenantRouteWrapper] Failed to switch tenant:",x)});else if(a){const x=dt(r.pathname);s(`/t/${a.slug}${x}`,{replace:!0})}else s("/",{replace:!0})}},[t,r.pathname,a?.slug,o,u,i,m,d,c,s]),n.useEffect(()=>{if(i||m||p.current)return;const b=r.pathname,h=Ms(b);if(d&&h){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(!u&&h){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&!h&&!d&&b!=="/"&&!b.startsWith("/login")&&!b.startsWith("/auth")&&!b.startsWith("/public")){p.current=!0,s(`/t/${a.slug}${b}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&h&&!d&&h!==a.slug&&h!==g.current){p.current=!0;const y=dt(b);s(`/t/${a.slug}${y}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}},[r.pathname,a?.slug,u,i,m,d,s]),e.jsx(w.Outlet,{})}function Oe({to:t,replace:s=!0}){const{slug:r}=w.useParams(),a=r?`/t/${r}${t}`:t;return e.jsx(w.Navigate,{to:a,replace:s})}function Vi(){const{t}=ne.useTranslation("admin"),{license:s}=He(),r=Ze();return!s||s.status==="NoLicense"?e.jsx(wa,{open:!0,onOpenChange:()=>{}}):e.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsx("div",{className:"flex justify-center pt-8 pb-4",children:e.jsx("div",{className:"p-4 bg-red-100 dark:bg-red-900/30 rounded-full",children:e.jsx(l.Lock,{className:"w-10 h-10 text-red-600 dark:text-red-400"})})}),e.jsxs("div",{className:"px-6 pb-6 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:t("license.guard.title","License Required")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:t("license.guard.description","Your license has expired or is invalid. Access to this area is restricted. Please activate a valid license to continue using the platform.")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(w.Link,{to:r("/administration/configuration/license"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(l.Settings,{className:"w-4 h-4"}),t("license.guard.manageLicense","Manage License")]}),e.jsxs(w.Link,{to:r("/myspace/profile"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(l.User,{className:"w-4 h-4"}),t("license.guard.myProfile","My Profile")]})]})]})]})]})}const Wi=["/myspace","/administration/configuration"];function Xi(t){const s=/^\/t\/[^/]+\/(.*)/.exec(t);return s?`/${s[1]}`:t}function Ca(){const{license:t,isLoading:s,isReadOnlyMode:r,isServerDowntimeBlocked:a}=He(),o=w.useLocation();if(s)return e.jsx(w.Outlet,{});const c=Xi(o.pathname);return Wi.some(d=>c.startsWith(d))?e.jsx(w.Outlet,{}):!t?.isValid||r||a?e.jsxs(e.Fragment,{children:[e.jsx(w.Outlet,{}),e.jsx(Vi,{})]}):e.jsx(w.Outlet,{})}function ws({feature:t}){const{t:s}=ne.useTranslation("admin"),{isFeatureEnabled:r,license:a,isLoading:o}=He();return o?e.jsx(w.Outlet,{}):r(t)?e.jsx(w.Outlet,{}):e.jsx("div",{className:"flex items-center justify-center min-h-[60vh] p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700 max-w-md",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:s("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:s("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.currentEdition","Current: {{edition}}",{edition:a?.edition||"Unknown"})})]})]})})}function Yi(){return sa(),null}function Ji(){return w.useInRouterContext()?e.jsx(Yi,{}):null}const vt="/api/administration/tenants/tenant-analytics",cs={getDashboardStats:async(t=30)=>await E.get(`${vt}/dashboard`,{params:{period:t}}),getTopTenants:async(t=10,s=30,r="access")=>await E.get(`${vt}/top-tenants`,{params:{limit:t,period:s,sortBy:r}}),getTrends:async(t=30)=>await E.get(`${vt}/trends`,{params:{period:t}}),trackStart:async t=>await E.post(`${vt}/track/start`,{tenantId:t}),trackEnd:async t=>{await E.post(`${vt}/track/end`,{accessId:t})}},Qi="/api/administration/tenants/tenant-analytics";function Zi(){const{currentTenant:t}=Ee(),{isAuthenticated:s}=Pe(),r=n.useRef(null),a=n.useRef(null),o=n.useRef(!1);n.useEffect(()=>{if(!s)return;const c=window.location.pathname;if(c.startsWith("/auth/")||c.startsWith("/login"))return;const i=t?.id??null;return i===a.current||o.current?void 0:(o.current=!0,(async()=>{if(r.current){try{await cs.trackEnd(r.current)}catch{}r.current=null}if(a.current=i,i)try{const u=await cs.trackStart(i);r.current=u.accessId}catch{r.current=null}o.current=!1})(),()=>{if(r.current){const u=localStorage.getItem("token");if(!u)return;fetch(`${Qi}/track/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({accessId:r.current}),keepalive:!0}).catch(()=>{}),r.current=null,a.current=null}})},[t?.id,s])}function el(){return Zi(),null}const Hs=n.lazy(()=>Promise.resolve().then(()=>xi).then(t=>({default:t.DocsLayout}))),tl=n.lazy(()=>Promise.resolve().then(()=>require("./DocsIndexPage-BPfi0FQD.js")).then(t=>({default:t.DocsIndexPage}))),sl=n.lazy(()=>Promise.resolve().then(()=>require("./SmartStackPresentationPage-52Nb7F0X.js")).then(t=>({default:t.SmartStackPresentationPage}))),rl=n.lazy(()=>Promise.resolve().then(()=>require("./DeveloperIndexPage-CtBfD2JI.js")).then(t=>({default:t.DeveloperIndexPage}))),al=n.lazy(()=>Promise.resolve().then(()=>require("./InfrastructurePage-D4ZjLzI_.js")).then(t=>({default:t.InfrastructurePage}))),nl=n.lazy(()=>Promise.resolve().then(()=>require("./InstallationPage-BJ-GBVPp.js")).then(t=>({default:t.InstallationPage}))),ol=n.lazy(()=>Promise.resolve().then(()=>require("./DatabasePage-DAzb3FnS.js")).then(t=>({default:t.DatabasePage}))),il=n.lazy(()=>Promise.resolve().then(()=>require("./DualDbContextPage-Dz8NAewk.js")).then(t=>({default:t.DualDbContextPage}))),ll=n.lazy(()=>Promise.resolve().then(()=>require("./CrossSchemaFkPage-DqFNORYd.js")).then(t=>({default:t.CrossSchemaFkPage}))),cl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantIndexPage}))),dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.MultiTenantModePage}))),ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantB2CPage}))),ml=n.lazy(()=>Promise.resolve().then(()=>require("./TeamsIntegrationPage-DXj5MDRS.js")).then(t=>({default:t.TeamsIntegrationPage}))),pl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CdORB0b4.js")).then(t=>({default:t.SecurityTestingPage}))),xl=n.lazy(()=>Promise.resolve().then(()=>require("./UserIndexPage-DahU6wzK.js")).then(t=>({default:t.UserIndexPage}))),hl=n.lazy(()=>Promise.resolve().then(()=>require("./ArchitecturePage-Cn_XCDAo.js")).then(t=>({default:t.ArchitecturePage}))),gl=n.lazy(()=>Promise.resolve().then(()=>require("./ModulesPage-lz8DUm3X.js")).then(t=>({default:t.ModulesPage}))),fl=n.lazy(()=>Promise.resolve().then(()=>require("./SlaDocPage-D44QWNY8.js")).then(t=>({default:t.SlaDocPage}))),bl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportIndexPage-CsDQ35Cu.js")).then(t=>({default:t.SupportIndexPage}))),vl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportDashboardDocPage-DfV-9_8r.js")).then(t=>({default:t.SupportDashboardDocPage}))),yl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTicketsDocPage-B_603CpY.js")).then(t=>({default:t.SupportTicketsDocPage}))),jl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportMyTicketsDocPage-Dbp6XBnH.js")).then(t=>({default:t.SupportMyTicketsDocPage}))),Nl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTemplatesDocPage-BkeDpR-8.js")).then(t=>({default:t.SupportTemplatesDocPage}))),wl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportEscalationDocPage-C65oCDZL.js")).then(t=>({default:t.SupportEscalationDocPage}))),Sl=n.lazy(()=>Promise.resolve().then(()=>require("./AiDocPage-CM7j_50_.js")).then(t=>({default:t.AiDocPage}))),Cl=n.lazy(()=>Promise.resolve().then(()=>require("./SettingsDocPage-Dqj8KzOa.js")).then(t=>({default:t.SettingsDocPage}))),kl=n.lazy(()=>Promise.resolve().then(()=>require("./ThemeDocPage-B6x55uSE.js")).then(t=>({default:t.ThemeDocPage}))),Al=n.lazy(()=>Promise.resolve().then(()=>require("./BaIndexPage-Df6ld4jp.js")).then(t=>({default:t.BaIndexPage}))),Vs=n.lazy(()=>Promise.resolve().then(()=>require("./BaViewerPage-CX3yS6tI.js")).then(t=>({default:t.BaViewerPage}))),Pl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CO5QP9C1.js"))),Tl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BASU1QDx.js"))),Rl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DYJbiXHU.js"))),El=n.lazy(()=>Promise.resolve().then(()=>require("./index-BBQMnq4P.js"))),Il=n.lazy(()=>Promise.resolve().then(()=>require("./index-Bz8ggekC.js"))),Ll=n.lazy(()=>Promise.resolve().then(()=>require("./index-D1WPBG1_.js"))),$l=n.lazy(()=>Promise.resolve().then(()=>require("./index-DIuoVYFu.js"))),Dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-Cdu0fSs8.js"))),Ml=n.lazy(()=>Promise.resolve().then(()=>require("./index-BVUCDL0k.js"))),Ol=n.lazy(()=>Promise.resolve().then(()=>require("./index-DRT2wvEs.js"))),Fl=n.lazy(()=>Promise.resolve().then(()=>require("./index-xCGnOlox.js"))),_l=n.lazy(()=>Promise.resolve().then(()=>require("./index-DQBVnnd6.js"))),ql=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0rFTzxZ.js"))),Ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-HWG-CG1i.js"))),zl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DlX3cwCY.js"))),Bl=n.lazy(()=>Promise.resolve().then(()=>require("./index-IuHTxwV6.js"))),Gl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DiazxhY7.js"))),Kl=n.lazy(()=>Promise.resolve().then(()=>require("./index-i8XTb32s.js"))),Hl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BHim8lfc.js"))),Vl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BEpBEF5G.js"))),Wl=n.lazy(()=>Promise.resolve().then(()=>require("./index-p2jNjCTo.js")));function Xl(){return e.jsxs(e.Fragment,{children:[e.jsxs(w.Route,{path:"/system/docs",element:e.jsx(Hs,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(tl,{})}),e.jsx(w.Route,{path:"developer",element:e.jsx(rl,{})}),e.jsx(w.Route,{path:"developer/infrastructure",element:e.jsx(al,{})}),e.jsx(w.Route,{path:"developer/installation",element:e.jsx(nl,{})}),e.jsx(w.Route,{path:"developer/database",element:e.jsx(ol,{})}),e.jsx(w.Route,{path:"developer/dual-dbcontext",element:e.jsx(il,{})}),e.jsx(w.Route,{path:"developer/cross-schema-fk",element:e.jsx(ll,{})}),e.jsx(w.Route,{path:"developer/tenants",element:e.jsx(cl,{})}),e.jsx(w.Route,{path:"developer/tenants/multi-tenant-mode",element:e.jsx(dl,{})}),e.jsx(w.Route,{path:"developer/tenants/b2c",element:e.jsx(ul,{})}),e.jsx(w.Route,{path:"developer/multi-tenant-mode",element:e.jsx(w.Navigate,{to:"/system/docs/developer/tenants/multi-tenant-mode",replace:!0})}),e.jsx(w.Route,{path:"developer/teams-integration",element:e.jsx(ml,{})}),e.jsx(w.Route,{path:"developer/testing/security",element:e.jsx(pl,{})}),e.jsx(w.Route,{path:"user",element:e.jsx(xl,{})}),e.jsx(w.Route,{path:"user/architecture",element:e.jsx(hl,{})}),e.jsx(w.Route,{path:"user/modules",element:e.jsx(gl,{})}),e.jsx(w.Route,{path:"user/support",element:e.jsx(bl,{})}),e.jsx(w.Route,{path:"user/support-dashboard",element:e.jsx(vl,{})}),e.jsx(w.Route,{path:"user/support-tickets",element:e.jsx(yl,{})}),e.jsx(w.Route,{path:"user/support-my-tickets",element:e.jsx(jl,{})}),e.jsx(w.Route,{path:"user/support-sla",element:e.jsx(fl,{})}),e.jsx(w.Route,{path:"user/support-templates",element:e.jsx(Nl,{})}),e.jsx(w.Route,{path:"user/support-escalation",element:e.jsx(wl,{})}),e.jsx(w.Route,{path:"user/ai",element:e.jsx(Sl,{})}),e.jsx(w.Route,{path:"user/settings",element:e.jsx(Cl,{})}),e.jsx(w.Route,{path:"user/theme",element:e.jsx(kl,{})}),e.jsx(w.Route,{path:"ba",element:e.jsx(Al,{})}),e.jsx(w.Route,{path:"ba/:appCode",element:e.jsx(Vs,{})}),e.jsx(w.Route,{path:"ba/:appCode/:moduleCode",element:e.jsx(Vs,{})})]}),e.jsxs(w.Route,{path:"/docs/business",element:e.jsx(Hs,{}),children:[e.jsx(w.Route,{path:"administration/users",element:e.jsx(Pl,{})}),e.jsx(w.Route,{path:"administration/users/dashboard",element:e.jsx(Tl,{})}),e.jsx(w.Route,{path:"administration/users/references",element:e.jsx(Rl,{})}),e.jsx(w.Route,{path:"administration/users/groups",element:e.jsx(El,{})}),e.jsx(w.Route,{path:"administration/permissions",element:e.jsx(Il,{})}),e.jsx(w.Route,{path:"administration/permissions/assignments",element:e.jsx(Ll,{})}),e.jsx(w.Route,{path:"administration/tenants",element:e.jsx($l,{})}),e.jsx(w.Route,{path:"administration/tenants/template",element:e.jsx(Dl,{})}),e.jsx(w.Route,{path:"administration/tenants/business",element:e.jsx(Ml,{})}),e.jsx(w.Route,{path:"administration/tenants/personal",element:e.jsx(Ol,{})}),e.jsx(w.Route,{path:"administration/tenants/other",element:e.jsx(Fl,{})}),e.jsx(w.Route,{path:"administration/tenants/applications",element:e.jsx(_l,{})}),e.jsx(w.Route,{path:"administration/tenants/access-requests",element:e.jsx(ql,{})}),e.jsx(w.Route,{path:"administration/tenants/organisations",element:e.jsx(Ul,{})}),e.jsx(w.Route,{path:"administration/ai",element:e.jsx(zl,{})}),e.jsx(w.Route,{path:"administration/workflows",element:e.jsx(Bl,{})}),e.jsx(w.Route,{path:"administration/entra",element:e.jsx(Gl,{})}),e.jsx(w.Route,{path:"administration/applications",element:e.jsx(Kl,{})}),e.jsx(w.Route,{path:"administration/configuration",element:e.jsx(Hl,{})}),e.jsx(w.Route,{path:"administration/configuration/license",element:e.jsx(Vl,{})}),e.jsx(w.Route,{path:"platform/support/tickets",element:e.jsx(Wl,{})})]}),e.jsx(w.Route,{path:"/system/docs/presentation",element:e.jsx(sl,{})}),e.jsx(w.Route,{path:"/docs/*",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})}),e.jsx(w.Route,{path:"/docs",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})})]})}const Yl={"administration.configuration.settings":{defaultTab:"general",tabs:["general","file-upload","legal-file"]},"administration.configuration.appsettings":{defaultTab:"infrastructure",tabs:["infrastructure","authentication","logging","email","entra"]}},Jl=[{icon:l.Users,title:"Gestion des Utilisateurs",description:"Créez, modifiez et gérez vos utilisateurs avec une interface intuitive. Profils complets, avatars et informations personnalisables.",color:"from-blue-500 to-cyan-500"},{icon:l.Bell,title:"Gestion des Notifications",description:"Système de notifications en temps réel. Email, push, in-app. Templates personnalisables et historique complet.",color:"from-amber-500 to-orange-500"},{icon:l.HeadphonesIcon,title:"Gestion du Support",description:"Système de tickets intégré pour le support client. Suivi, priorités, assignation et statistiques.",color:"from-emerald-500 to-teal-500"},{icon:l.Shield,title:"Panneau Administrateur",description:"Dashboard complet pour administrer votre plateforme. Métriques, logs, configuration et monitoring.",color:"from-purple-500 to-pink-500"},{icon:l.Key,title:"Gestion des Rôles",description:"RBAC avancé avec permissions granulaires. Hiérarchie de rôles, wildcards et héritage des droits.",color:"from-red-500 to-rose-500"},{icon:l.Layers,title:"Architecture Modulaire",description:"Structure en 5 niveaux : Contexte, Application, Module, Section, Resource. Extensible et maintenable.",color:"from-indigo-500 to-violet-500"}],Ql=[{icon:l.Zap,text:"Démarrage rapide"},{icon:l.Lock,text:"Sécurité intégrée"},{icon:l.Rocket,text:"Performance optimale"}],Zl=[".NET 10","React 19","TypeScript","EF Core","SQL Server","Tailwind CSS"];function ec(){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("section",{className:"relative pt-32 pb-20 md:pt-40 md:pb-32 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 rounded-full bg-primary-500/10 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 rounded-full bg-accent-500/10 blur-3xl"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] rounded-full bg-gradient-to-r from-primary-500/5 to-accent-500/5 blur-3xl"})]}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-primary-500/10 border border-primary-500/20 mb-8",children:[e.jsx(l.Zap,{className:"w-4 h-4 text-primary-500"}),e.jsx("span",{className:"text-sm font-medium text-primary-500",children:"Version 1.0 disponible"})]}),e.jsxs("h1",{className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold tracking-tight mb-6",children:["Le socle moderne pour",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"vos applications"})]}),e.jsx("p",{className:"max-w-2xl mx-auto text-lg md:text-xl text-[var(--text-secondary)] mb-10",children:"SmartStack est une plateforme complète pour créer des applications d'entreprise. Authentification, rôles, notifications et support intégrés."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 mb-16",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Commencer gratuitement",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"#features",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Découvrir les fonctionnalités"})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-6",children:Ql.map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[e.jsx(t.icon,{className:"w-5 h-5 text-primary-500"}),e.jsx("span",{children:t.text})]},t.text))})]})})]}),e.jsx("section",{className:"py-8 bg-[var(--bg-secondary)] border-y border-[var(--border-color)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-8 md:gap-12",children:[e.jsx("span",{className:"text-[var(--text-tertiary)] text-sm uppercase tracking-wider",children:"Construit avec"}),Zl.map(t=>e.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:t},t))]})})}),e.jsx("section",{id:"features",className:"py-20 md:py-32",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Tout ce dont vous avez besoin"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)]",children:"SmartStack inclut toutes les fonctionnalités essentielles pour démarrer votre projet d'entreprise."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Jl.map(t=>e.jsxs("div",{className:"group p-6 rounded-2xl bg-[var(--bg-card)] border border-[var(--border-color)] hover-card",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${t.color} flex items-center justify-center mb-4`,children:e.jsx(t.icon,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:t.title}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t.description})]},t.title))})]})}),e.jsx("section",{id:"modules",className:"py-20 md:py-32 bg-[var(--bg-secondary)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:["Architecture modulaire",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"prête pour la production"})]}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-8",children:"SmartStack utilise une architecture en 5 niveaux qui permet une organisation claire et une extensibilité maximale. Chaque niveau correspond à un scope de permissions."}),e.jsx("ul",{className:"space-y-4 mb-8",children:["Contexte - Environnements séparés (Platform, Business, Personal)","Application - Apps au sein d'un contexte (Admin, MySpace)","Module - Fonctionnalités (Users, Roles, Profile)","Section - Sous-divisions des modules","Resource - Éléments individuels"].map(t=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary-500/10 flex items-center justify-center mt-0.5",children:e.jsx(l.Check,{className:"w-4 h-4 text-primary-500"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t})]},t))})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary-500/20 to-accent-500/20 rounded-3xl blur-2xl"}),e.jsx("div",{className:"relative p-8 rounded-3xl bg-[var(--bg-card)] border border-[var(--border-color)]",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-primary-500/10 to-primary-500/5 border border-primary-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-primary-500"}),e.jsx("span",{className:"font-semibold text-primary-500",children:"Contexte: Platform"})]}),e.jsxs("div",{className:"ml-4 mt-3 p-3 rounded-lg bg-accent-500/10 border border-accent-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-500"}),e.jsx("span",{className:"font-medium text-accent-500",children:"Application: Admin"})]}),e.jsxs("div",{className:"ml-4 mt-2 space-y-2",children:[e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Users"})]})}),e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Key,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Roles"})]})})]})]})]})})})]})]})})}),e.jsx("section",{id:"contact",className:"py-20 md:py-32",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"relative overflow-hidden rounded-3xl animated-gradient p-px",children:e.jsxs("div",{className:"relative rounded-3xl bg-[var(--bg-primary)] p-8 md:p-16 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Prêt à commencer ?"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)] mb-8",children:"Lancez votre projet d'entreprise avec SmartStack. Tout est déjà configuré pour vous permettre de vous concentrer sur votre métier."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Créer un compte",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"/contact",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Nous contacter"})]})]})})})})]})}const tc=(t,s)=>{const r=s.exec(t);return r?r[1]:""},sc=[{detect:t=>t.includes("edg/")||t.includes("edge/"),name:"Edge",pattern:/Edg(?:e)?\/(\d+)/i},{detect:t=>t.includes("opr/")||t.includes("opera"),name:"Opera",pattern:/(?:OPR|Opera)\/(\d+)/i},{detect:t=>t.includes("chrome")&&!t.includes("edg"),name:"Chrome",pattern:/Chrome\/(\d+)/i},{detect:t=>t.includes("safari")&&!t.includes("chrome"),name:"Safari",pattern:/Version\/(\d+)/i},{detect:t=>t.includes("firefox"),name:"Firefox",pattern:/Firefox\/(\d+)/i},{detect:t=>t.includes("msie")||t.includes("trident"),name:"Internet Explorer",pattern:/(?:MSIE |rv:)(\d+)/i}],rc=(t,s)=>{const r=sc.find(a=>a.detect(t));return r?{browser:r.name,version:tc(s,r.pattern)}:{browser:"Unknown",version:""}},ac={"windows nt 10":"10/11","windows nt 6.3":"8.1","windows nt 6.2":"8","windows nt 6.1":"7"},nc=t=>{for(const[s,r]of Object.entries(ac))if(t.includes(s))return r;return""},oc=[{detect:t=>t.includes("windows nt"),name:"Windows",getVersion:t=>nc(t)},{detect:t=>t.includes("windows"),name:"Windows",getVersion:()=>""},{detect:t=>t.includes("iphone"),name:"iOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("ipad"),name:"iPadOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("mac os x"),name:"macOS",getVersion:(t,s)=>{const r=/Mac OS X (\d+)[._](\d+)/i.exec(s);return r?`${r[1]}.${r[2]}`:""}},{detect:t=>t.includes("android"),name:"Android",getVersion:(t,s)=>{const r=/Android (\d+)/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("linux"),name:"Linux",getVersion:()=>""},{detect:t=>t.includes("cros"),name:"Chrome OS",getVersion:()=>""}],ic=(t,s)=>{const r=oc.find(a=>a.detect(t));if(r){const a=r.getVersion(t,s);return{os:r.name,version:a}}return{os:"Unknown",version:""}},lc=t=>/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk)/i.test(t)?"Tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/i.test(t)?"Mobile":"Desktop";function cc(t){if(!t)return{browser:"Unknown",browserVersion:"",os:"Unknown",osVersion:"",device:"Unknown",formatted:"Unknown"};const s=t.toLowerCase(),{browser:r,version:a}=rc(s,t),{os:o,version:c}=ic(s,t),i=lc(s);let d=r;if(o!=="Unknown"){const u=a?a+" ":"",m=c?" "+c:"";d=`${r} ${u}sur ${o}${m}`}return{browser:r,browserVersion:a,os:o,osVersion:c,device:i,formatted:d}}function ka(){const t=navigator.userAgent.toLowerCase();return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(t)?"tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/.test(t)?"mobile":/(windows|macintosh|linux|x11)/.test(t)?"desktop":"unknown"}async function Aa(){try{const t=await fetch("https://api.ipify.org?format=json",{method:"GET",signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).ip||null}catch{return null}}function dc(){const[t,s]=n.useState(""),[r,a]=n.useState(""),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState("auth"),[p,g]=n.useState(null),[f]=n.useState(()=>{const h=new URLSearchParams(window.location.search).get("redirect_uri");return h?(sessionStorage.setItem("sso_redirect_uri",h),h):sessionStorage.getItem("sso_redirect_uri")}),b=n.useCallback(async h=>{h.preventDefault(),g(null),m("auth"),d(!0);try{Te.logEvent("login_attempt","auth",{email:t});const y=ka(),x=await Aa(),j=await E.post("/api/auth/login",{email:t,password:r,deviceType:y,clientIp:x});localStorage.setItem("token",j.token),localStorage.setItem("refreshToken",j.refreshToken),localStorage.setItem("user",JSON.stringify(j.user)),Te.logEvent("login_success","auth",{email:t}),m("prefs");try{if(!(await E.get("/api/onboarding/status")).hasCompletedOnboarding){window.location.href="/auth/onboarding";return}}catch{}try{const v=await _t.preferences.get(),S={mode:v.theme||"dark",accentColorKey:v.accentColorKey||"indigo",borderRadius:v.borderRadius||{},itemPaletteKey:v.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(S)),v.language&&localStorage.setItem("i18nextLng",v.language)}catch{}if(localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),f){sessionStorage.removeItem("sso_redirect_uri");const v=f.includes("?")?"&":"?";window.location.href=`${f}${v}token=${encodeURIComponent(j.token)}&refreshToken=${encodeURIComponent(j.refreshToken)}`;return}window.location.href="/myspace"}catch(y){if(y instanceof ps)g({message:y.message,code:"NETWORK_ERROR"});else if(y instanceof gr)g({message:y.message,code:y.code});else{const x=y instanceof Error?y.message:"Une erreur inattendue est survenue";g({message:x})}Te.logError(y instanceof Error?y:new Error(String(y)),"LoginPage.handleSubmit",{email:t})}finally{d(!1)}},[t,r,f]);return{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:u,error:p,handleSubmit:b}}const uc=[{icon:l.Shield,title:"Sécurité avancée",description:"Authentification multi-facteurs et contrôle d'accès granulaire"},{icon:l.Zap,title:"Performance optimale",description:"Interface rapide et réactive pour une productivité maximale"},{icon:l.Users,title:"Collaboration",description:"Gestion des équipes et permissions centralisée"},{icon:l.BarChart3,title:"Analytics",description:"Tableaux de bord et rapports en temps réel"}],mc=t=>{switch(t){case"ACCOUNT_DISABLED":return e.jsx(l.UserX,{className:"w-5 h-5 flex-shrink-0"});case"ACCOUNT_LOCKED":return e.jsx(l.Clock,{className:"w-5 h-5 flex-shrink-0"});case"EXTERNAL_AUTH_REQUIRED":return e.jsx(l.KeyRound,{className:"w-5 h-5 flex-shrink-0"});case"NETWORK_ERROR":return e.jsx(l.WifiOff,{className:"w-5 h-5 flex-shrink-0"});default:return e.jsx(l.AlertCircle,{className:"w-5 h-5 flex-shrink-0"})}},pc=t=>{switch(t){case"ACCOUNT_DISABLED":return"bg-orange-500/10 border-orange-500/20 text-orange-600 dark:text-orange-400";case"ACCOUNT_LOCKED":return"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-400";case"EXTERNAL_AUTH_REQUIRED":return"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400";case"NETWORK_ERROR":return"bg-gray-500/10 border-gray-500/20 text-gray-600 dark:text-gray-400";default:return"bg-red-500/10 border-red-500/20 text-red-500"}};function xc(){const{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:d,error:u,handleSubmit:m}=dc();return e.jsxs("div",{className:"min-h-screen flex",children:[e.jsxs("div",{className:"hidden lg:flex lg:w-1/2 xl:w-[55%] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 animated-gradient"}),e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"radial-gradient(circle at 1px 1px, white 1px, transparent 0)",backgroundSize:"40px 40px"}}),e.jsx("div",{className:"absolute top-20 left-20 w-72 h-72 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-20 right-20 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/3 w-64 h-64 bg-white/5 rounded-full blur-2xl animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between p-12 xl:p-16 text-white w-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-7 h-7 text-white"})}),e.jsx("span",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-4xl xl:text-5xl font-bold leading-tight mb-6",children:"Votre plateforme de gestion unifiée"}),e.jsx("p",{className:"text-xl text-white/80 mb-12",children:"Simplifiez vos processus, centralisez vos données et boostez la productivité de votre équipe."}),e.jsx("div",{className:"grid grid-cols-2 gap-6",children:uc.map(p=>e.jsxs("div",{className:"bg-white/10 backdrop-blur-sm rounded-2xl p-5 hover:bg-white/15 transition-colors",children:[e.jsx(p.icon,{className:"w-8 h-8 mb-3 text-white/90"}),e.jsx("h3",{className:"font-semibold mb-1",children:p.title}),e.jsx("p",{className:"text-sm text-white/70",children:p.description})]},p.title))})]}),e.jsxs("p",{className:"text-sm text-white/60",children:["© ",new Date().getFullYear()," SmartStack — Plateforme de gestion unifiée"]})]})]}),e.jsxs("div",{className:"w-full lg:w-1/2 xl:w-[45%] flex flex-col relative bg-[var(--bg-primary)]",children:[e.jsx("div",{className:"lg:hidden absolute inset-0",children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 rounded-full bg-primary-500/20 blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 rounded-full bg-accent-500/20 blur-3xl animate-pulse",style:{animationDelay:"1s"}})]})}),e.jsxs("div",{className:"absolute top-6 right-6 z-10 flex items-center gap-2",children:[e.jsx("a",{href:"/",className:"p-2 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-colors",title:"Retour à l'accueil",children:e.jsx(l.Home,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx(Kt,{})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-6 sm:p-8 lg:p-12",children:e.jsxs("div",{className:"w-full max-w-md relative",children:[e.jsxs("div",{className:"lg:hidden flex flex-col items-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl animated-gradient flex items-center justify-center mb-4 shadow-lg",children:e.jsx(l.Layers,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"hidden lg:block mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold mb-2",children:"Bienvenue"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Connectez-vous à votre compte pour continuer"})]}),u&&e.jsxs("div",{className:`mb-6 p-4 rounded-xl border text-sm flex items-start gap-3 ${pc(u.code)}`,children:[mc(u.code),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u.message}),u.code==="ACCOUNT_DISABLED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Contactez le support si vous pensez qu'il s'agit d'une erreur."}),u.code==="EXTERNAL_AUTH_REQUIRED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Utilisez les boutons Microsoft ou Google ci-dessous."})]})]}),e.jsxs("form",{onSubmit:m,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-2",children:"Adresse email"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Mail,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"email",type:"email",value:t,onChange:p=>s(p.target.value),placeholder:"vous@exemple.com",required:!0,className:"w-full pl-12 pr-4 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-2",children:"Mot de passe"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Lock,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"password",type:o?"text":"password",value:r,onChange:p=>a(p.target.value),placeholder:"••••••••",required:!0,className:"w-full pl-12 pr-12 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"}),e.jsx("button",{type:"button",onClick:()=>c(!o),className:"absolute right-4 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:o?e.jsx(l.EyeOff,{className:"w-5 h-5"}):e.jsx(l.Eye,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-tertiary)] text-primary-600 focus:ring-primary-500/20"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:"Se souvenir de moi"})]}),e.jsx("a",{href:"/forgot-password",className:"text-primary-500 hover:text-primary-600 font-medium transition-colors",children:"Mot de passe oublié ?"})]}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-3.5 px-4 rounded-xl bg-primary-600 hover:bg-primary-700 disabled:bg-primary-600/50 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40 disabled:shadow-none flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}),d==="auth"?"Connexion en cours...":"Chargement des préférences..."]}):"Se connecter"})]}),e.jsxs("div",{className:"relative my-8",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[var(--border-color)]"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-4 bg-[var(--bg-primary)] text-[var(--text-tertiary)]",children:"Ou continuer avec"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/microsoft",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"#F25022"}),e.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"#7FBA00"}),e.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"#00A4EF"}),e.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"#FFB900"})]}),"Microsoft"]}),e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/google",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]})]}),e.jsxs("p",{className:"text-center text-[var(--text-secondary)] mt-8",children:["Nouveau sur SmartStack ?"," ",e.jsx("a",{href:"/register",className:"text-primary-500 hover:text-primary-600 font-semibold transition-colors",children:"Créer un compte"})]})]})}),e.jsx("div",{className:"p-6 text-center",children:e.jsxs("p",{className:"text-sm text-[var(--text-tertiary)]",children:["© ",new Date().getFullYear()," SmartStack. Tous droits réservés."]})})]})]})}function hc(){const{t}=ne.useTranslation("common"),s=w.useNavigate(),r=()=>{window.history.length>2?s(-1):s("/")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-md w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-6",children:e.jsx(l.FileWarning,{className:"w-8 h-8 text-yellow-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.notFound.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.notFound.description")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mb-6 font-mono",children:window.location.pathname}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:r,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),t("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),t("errors.home")]})]})]})})})}const gc=n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-DBq7_Sm8.js")).then(t=>({default:t.ApplicationsPage}))),fc=n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-BCnL9oPb.js")).then(t=>({default:t.NotificationsPage}))),bc=n.lazy(()=>Promise.resolve().then(()=>hi).then(t=>({default:t.PublicLayout}))),Zt=n.lazy(()=>Promise.resolve().then(()=>ci).then(t=>({default:t.AppLayout}))),vc=n.lazy(()=>Promise.resolve().then(()=>require("./RegisterPage-DoeIiJt0.js")).then(t=>({default:t.RegisterPage}))),yc=n.lazy(()=>Promise.resolve().then(()=>require("./ConfirmEmailPage-Bh_K5qJn.js")).then(t=>({default:t.ConfirmEmailPage}))),jc=n.lazy(()=>Promise.resolve().then(()=>require("./ForgotPasswordPage-Dlb6wKfC.js")).then(t=>({default:t.ForgotPasswordPage}))),Nc=n.lazy(()=>Promise.resolve().then(()=>require("./ResetPasswordPage-C_VQSFB5.js")).then(t=>({default:t.ResetPasswordPage}))),wc=n.lazy(()=>Promise.resolve().then(()=>require("./ForceChangePasswordPage-1SCOPIqK.js")).then(t=>({default:t.ForceChangePasswordPage}))),Sc=n.lazy(()=>Promise.resolve().then(()=>require("./AuthCallbackPage-BF4bkTnR.js")).then(t=>({default:t.AuthCallbackPage}))),Cc=n.lazy(()=>Promise.resolve().then(()=>require("./OnboardingWizardPage-Du-tQ2ag.js")).then(t=>({default:t.OnboardingWizardPage}))),kc={".detail":"/:id",".edit":"/:id/edit",".create":"/create",".new":"/new",".duplicate":"/:id/duplicate",".settings":"/:id/settings",".configure":"/:id/configure",".permissions":"/:id/permissions",".members":"/:id/members",".history":"/:id/history",".logs":"/:id/logs",".analytics":"/:id/analytics",".preview":"/:id/preview",".versions":"/:id/versions",".comments":"/:id/comments",".attachments":"/:id/attachments",".audit":"/:id/audit",".export":"/:id/export",".notifications":"/:id/notifications",".schedule":"/:id/schedule",".workflow":"/:id/workflow",".summary":"/:id/summary",".test":"/:id/test",".runs":"/:id/runs",".import":"/import"};function Ss(t,s){const r=[];for(const[a,o]of Object.entries(kc)){const c=`${t}${a}`,i=O.resolve(c);if(i){const d=s.replace(/^\//,"")+o;r.push({path:d,Component:i})}}return r}function Ac(t,s,r,a){const o=[],c=r.route?.replace(`/${a}/`,"")||`${t.code}/${s.code}/${r.code}`,i=O.resolve(r.componentKey);if(i){const d=i;o.push(e.jsx(w.Route,{path:c,element:e.jsx(d,{})},r.componentKey))}if(r.route)for(const d of Ss(r.componentKey,c)){const u=d.Component;o.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${r.componentKey}-implicit-${d.path}`))}return o}function Pc(t,s,r){const a=[],o=s.route?.replace(`/${r}/`,"")||`${t.code}/${s.code}`,c=Yl[s.componentKey];if(c){const d=O.resolve(s.componentKey);if(d){const u=c.tabs.map(m=>{const p=`${s.componentKey}.${m}`,g=O.resolve(p);return g?e.jsx(w.Route,{path:m,element:e.jsx(g,{})},p):null}).filter(Boolean);return a.push(e.jsxs(w.Route,{path:o,element:e.jsx(d,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:c.defaultTab,replace:!0})}),u]},s.componentKey)),a}}const i=O.resolve(s.componentKey);if(i){const d=i;a.push(e.jsx(w.Route,{path:o,element:e.jsx(d,{})},s.componentKey))}if(!i&&s.resources.length>0){const d=s.resources[0];a.push(e.jsx(w.Route,{path:o,element:e.jsx(w.Navigate,{to:d.code,replace:!0})},`${s.componentKey}-redirect`))}if(s.route)for(const d of Ss(s.componentKey,o)){const u=d.Component;a.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${s.componentKey}-implicit-${d.path}`))}for(const d of s.resources){const u=Ac(t,s,d,r);a.push(...u)}return a}function Tc(t,s){const r=[],a=t.route?.replace(`/${s}/`,"")||t.code,o=O.resolve(t.componentKey);if(o){const c=o;r.push(e.jsx(w.Route,{path:a,element:e.jsx(c,{})},t.componentKey))}if(!o&&t.sections.length>0){const c=t.sections[0];r.push(e.jsx(w.Route,{path:a,element:e.jsx(w.Navigate,{to:c.code,replace:!0})},`${t.componentKey}-redirect`))}if(t.route)for(const c of Ss(t.componentKey,a)){const i=c.Component;r.push(e.jsx(w.Route,{path:c.path,element:e.jsx(i,{})},`${t.componentKey}-implicit-${c.path}`))}for(const c of t.sections){const i=Pc(t,c,s);r.push(...i)}return r}function Rc(t){const s=[],r=O.resolve(t.componentKey);if(r){const a=r;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(a,{})},`${t.code}-index`))}else if(t.modules.length>0){const a=t.modules[0],o=a.route?.replace(/^\//,"").replace(new RegExp(`^${t.code}/?`),"")||a.code;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:o,replace:!0})},`${t.code}-index`))}for(const a of t.modules){const o=Tc(a,t.code);a.requiredFeature?s.push(e.jsx(w.Route,{element:e.jsx(ws,{feature:a.requiredFeature}),children:o},`feature-${a.componentKey}`)):s.push(...o)}return s}function Ec(t,s){return t.requiredFeature?[e.jsx(w.Route,{element:e.jsx(ws,{feature:t.requiredFeature}),children:s},`feature-${t.code}`)]:s}function Ic(t){switch(t){case"administration":return[e.jsx(w.Route,{path:"settings",element:e.jsx(w.Navigate,{to:"../configuration/settings",relative:"path",replace:!0})},"legacy-settings"),e.jsx(w.Route,{path:"settings/*",element:e.jsx(Oe,{to:"/administration/configuration/settings"})},"legacy-settings-wc"),e.jsx(w.Route,{path:"appsettings",element:e.jsx(w.Navigate,{to:"../configuration/appsettings",relative:"path",replace:!0})},"legacy-appsettings"),e.jsx(w.Route,{path:"appsettings/*",element:e.jsx(Oe,{to:"/administration/configuration/appsettings"})},"legacy-appsettings-wc"),e.jsx(w.Route,{path:"email-templates",element:e.jsx(w.Navigate,{to:"../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates"),e.jsx(w.Route,{path:"email-templates/list",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates-list"),e.jsx(w.Route,{path:"email-templates/create",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates/create",relative:"path",replace:!0})},"legacy-email-templates-create"),e.jsx(w.Route,{path:"workflows/templates",element:e.jsx(w.Navigate,{to:"../email-templates",relative:"path",replace:!0})},"legacy-wf-templates"),e.jsx(w.Route,{path:"workflows/templates/*",element:e.jsx(Oe,{to:"/administration/workflows/email-templates"})},"legacy-wf-templates-wc"),e.jsx(w.Route,{path:"tenants/business",element:e.jsx(w.Navigate,{to:"../tenants/list/enterprise",replace:!0})},"legacy-tenants-biz"),e.jsx(w.Route,{path:"tenants/personal",element:e.jsx(w.Navigate,{to:"../tenants/list/personal",replace:!0})},"legacy-tenants-perso")];case"support":return[e.jsx(w.Route,{path:"dashboard",element:e.jsx(w.Navigate,{to:"tickets",replace:!0})},"legacy-dashboard"),e.jsx(w.Route,{path:"sla",element:e.jsx(w.Navigate,{to:"admin/sla",replace:!0})},"legacy-sla"),e.jsx(w.Route,{path:"templates",element:e.jsx(w.Navigate,{to:"admin/templates",replace:!0})},"legacy-templates"),e.jsx(w.Route,{path:"admin/escalation",element:e.jsx(w.Navigate,{to:"tickets/escalation",replace:!0})},"legacy-admin-esc")];default:return[]}}function Lc(){const{isLoading:t,menu:s}=Ce(),{currentTenant:r}=Ee(),{user:a}=Pe(),o=w.useLocation();if(t)return e.jsx(wt,{});const c=o.pathname.split("/").filter(Boolean),i=c[0]==="t"?c.slice(2):c,d=i.slice(0,2).join("."),u=r?.slug?`/t/${r.slug}/applications`:"/applications",m=i[0]?.toLowerCase(),g=(m?s?.applications.some(f=>f.code?.toLowerCase()===m)??!1:!1)?"permission":"tenant";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:g,tenantName:r?.name,permissionPath:d||void 0,applicationsUrl:u,userRoles:a?.roles,userPermissions:a?.permissions})})})]})}function $c(){const{isLoading:t}=Ce();return!!localStorage.getItem("token")&&t?e.jsx(wt,{}):e.jsx(hc,{})}function Dc(){const{menu:t,isLoading:s}=Ce(),r=n.useMemo(()=>!t||s?[]:t.applications.map(o=>{const c=o.route?.replace(/^\//,"")||o.code,i=Rc(o),d=Ec(o,i),u=Ic(o.code);return e.jsxs(w.Route,{path:c,element:e.jsx(Zt,{}),children:[d,u]},o.code)}),[t,s]),a=e.jsx(e.Fragment,{children:e.jsx(w.Route,{element:e.jsx(Sa,{}),children:e.jsxs(w.Route,{element:e.jsx(Ca,{}),children:[r,e.jsx(w.Route,{path:"applications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(gc,{})})}),e.jsx(w.Route,{path:"notifications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(fc,{})})}),e.jsx(w.Route,{path:"administration/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"administration/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"support-client",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"support-client/*",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"user",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"user/*",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"*",element:e.jsx(Lc,{})})]})})});return e.jsxs(n.Suspense,{fallback:e.jsx(wt,{}),children:[e.jsx(Ji,{}),e.jsx(el,{}),e.jsxs(w.Routes,{children:[e.jsx(w.Route,{path:"/",element:e.jsx(bc,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(ec,{})})}),Xl(),e.jsx(w.Route,{path:"/login",element:e.jsx(xc,{})}),e.jsx(w.Route,{path:"/register",element:e.jsx(vc,{})}),e.jsx(w.Route,{path:"/confirm-email",element:e.jsx(yc,{})}),e.jsx(w.Route,{path:"/forgot-password",element:e.jsx(jc,{})}),e.jsx(w.Route,{path:"/reset-password",element:e.jsx(Nc,{})}),e.jsx(w.Route,{path:"/force-change-password",element:e.jsx(wc,{})}),e.jsx(w.Route,{path:"/auth/callback",element:e.jsx(Sc,{})}),e.jsx(w.Route,{path:"/auth/onboarding",element:e.jsx(Cc,{})}),e.jsx(w.Route,{path:"/t/:slug",element:e.jsx(Ks,{}),children:a}),e.jsx(w.Route,{element:e.jsx(Ks,{}),children:a}),e.jsx(w.Route,{path:"/admin",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/admin/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/administration/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/support/*",element:e.jsx(w.Navigate,{to:"/support",replace:!0})}),e.jsx(w.Route,{path:"/dashboard",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/business",element:e.jsx(w.Navigate,{to:"/applications",replace:!0})}),e.jsx(w.Route,{path:"/business/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"*",element:e.jsx($c,{})})]})]})}function Ws({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Mc(t,s){return t?"bg-[var(--color-accent-100)] border border-[var(--color-accent-500)]":s?"opacity-50 cursor-not-allowed bg-[var(--bg-secondary)]":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-transparent hover:border-[var(--border-color)]"}function Pa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["common","navigation"]),{menu:a}=Ce(),{favorites:o,toggleFavorite:c,isFavorite:i,canAddMore:d,maxFavorites:u}=Ke();if(!t)return null;const m=[];a?.applications.forEach(g=>{(g.modules?.length??0)>0&&m.push({app:g,modules:g.modules})});const p=(g,f)=>{const b=[...g.sections||[]].sort((x,j)=>x.displayOrder-j.displayOrder),h=b.length>0&&b[0].route?b[0].route:`/${f.code}/${g.code}`,y={id:g.id,code:g.code,label:g.label,icon:g.icon||"Star",route:h,applicationCode:f.code,applicationLabel:f.label};c(y)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-modal)] shadow-xl w-full max-w-lg max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),r("common:favorites.manageTitle")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r("common:favorites.selectModules",{count:o.length,max:u})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{const g={component:"FavoritesModal",url:window.location.href},f=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent("[Bug] Favorites Modal")}&body=${encodeURIComponent(`## Context
30
- - Component: ${g.component}
31
- - URL: ${g.url}
29
+ `)}`},[b,i]),y=n.useMemo(()=>{if(!t||!r||!s||!a)return null;const S=`${a.replace(/\/applications$/,"")}/support/my-tickets/create`,N=t==="tenant"?"ApplicationRequest":"Support",I=r.split(".")[0],P=t==="tenant"?i("errors.accessDenied.ticket.accessSubject",{permissionPath:r,tenantName:s}):i("errors.accessDenied.ticket.permissionSubject",{permissionPath:r,tenantName:s}),A=(t==="tenant"?i("errors.accessDenied.ticket.accessBody",{appCode:I,tenantName:s,permissionPath:r}):i("errors.accessDenied.ticket.permissionBody",{permissionPath:r,tenantName:s}))+g,R=new URLSearchParams({type:N,subject:P,body:A});return`${S}?${R.toString()}`},[t,r,s,a,i,g]),j=t==="tenant"&&s?i("errors.accessDenied.tenantNotAvailable",{tenantName:s}):t==="permission"&&s?i("errors.accessDenied.permissionMissing",{tenantName:s}):s?i("errors.accessDenied.tenantDescription",{tenantName:s}):i("errors.accessDenied.description");return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6",children:e.jsx(l.ShieldX,{className:"w-8 h-8 text-red-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:i("errors.accessDenied.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:j}),f&&e.jsxs("div",{className:"w-full mb-6 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)] divide-y divide-[var(--border-color)]",children:[e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono font-medium text-red-500",children:r})]}),(o?.length??0)>0&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourRoles")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center",children:o?.map(v=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:v},v))})]}),c&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourPermissionsFor",{appCode:p??""})}),x.length>0?e.jsx("div",{className:"flex flex-col gap-1 items-start",children:x.map(v=>e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:v},v))}):e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] italic",children:i("errors.accessDenied.noPermissions")})]})]}),!f&&r&&e.jsxs("div",{className:"w-full mb-6 p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono text-[var(--text-primary)]",children:r})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[y&&e.jsxs("a",{href:y,className:"flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.TicketPlus,{className:"w-4 h-4"}),i(t==="tenant"?"errors.accessDenied.requestAccess":"errors.accessDenied.requestPermission")]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[a?e.jsxs("a",{href:a,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LayoutGrid,{className:"w-4 h-4"}),i("errors.accessDenied.goToApplications")]}):e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),i("errors.home")]})]})]})]})})})}function Vi(){const{t}=ne.useTranslation("common"),{logout:s}=Pe();return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-orange-500/10 flex items-center justify-center mb-6",children:e.jsx(l.Building2,{className:"w-8 h-8 text-orange-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.noActiveWorkspace.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.noActiveWorkspace.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("a",{href:"mailto:support@atlashub.ch",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.Mail,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.contactAdmin")]}),e.jsxs("button",{onClick:()=>{s()},className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.logout")]})]}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-6",children:t("errors.noActiveWorkspace.hint")})]})})})}function Nt(){return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] w-full",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(l.Loader2,{className:"w-10 h-10 animate-spin text-[var(--color-primary-500)]"}),e.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:"Chargement..."})]})})}function ka(){const{user:t,isLoading:s}=Pe(),r=w.useLocation(),{currentAppCode:a,currentModuleCode:o,isLoading:c,menu:i}=Ce(),{currentTenant:d,userTenants:u,isLoading:m,isGlobalView:p}=Ee(),x=d?.id||"global",f=n.useRef(null),b=(S,N)=>{const I=`${S}:${N}:${r.pathname}`;f.current!==I&&(f.current=I,E.post("/security/access-denied",{reason:S,permissionPath:N,attemptedPath:r.pathname}).catch(()=>{}))},g=n.useRef(d?.id);let y=!1;if(d?.id!==g.current&&(g.current=d?.id,y=!0),s)return e.jsx(Nt,{});if(!t)return e.jsx(w.Navigate,{to:"/login",state:{from:r},replace:!0});if(y||c||m||!i)return e.jsx(Nt,{});if(!d&&!p&&!u.some(N=>N.status==="Active"))return e.jsx(Vi,{});if(!a)return e.jsx(w.Outlet,{},x);if(Dr.includes(a))return e.jsx(w.Outlet,{},x);const j=(i?.applications||[]).find(S=>S.route?.split("/").filter(Boolean)[0]===a||S.code===a);if(j?.isOpen)return e.jsx(w.Outlet,{},x);if(!j){const S=[a,o].filter(Boolean).join("."),N=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("tenant",S),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(jt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"tenant",tenantName:d?.name,permissionPath:S,applicationsUrl:N,userRoles:t.roles,userPermissions:t.permissions})})})]})}const v=[a,o].filter(Boolean).join(".");if(!Sr(t.permissions,v)&&j.accessLevel!=="RequestAccess"){const S=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("permission",v),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(jt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"permission",tenantName:d?.name,permissionPath:v,applicationsUrl:S,userRoles:t.roles,userPermissions:t.permissions})})})]})}return e.jsx(w.Outlet,{},x)}function Hs(){const{slug:t}=w.useParams(),s=w.useNavigate(),r=w.useLocation(),{currentTenant:a,userTenants:o,switchTenant:c,isLoading:i,isGlobalView:d}=Ee(),{useUrlRouting:u,isLoading:m}=_t(),p=n.useRef(!1),x=n.useRef(null),f=n.useRef(null);return n.useEffect(()=>{if(i||m||!u||d)return;const b=t||Os(r.pathname),g=b!==f.current;if(f.current=b,!!g&&b&&b!==a?.slug){const y=o.find(h=>h.slug===b&&h.status==="Active");if(y)x.current=b,c(y.id).then(()=>{x.current=null}).catch(h=>{x.current=null,console.error("[TenantRouteWrapper] Failed to switch tenant:",h)});else if(a){const h=dt(r.pathname);s(`/t/${a.slug}${h}`,{replace:!0})}else s("/",{replace:!0})}},[t,r.pathname,a?.slug,o,u,i,m,d,c,s]),n.useEffect(()=>{if(i||m||p.current)return;const b=r.pathname,g=Os(b);if(d&&g){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(!u&&g){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&!g&&!d&&b!=="/"&&!b.startsWith("/login")&&!b.startsWith("/auth")&&!b.startsWith("/public")){p.current=!0,s(`/t/${a.slug}${b}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&g&&!d&&g!==a.slug&&g!==x.current){p.current=!0;const y=dt(b);s(`/t/${a.slug}${y}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}},[r.pathname,a?.slug,u,i,m,d,s]),e.jsx(w.Outlet,{})}function Oe({to:t,replace:s=!0}){const{slug:r}=w.useParams(),a=r?`/t/${r}${t}`:t;return e.jsx(w.Navigate,{to:a,replace:s})}function Wi(){const{t}=ne.useTranslation("admin"),{license:s}=He(),r=Ze();return!s||s.status==="NoLicense"?e.jsx(Ca,{open:!0,onOpenChange:()=>{}}):e.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsx("div",{className:"flex justify-center pt-8 pb-4",children:e.jsx("div",{className:"p-4 bg-red-100 dark:bg-red-900/30 rounded-full",children:e.jsx(l.Lock,{className:"w-10 h-10 text-red-600 dark:text-red-400"})})}),e.jsxs("div",{className:"px-6 pb-6 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:t("license.guard.title","License Required")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:t("license.guard.description","Your license has expired or is invalid. Access to this area is restricted. Please activate a valid license to continue using the platform.")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(w.Link,{to:r("/administration/configuration/license"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(l.Settings,{className:"w-4 h-4"}),t("license.guard.manageLicense","Manage License")]}),e.jsxs(w.Link,{to:r("/myspace/profile"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(l.User,{className:"w-4 h-4"}),t("license.guard.myProfile","My Profile")]})]})]})]})]})}const Xi=["/myspace","/administration/configuration"];function Yi(t){const s=/^\/t\/[^/]+\/(.*)/.exec(t);return s?`/${s[1]}`:t}function Aa(){const{license:t,isLoading:s,isReadOnlyMode:r,isServerDowntimeBlocked:a}=He(),o=w.useLocation();if(s)return e.jsx(w.Outlet,{});const c=Yi(o.pathname);return Xi.some(d=>c.startsWith(d))?e.jsx(w.Outlet,{}):!t?.isValid||r||a?e.jsxs(e.Fragment,{children:[e.jsx(w.Outlet,{}),e.jsx(Wi,{})]}):e.jsx(w.Outlet,{})}function Ss({feature:t}){const{t:s}=ne.useTranslation("admin"),{isFeatureEnabled:r,license:a,isLoading:o}=He();return o?e.jsx(w.Outlet,{}):r(t)?e.jsx(w.Outlet,{}):e.jsx("div",{className:"flex items-center justify-center min-h-[60vh] p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700 max-w-md",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:s("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:s("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.currentEdition","Current: {{edition}}",{edition:a?.edition||"Unknown"})})]})]})})}function Ji(){return aa(),null}function Qi(){return w.useInRouterContext()?e.jsx(Ji,{}):null}const vt="/api/administration/tenants/tenant-analytics",cs={getDashboardStats:async(t=30)=>await E.get(`${vt}/dashboard`,{params:{period:t}}),getTopTenants:async(t=10,s=30,r="access")=>await E.get(`${vt}/top-tenants`,{params:{limit:t,period:s,sortBy:r}}),getTrends:async(t=30)=>await E.get(`${vt}/trends`,{params:{period:t}}),trackStart:async t=>await E.post(`${vt}/track/start`,{tenantId:t}),trackEnd:async t=>{await E.post(`${vt}/track/end`,{accessId:t})}},Zi="/api/administration/tenants/tenant-analytics";function el(){const{currentTenant:t}=Ee(),{isAuthenticated:s}=Pe(),r=n.useRef(null),a=n.useRef(null),o=n.useRef(!1);n.useEffect(()=>{if(!s)return;const c=window.location.pathname;if(c.startsWith("/auth/")||c.startsWith("/login"))return;const i=t?.id??null;return i===a.current||o.current?void 0:(o.current=!0,(async()=>{if(r.current){try{await cs.trackEnd(r.current)}catch{}r.current=null}if(a.current=i,i)try{const u=await cs.trackStart(i);r.current=u.accessId}catch{r.current=null}o.current=!1})(),()=>{if(r.current){const u=localStorage.getItem("token");if(!u)return;fetch(`${Zi}/track/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({accessId:r.current}),keepalive:!0}).catch(()=>{}),r.current=null,a.current=null}})},[t?.id,s])}function tl(){return el(),null}const Vs=n.lazy(()=>Promise.resolve().then(()=>hi).then(t=>({default:t.DocsLayout}))),sl=n.lazy(()=>Promise.resolve().then(()=>require("./DocsIndexPage-BPfi0FQD.js")).then(t=>({default:t.DocsIndexPage}))),rl=n.lazy(()=>Promise.resolve().then(()=>require("./SmartStackPresentationPage-52Nb7F0X.js")).then(t=>({default:t.SmartStackPresentationPage}))),al=n.lazy(()=>Promise.resolve().then(()=>require("./DeveloperIndexPage-CtBfD2JI.js")).then(t=>({default:t.DeveloperIndexPage}))),nl=n.lazy(()=>Promise.resolve().then(()=>require("./InfrastructurePage-D4ZjLzI_.js")).then(t=>({default:t.InfrastructurePage}))),ol=n.lazy(()=>Promise.resolve().then(()=>require("./InstallationPage-BJ-GBVPp.js")).then(t=>({default:t.InstallationPage}))),il=n.lazy(()=>Promise.resolve().then(()=>require("./DatabasePage-DAzb3FnS.js")).then(t=>({default:t.DatabasePage}))),ll=n.lazy(()=>Promise.resolve().then(()=>require("./DualDbContextPage-Dz8NAewk.js")).then(t=>({default:t.DualDbContextPage}))),cl=n.lazy(()=>Promise.resolve().then(()=>require("./CrossSchemaFkPage-DqFNORYd.js")).then(t=>({default:t.CrossSchemaFkPage}))),dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantIndexPage}))),ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.MultiTenantModePage}))),ml=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantB2CPage}))),pl=n.lazy(()=>Promise.resolve().then(()=>require("./TeamsIntegrationPage-DXj5MDRS.js")).then(t=>({default:t.TeamsIntegrationPage}))),xl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CdORB0b4.js")).then(t=>({default:t.SecurityTestingPage}))),hl=n.lazy(()=>Promise.resolve().then(()=>require("./UserIndexPage-DahU6wzK.js")).then(t=>({default:t.UserIndexPage}))),gl=n.lazy(()=>Promise.resolve().then(()=>require("./ArchitecturePage-Cn_XCDAo.js")).then(t=>({default:t.ArchitecturePage}))),fl=n.lazy(()=>Promise.resolve().then(()=>require("./ModulesPage-lz8DUm3X.js")).then(t=>({default:t.ModulesPage}))),bl=n.lazy(()=>Promise.resolve().then(()=>require("./SlaDocPage-D44QWNY8.js")).then(t=>({default:t.SlaDocPage}))),vl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportIndexPage-CsDQ35Cu.js")).then(t=>({default:t.SupportIndexPage}))),yl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportDashboardDocPage-DfV-9_8r.js")).then(t=>({default:t.SupportDashboardDocPage}))),jl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTicketsDocPage-B_603CpY.js")).then(t=>({default:t.SupportTicketsDocPage}))),Nl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportMyTicketsDocPage-Dbp6XBnH.js")).then(t=>({default:t.SupportMyTicketsDocPage}))),wl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTemplatesDocPage-BkeDpR-8.js")).then(t=>({default:t.SupportTemplatesDocPage}))),Sl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportEscalationDocPage-C65oCDZL.js")).then(t=>({default:t.SupportEscalationDocPage}))),Cl=n.lazy(()=>Promise.resolve().then(()=>require("./AiDocPage-CM7j_50_.js")).then(t=>({default:t.AiDocPage}))),kl=n.lazy(()=>Promise.resolve().then(()=>require("./SettingsDocPage-Dqj8KzOa.js")).then(t=>({default:t.SettingsDocPage}))),Al=n.lazy(()=>Promise.resolve().then(()=>require("./ThemeDocPage-B6x55uSE.js")).then(t=>({default:t.ThemeDocPage}))),Pl=n.lazy(()=>Promise.resolve().then(()=>require("./BaIndexPage-Df6ld4jp.js")).then(t=>({default:t.BaIndexPage}))),Ws=n.lazy(()=>Promise.resolve().then(()=>require("./BaViewerPage-CX3yS6tI.js")).then(t=>({default:t.BaViewerPage}))),Tl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CO5QP9C1.js"))),Rl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BASU1QDx.js"))),El=n.lazy(()=>Promise.resolve().then(()=>require("./index-DYJbiXHU.js"))),Il=n.lazy(()=>Promise.resolve().then(()=>require("./index-BBQMnq4P.js"))),Ll=n.lazy(()=>Promise.resolve().then(()=>require("./index-Bz8ggekC.js"))),$l=n.lazy(()=>Promise.resolve().then(()=>require("./index-D1WPBG1_.js"))),Dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DIuoVYFu.js"))),Ml=n.lazy(()=>Promise.resolve().then(()=>require("./index-Cdu0fSs8.js"))),Ol=n.lazy(()=>Promise.resolve().then(()=>require("./index-BVUCDL0k.js"))),Fl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DRT2wvEs.js"))),_l=n.lazy(()=>Promise.resolve().then(()=>require("./index-xCGnOlox.js"))),Ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-DQBVnnd6.js"))),ql=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0rFTzxZ.js"))),Bl=n.lazy(()=>Promise.resolve().then(()=>require("./index-HWG-CG1i.js"))),zl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DlX3cwCY.js"))),Gl=n.lazy(()=>Promise.resolve().then(()=>require("./index-IuHTxwV6.js"))),Kl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DiazxhY7.js"))),Hl=n.lazy(()=>Promise.resolve().then(()=>require("./index-i8XTb32s.js"))),Vl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BHim8lfc.js"))),Wl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BEpBEF5G.js"))),Xl=n.lazy(()=>Promise.resolve().then(()=>require("./index-p2jNjCTo.js")));function Yl(){return e.jsxs(e.Fragment,{children:[e.jsxs(w.Route,{path:"/system/docs",element:e.jsx(Vs,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(sl,{})}),e.jsx(w.Route,{path:"developer",element:e.jsx(al,{})}),e.jsx(w.Route,{path:"developer/infrastructure",element:e.jsx(nl,{})}),e.jsx(w.Route,{path:"developer/installation",element:e.jsx(ol,{})}),e.jsx(w.Route,{path:"developer/database",element:e.jsx(il,{})}),e.jsx(w.Route,{path:"developer/dual-dbcontext",element:e.jsx(ll,{})}),e.jsx(w.Route,{path:"developer/cross-schema-fk",element:e.jsx(cl,{})}),e.jsx(w.Route,{path:"developer/tenants",element:e.jsx(dl,{})}),e.jsx(w.Route,{path:"developer/tenants/multi-tenant-mode",element:e.jsx(ul,{})}),e.jsx(w.Route,{path:"developer/tenants/b2c",element:e.jsx(ml,{})}),e.jsx(w.Route,{path:"developer/multi-tenant-mode",element:e.jsx(w.Navigate,{to:"/system/docs/developer/tenants/multi-tenant-mode",replace:!0})}),e.jsx(w.Route,{path:"developer/teams-integration",element:e.jsx(pl,{})}),e.jsx(w.Route,{path:"developer/testing/security",element:e.jsx(xl,{})}),e.jsx(w.Route,{path:"user",element:e.jsx(hl,{})}),e.jsx(w.Route,{path:"user/architecture",element:e.jsx(gl,{})}),e.jsx(w.Route,{path:"user/modules",element:e.jsx(fl,{})}),e.jsx(w.Route,{path:"user/support",element:e.jsx(vl,{})}),e.jsx(w.Route,{path:"user/support-dashboard",element:e.jsx(yl,{})}),e.jsx(w.Route,{path:"user/support-tickets",element:e.jsx(jl,{})}),e.jsx(w.Route,{path:"user/support-my-tickets",element:e.jsx(Nl,{})}),e.jsx(w.Route,{path:"user/support-sla",element:e.jsx(bl,{})}),e.jsx(w.Route,{path:"user/support-templates",element:e.jsx(wl,{})}),e.jsx(w.Route,{path:"user/support-escalation",element:e.jsx(Sl,{})}),e.jsx(w.Route,{path:"user/ai",element:e.jsx(Cl,{})}),e.jsx(w.Route,{path:"user/settings",element:e.jsx(kl,{})}),e.jsx(w.Route,{path:"user/theme",element:e.jsx(Al,{})}),e.jsx(w.Route,{path:"ba",element:e.jsx(Pl,{})}),e.jsx(w.Route,{path:"ba/:appCode",element:e.jsx(Ws,{})}),e.jsx(w.Route,{path:"ba/:appCode/:moduleCode",element:e.jsx(Ws,{})})]}),e.jsxs(w.Route,{path:"/docs/business",element:e.jsx(Vs,{}),children:[e.jsx(w.Route,{path:"administration/users",element:e.jsx(Tl,{})}),e.jsx(w.Route,{path:"administration/users/dashboard",element:e.jsx(Rl,{})}),e.jsx(w.Route,{path:"administration/users/references",element:e.jsx(El,{})}),e.jsx(w.Route,{path:"administration/users/groups",element:e.jsx(Il,{})}),e.jsx(w.Route,{path:"administration/permissions",element:e.jsx(Ll,{})}),e.jsx(w.Route,{path:"administration/permissions/assignments",element:e.jsx($l,{})}),e.jsx(w.Route,{path:"administration/tenants",element:e.jsx(Dl,{})}),e.jsx(w.Route,{path:"administration/tenants/template",element:e.jsx(Ml,{})}),e.jsx(w.Route,{path:"administration/tenants/business",element:e.jsx(Ol,{})}),e.jsx(w.Route,{path:"administration/tenants/personal",element:e.jsx(Fl,{})}),e.jsx(w.Route,{path:"administration/tenants/other",element:e.jsx(_l,{})}),e.jsx(w.Route,{path:"administration/tenants/applications",element:e.jsx(Ul,{})}),e.jsx(w.Route,{path:"administration/tenants/access-requests",element:e.jsx(ql,{})}),e.jsx(w.Route,{path:"administration/tenants/organisations",element:e.jsx(Bl,{})}),e.jsx(w.Route,{path:"administration/ai",element:e.jsx(zl,{})}),e.jsx(w.Route,{path:"administration/workflows",element:e.jsx(Gl,{})}),e.jsx(w.Route,{path:"administration/entra",element:e.jsx(Kl,{})}),e.jsx(w.Route,{path:"administration/applications",element:e.jsx(Hl,{})}),e.jsx(w.Route,{path:"administration/configuration",element:e.jsx(Vl,{})}),e.jsx(w.Route,{path:"administration/configuration/license",element:e.jsx(Wl,{})}),e.jsx(w.Route,{path:"platform/support/tickets",element:e.jsx(Xl,{})})]}),e.jsx(w.Route,{path:"/system/docs/presentation",element:e.jsx(rl,{})}),e.jsx(w.Route,{path:"/docs/*",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})}),e.jsx(w.Route,{path:"/docs",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})})]})}const Jl={"administration.configuration.settings":{defaultTab:"general",tabs:["general","file-upload","legal-file"]},"administration.configuration.appsettings":{defaultTab:"infrastructure",tabs:["infrastructure","authentication","logging","email","entra"]}},Ql=[{icon:l.Users,title:"Gestion des Utilisateurs",description:"Créez, modifiez et gérez vos utilisateurs avec une interface intuitive. Profils complets, avatars et informations personnalisables.",color:"from-blue-500 to-cyan-500"},{icon:l.Bell,title:"Gestion des Notifications",description:"Système de notifications en temps réel. Email, push, in-app. Templates personnalisables et historique complet.",color:"from-amber-500 to-orange-500"},{icon:l.HeadphonesIcon,title:"Gestion du Support",description:"Système de tickets intégré pour le support client. Suivi, priorités, assignation et statistiques.",color:"from-emerald-500 to-teal-500"},{icon:l.Shield,title:"Panneau Administrateur",description:"Dashboard complet pour administrer votre plateforme. Métriques, logs, configuration et monitoring.",color:"from-purple-500 to-pink-500"},{icon:l.Key,title:"Gestion des Rôles",description:"RBAC avancé avec permissions granulaires. Hiérarchie de rôles, wildcards et héritage des droits.",color:"from-red-500 to-rose-500"},{icon:l.Layers,title:"Architecture Modulaire",description:"Structure en 5 niveaux : Contexte, Application, Module, Section, Resource. Extensible et maintenable.",color:"from-indigo-500 to-violet-500"}],Zl=[{icon:l.Zap,text:"Démarrage rapide"},{icon:l.Lock,text:"Sécurité intégrée"},{icon:l.Rocket,text:"Performance optimale"}],ec=[".NET 10","React 19","TypeScript","EF Core","SQL Server","Tailwind CSS"];function tc(){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("section",{className:"relative pt-32 pb-20 md:pt-40 md:pb-32 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 rounded-full bg-primary-500/10 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 rounded-full bg-accent-500/10 blur-3xl"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] rounded-full bg-gradient-to-r from-primary-500/5 to-accent-500/5 blur-3xl"})]}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-primary-500/10 border border-primary-500/20 mb-8",children:[e.jsx(l.Zap,{className:"w-4 h-4 text-primary-500"}),e.jsx("span",{className:"text-sm font-medium text-primary-500",children:"Version 1.0 disponible"})]}),e.jsxs("h1",{className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold tracking-tight mb-6",children:["Le socle moderne pour",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"vos applications"})]}),e.jsx("p",{className:"max-w-2xl mx-auto text-lg md:text-xl text-[var(--text-secondary)] mb-10",children:"SmartStack est une plateforme complète pour créer des applications d'entreprise. Authentification, rôles, notifications et support intégrés."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 mb-16",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Commencer gratuitement",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"#features",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Découvrir les fonctionnalités"})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-6",children:Zl.map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[e.jsx(t.icon,{className:"w-5 h-5 text-primary-500"}),e.jsx("span",{children:t.text})]},t.text))})]})})]}),e.jsx("section",{className:"py-8 bg-[var(--bg-secondary)] border-y border-[var(--border-color)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-8 md:gap-12",children:[e.jsx("span",{className:"text-[var(--text-tertiary)] text-sm uppercase tracking-wider",children:"Construit avec"}),ec.map(t=>e.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:t},t))]})})}),e.jsx("section",{id:"features",className:"py-20 md:py-32",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Tout ce dont vous avez besoin"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)]",children:"SmartStack inclut toutes les fonctionnalités essentielles pour démarrer votre projet d'entreprise."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Ql.map(t=>e.jsxs("div",{className:"group p-6 rounded-2xl bg-[var(--bg-card)] border border-[var(--border-color)] hover-card",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${t.color} flex items-center justify-center mb-4`,children:e.jsx(t.icon,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:t.title}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t.description})]},t.title))})]})}),e.jsx("section",{id:"modules",className:"py-20 md:py-32 bg-[var(--bg-secondary)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:["Architecture modulaire",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"prête pour la production"})]}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-8",children:"SmartStack utilise une architecture en 5 niveaux qui permet une organisation claire et une extensibilité maximale. Chaque niveau correspond à un scope de permissions."}),e.jsx("ul",{className:"space-y-4 mb-8",children:["Contexte - Environnements séparés (Platform, Business, Personal)","Application - Apps au sein d'un contexte (Admin, MySpace)","Module - Fonctionnalités (Users, Roles, Profile)","Section - Sous-divisions des modules","Resource - Éléments individuels"].map(t=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary-500/10 flex items-center justify-center mt-0.5",children:e.jsx(l.Check,{className:"w-4 h-4 text-primary-500"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t})]},t))})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary-500/20 to-accent-500/20 rounded-3xl blur-2xl"}),e.jsx("div",{className:"relative p-8 rounded-3xl bg-[var(--bg-card)] border border-[var(--border-color)]",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-primary-500/10 to-primary-500/5 border border-primary-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-primary-500"}),e.jsx("span",{className:"font-semibold text-primary-500",children:"Contexte: Platform"})]}),e.jsxs("div",{className:"ml-4 mt-3 p-3 rounded-lg bg-accent-500/10 border border-accent-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-500"}),e.jsx("span",{className:"font-medium text-accent-500",children:"Application: Admin"})]}),e.jsxs("div",{className:"ml-4 mt-2 space-y-2",children:[e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Users"})]})}),e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Key,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Roles"})]})})]})]})]})})})]})]})})}),e.jsx("section",{id:"contact",className:"py-20 md:py-32",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"relative overflow-hidden rounded-3xl animated-gradient p-px",children:e.jsxs("div",{className:"relative rounded-3xl bg-[var(--bg-primary)] p-8 md:p-16 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Prêt à commencer ?"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)] mb-8",children:"Lancez votre projet d'entreprise avec SmartStack. Tout est déjà configuré pour vous permettre de vous concentrer sur votre métier."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Créer un compte",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"/contact",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Nous contacter"})]})]})})})})]})}const sc=(t,s)=>{const r=s.exec(t);return r?r[1]:""},rc=[{detect:t=>t.includes("edg/")||t.includes("edge/"),name:"Edge",pattern:/Edg(?:e)?\/(\d+)/i},{detect:t=>t.includes("opr/")||t.includes("opera"),name:"Opera",pattern:/(?:OPR|Opera)\/(\d+)/i},{detect:t=>t.includes("chrome")&&!t.includes("edg"),name:"Chrome",pattern:/Chrome\/(\d+)/i},{detect:t=>t.includes("safari")&&!t.includes("chrome"),name:"Safari",pattern:/Version\/(\d+)/i},{detect:t=>t.includes("firefox"),name:"Firefox",pattern:/Firefox\/(\d+)/i},{detect:t=>t.includes("msie")||t.includes("trident"),name:"Internet Explorer",pattern:/(?:MSIE |rv:)(\d+)/i}],ac=(t,s)=>{const r=rc.find(a=>a.detect(t));return r?{browser:r.name,version:sc(s,r.pattern)}:{browser:"Unknown",version:""}},nc={"windows nt 10":"10/11","windows nt 6.3":"8.1","windows nt 6.2":"8","windows nt 6.1":"7"},oc=t=>{for(const[s,r]of Object.entries(nc))if(t.includes(s))return r;return""},ic=[{detect:t=>t.includes("windows nt"),name:"Windows",getVersion:t=>oc(t)},{detect:t=>t.includes("windows"),name:"Windows",getVersion:()=>""},{detect:t=>t.includes("iphone"),name:"iOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("ipad"),name:"iPadOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("mac os x"),name:"macOS",getVersion:(t,s)=>{const r=/Mac OS X (\d+)[._](\d+)/i.exec(s);return r?`${r[1]}.${r[2]}`:""}},{detect:t=>t.includes("android"),name:"Android",getVersion:(t,s)=>{const r=/Android (\d+)/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("linux"),name:"Linux",getVersion:()=>""},{detect:t=>t.includes("cros"),name:"Chrome OS",getVersion:()=>""}],lc=(t,s)=>{const r=ic.find(a=>a.detect(t));if(r){const a=r.getVersion(t,s);return{os:r.name,version:a}}return{os:"Unknown",version:""}},cc=t=>/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk)/i.test(t)?"Tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/i.test(t)?"Mobile":"Desktop";function dc(t){if(!t)return{browser:"Unknown",browserVersion:"",os:"Unknown",osVersion:"",device:"Unknown",formatted:"Unknown"};const s=t.toLowerCase(),{browser:r,version:a}=ac(s,t),{os:o,version:c}=lc(s,t),i=cc(s);let d=r;if(o!=="Unknown"){const u=a?a+" ":"",m=c?" "+c:"";d=`${r} ${u}sur ${o}${m}`}return{browser:r,browserVersion:a,os:o,osVersion:c,device:i,formatted:d}}function Pa(){const t=navigator.userAgent.toLowerCase();return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(t)?"tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/.test(t)?"mobile":/(windows|macintosh|linux|x11)/.test(t)?"desktop":"unknown"}async function Ta(){try{const t=await fetch("https://api.ipify.org?format=json",{method:"GET",signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).ip||null}catch{return null}}function uc(){const[t,s]=n.useState(""),[r,a]=n.useState(""),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState("auth"),[p,x]=n.useState(null),[f]=n.useState(()=>{const g=new URLSearchParams(window.location.search).get("redirect_uri");return g?(sessionStorage.setItem("sso_redirect_uri",g),g):sessionStorage.getItem("sso_redirect_uri")}),b=n.useCallback(async g=>{g.preventDefault(),x(null),m("auth"),d(!0);try{Te.logEvent("login_attempt","auth",{email:t});const y=Pa(),h=await Ta(),j=await E.post("/api/auth/login",{email:t,password:r,deviceType:y,clientIp:h});localStorage.setItem("token",j.token),localStorage.setItem("refreshToken",j.refreshToken),localStorage.setItem("user",JSON.stringify(j.user)),Te.logEvent("login_success","auth",{email:t}),m("prefs");try{if(!(await E.get("/api/onboarding/status")).hasCompletedOnboarding){window.location.href="/auth/onboarding";return}}catch{}try{const v=await Ft.preferences.get(),S={mode:v.theme||"dark",accentColorKey:v.accentColorKey||"indigo",borderRadius:v.borderRadius||{},itemPaletteKey:v.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(S)),v.language&&localStorage.setItem("i18nextLng",v.language)}catch{}if(localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),f){sessionStorage.removeItem("sso_redirect_uri");const v=f.includes("?")?"&":"?";window.location.href=`${f}${v}token=${encodeURIComponent(j.token)}&refreshToken=${encodeURIComponent(j.refreshToken)}`;return}window.location.href="/myspace"}catch(y){if(y instanceof ps)x({message:y.message,code:"NETWORK_ERROR"});else if(y instanceof fr)x({message:y.message,code:y.code});else{const h=y instanceof Error?y.message:"Une erreur inattendue est survenue";x({message:h})}Te.logError(y instanceof Error?y:new Error(String(y)),"LoginPage.handleSubmit",{email:t})}finally{d(!1)}},[t,r,f]);return{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:u,error:p,handleSubmit:b}}const mc=[{icon:l.Shield,titleKey:"features.security",descKey:"features.securityDesc"},{icon:l.Zap,titleKey:"features.performance",descKey:"features.performanceDesc"},{icon:l.Users,titleKey:"features.collaboration",descKey:"features.collaborationDesc"},{icon:l.BarChart3,titleKey:"features.analytics",descKey:"features.analyticsDesc"}],pc=t=>{switch(t){case"ACCOUNT_DISABLED":return e.jsx(l.UserX,{className:"w-5 h-5 flex-shrink-0"});case"ACCOUNT_LOCKED":return e.jsx(l.Clock,{className:"w-5 h-5 flex-shrink-0"});case"EXTERNAL_AUTH_REQUIRED":return e.jsx(l.KeyRound,{className:"w-5 h-5 flex-shrink-0"});case"NETWORK_ERROR":return e.jsx(l.WifiOff,{className:"w-5 h-5 flex-shrink-0"});default:return e.jsx(l.AlertCircle,{className:"w-5 h-5 flex-shrink-0"})}},xc=t=>{switch(t){case"ACCOUNT_DISABLED":return"bg-orange-500/10 border-orange-500/20 text-orange-600 dark:text-orange-400";case"ACCOUNT_LOCKED":return"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-400";case"EXTERNAL_AUTH_REQUIRED":return"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400";case"NETWORK_ERROR":return"bg-gray-500/10 border-gray-500/20 text-gray-600 dark:text-gray-400";default:return"bg-red-500/10 border-red-500/20 text-red-500"}};function hc(){const{t}=ne.useTranslation("auth"),{email:s,setEmail:r,password:a,setPassword:o,showPassword:c,setShowPassword:i,isLoading:d,loadingStep:u,error:m,handleSubmit:p}=uc();return e.jsxs("div",{className:"min-h-screen flex",children:[e.jsxs("div",{className:"hidden lg:flex lg:w-1/2 xl:w-[55%] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 animated-gradient"}),e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"radial-gradient(circle at 1px 1px, white 1px, transparent 0)",backgroundSize:"40px 40px"}}),e.jsx("div",{className:"absolute top-20 left-20 w-72 h-72 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-20 right-20 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/3 w-64 h-64 bg-white/5 rounded-full blur-2xl animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between p-12 xl:p-16 text-white w-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-7 h-7 text-white"})}),e.jsx("span",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-4xl xl:text-5xl font-bold leading-tight mb-6",children:t("login.heroTitle")}),e.jsx("p",{className:"text-xl text-white/80 mb-12",children:t("login.heroSubtitle")}),e.jsx("div",{className:"grid grid-cols-2 gap-6",children:mc.map(x=>e.jsxs("div",{className:"bg-white/10 backdrop-blur-sm rounded-2xl p-5 hover:bg-white/15 transition-colors",children:[e.jsx(x.icon,{className:"w-8 h-8 mb-3 text-white/90"}),e.jsx("h3",{className:"font-semibold mb-1",children:t(x.titleKey)}),e.jsx("p",{className:"text-sm text-white/70",children:t(x.descKey)})]},x.titleKey))})]}),e.jsxs("p",{className:"text-sm text-white/60",children:["© ",new Date().getFullYear()," SmartStack — ",t("login.tagline")]})]})]}),e.jsxs("div",{className:"w-full lg:w-1/2 xl:w-[45%] flex flex-col relative bg-[var(--bg-primary)]",children:[e.jsx("div",{className:"lg:hidden absolute inset-0",children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 rounded-full bg-primary-500/20 blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 rounded-full bg-accent-500/20 blur-3xl animate-pulse",style:{animationDelay:"1s"}})]})}),e.jsxs("div",{className:"absolute top-6 right-6 z-10 flex items-center gap-2",children:[e.jsx("a",{href:"/",className:"p-2 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-colors",title:t("login.backToHome"),children:e.jsx(l.Home,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx(Kt,{})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-6 sm:p-8 lg:p-12",children:e.jsxs("div",{className:"w-full max-w-md relative",children:[e.jsxs("div",{className:"lg:hidden flex flex-col items-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl animated-gradient flex items-center justify-center mb-4 shadow-lg",children:e.jsx(l.Layers,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"hidden lg:block mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold mb-2",children:t("login.welcome")}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("login.welcomeSubtitle")})]}),m&&e.jsxs("div",{className:`mb-6 p-4 rounded-xl border text-sm flex items-start gap-3 ${xc(m.code)}`,children:[pc(m.code),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:m.message}),m.code==="ACCOUNT_DISABLED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:t("login.contactSupport")}),m.code==="EXTERNAL_AUTH_REQUIRED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:t("login.useExternalAuth")})]})]}),e.jsxs("form",{onSubmit:p,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-2",children:t("login.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Mail,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"email",type:"email",value:s,onChange:x=>r(x.target.value),placeholder:t("login.emailPlaceholder"),required:!0,className:"w-full pl-12 pr-4 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-2",children:t("login.password")}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Lock,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"password",type:c?"text":"password",value:a,onChange:x=>o(x.target.value),placeholder:"••••••••",required:!0,className:"w-full pl-12 pr-12 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"}),e.jsx("button",{type:"button",onClick:()=>i(!c),className:"absolute right-4 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:c?e.jsx(l.EyeOff,{className:"w-5 h-5"}):e.jsx(l.Eye,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-tertiary)] text-primary-600 focus:ring-primary-500/20"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("login.rememberMe")})]}),e.jsx("a",{href:"/forgot-password",className:"text-primary-500 hover:text-primary-600 font-medium transition-colors",children:t("login.forgotPassword")})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full py-3.5 px-4 rounded-xl bg-primary-600 hover:bg-primary-700 disabled:bg-primary-600/50 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40 disabled:shadow-none flex items-center justify-center gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}),t(u==="auth"?"login.loading":"login.loadingPreferences")]}):t("login.submit")})]}),e.jsxs("div",{className:"relative my-8",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[var(--border-color)]"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-4 bg-[var(--bg-primary)] text-[var(--text-tertiary)]",children:t("login.or")})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/microsoft",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"#F25022"}),e.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"#7FBA00"}),e.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"#00A4EF"}),e.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"#FFB900"})]}),"Microsoft"]}),e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/google",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]})]}),e.jsxs("p",{className:"text-center text-[var(--text-secondary)] mt-8",children:[t("login.noAccount")," ",e.jsx("a",{href:"/register",className:"text-primary-500 hover:text-primary-600 font-semibold transition-colors",children:t("login.createAccount")})]})]})}),e.jsx("div",{className:"p-6 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("login.copyright",{year:new Date().getFullYear()})})})]})]})}function gc(){const{t}=ne.useTranslation("common"),s=w.useNavigate(),r=()=>{window.history.length>2?s(-1):s("/")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-md w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-6",children:e.jsx(l.FileWarning,{className:"w-8 h-8 text-yellow-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.notFound.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.notFound.description")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mb-6 font-mono",children:window.location.pathname}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:r,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),t("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),t("errors.home")]})]})]})})})}const fc=n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-BBaiBM--.js")).then(t=>({default:t.ApplicationsPage}))),bc=n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-I1yCk7tk.js")).then(t=>({default:t.NotificationsPage}))),vc=n.lazy(()=>Promise.resolve().then(()=>gi).then(t=>({default:t.PublicLayout}))),Zt=n.lazy(()=>Promise.resolve().then(()=>di).then(t=>({default:t.AppLayout}))),yc=n.lazy(()=>Promise.resolve().then(()=>require("./RegisterPage-CNyHSbqs.js")).then(t=>({default:t.RegisterPage}))),jc=n.lazy(()=>Promise.resolve().then(()=>require("./ConfirmEmailPage-D_8T1vqV.js")).then(t=>({default:t.ConfirmEmailPage}))),Nc=n.lazy(()=>Promise.resolve().then(()=>require("./ForgotPasswordPage-B4M6-xeM.js")).then(t=>({default:t.ForgotPasswordPage}))),wc=n.lazy(()=>Promise.resolve().then(()=>require("./ResetPasswordPage-JW8-mh_k.js")).then(t=>({default:t.ResetPasswordPage}))),Sc=n.lazy(()=>Promise.resolve().then(()=>require("./ForceChangePasswordPage-ZEIfyqwE.js")).then(t=>({default:t.ForceChangePasswordPage}))),Cc=n.lazy(()=>Promise.resolve().then(()=>require("./AuthCallbackPage-CzMHz4jy.js")).then(t=>({default:t.AuthCallbackPage}))),kc=n.lazy(()=>Promise.resolve().then(()=>require("./OnboardingWizardPage-DtWUPCh3.js")).then(t=>({default:t.OnboardingWizardPage}))),Ac={".detail":"/:id",".edit":"/:id/edit",".create":"/create",".new":"/new",".duplicate":"/:id/duplicate",".settings":"/:id/settings",".configure":"/:id/configure",".permissions":"/:id/permissions",".members":"/:id/members",".history":"/:id/history",".logs":"/:id/logs",".analytics":"/:id/analytics",".preview":"/:id/preview",".versions":"/:id/versions",".comments":"/:id/comments",".attachments":"/:id/attachments",".audit":"/:id/audit",".export":"/:id/export",".notifications":"/:id/notifications",".schedule":"/:id/schedule",".workflow":"/:id/workflow",".summary":"/:id/summary",".test":"/:id/test",".runs":"/:id/runs",".import":"/import"};function Cs(t,s){const r=[];for(const[a,o]of Object.entries(Ac)){const c=`${t}${a}`,i=O.resolve(c);if(i){const d=s.replace(/^\//,"")+o;r.push({path:d,Component:i})}}return r}function Pc(t,s,r,a){const o=[],c=r.route?.replace(`/${a}/`,"")||`${t.code}/${s.code}/${r.code}`,i=O.resolve(r.componentKey);if(i){const d=i;o.push(e.jsx(w.Route,{path:c,element:e.jsx(d,{})},r.componentKey))}if(r.route)for(const d of Cs(r.componentKey,c)){const u=d.Component;o.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${r.componentKey}-implicit-${d.path}`))}return o}function Tc(t,s,r){const a=[],o=s.route?.replace(`/${r}/`,"")||`${t.code}/${s.code}`,c=Jl[s.componentKey];if(c){const d=O.resolve(s.componentKey);if(d){const u=c.tabs.map(m=>{const p=`${s.componentKey}.${m}`,x=O.resolve(p);return x?e.jsx(w.Route,{path:m,element:e.jsx(x,{})},p):null}).filter(Boolean);return a.push(e.jsxs(w.Route,{path:o,element:e.jsx(d,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:c.defaultTab,replace:!0})}),u]},s.componentKey)),a}}const i=O.resolve(s.componentKey);if(i){const d=i;a.push(e.jsx(w.Route,{path:o,element:e.jsx(d,{})},s.componentKey))}if(!i&&s.resources.length>0){const d=s.resources[0];a.push(e.jsx(w.Route,{path:o,element:e.jsx(w.Navigate,{to:d.code,replace:!0})},`${s.componentKey}-redirect`))}if(s.route)for(const d of Cs(s.componentKey,o)){const u=d.Component;a.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${s.componentKey}-implicit-${d.path}`))}for(const d of s.resources){const u=Pc(t,s,d,r);a.push(...u)}return a}function Rc(t,s){const r=[],a=t.route?.replace(`/${s}/`,"")||t.code,o=O.resolve(t.componentKey);if(o){const c=o;r.push(e.jsx(w.Route,{path:a,element:e.jsx(c,{})},t.componentKey))}if(!o&&t.sections.length>0){const c=t.sections[0];r.push(e.jsx(w.Route,{path:a,element:e.jsx(w.Navigate,{to:c.code,replace:!0})},`${t.componentKey}-redirect`))}if(t.route)for(const c of Cs(t.componentKey,a)){const i=c.Component;r.push(e.jsx(w.Route,{path:c.path,element:e.jsx(i,{})},`${t.componentKey}-implicit-${c.path}`))}for(const c of t.sections){const i=Tc(t,c,s);r.push(...i)}return r}function Ec(t){const s=[],r=O.resolve(t.componentKey);if(r){const a=r;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(a,{})},`${t.code}-index`))}else if(t.modules.length>0){const a=t.modules[0],o=a.route?.replace(/^\//,"").replace(new RegExp(`^${t.code}/?`),"")||a.code;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:o,replace:!0})},`${t.code}-index`))}for(const a of t.modules){const o=Rc(a,t.code);a.requiredFeature?s.push(e.jsx(w.Route,{element:e.jsx(Ss,{feature:a.requiredFeature}),children:o},`feature-${a.componentKey}`)):s.push(...o)}return s}function Ic(t,s){return t.requiredFeature?[e.jsx(w.Route,{element:e.jsx(Ss,{feature:t.requiredFeature}),children:s},`feature-${t.code}`)]:s}function Lc(t){switch(t){case"administration":return[e.jsx(w.Route,{path:"settings",element:e.jsx(w.Navigate,{to:"../configuration/settings",relative:"path",replace:!0})},"legacy-settings"),e.jsx(w.Route,{path:"settings/*",element:e.jsx(Oe,{to:"/administration/configuration/settings"})},"legacy-settings-wc"),e.jsx(w.Route,{path:"appsettings",element:e.jsx(w.Navigate,{to:"../configuration/appsettings",relative:"path",replace:!0})},"legacy-appsettings"),e.jsx(w.Route,{path:"appsettings/*",element:e.jsx(Oe,{to:"/administration/configuration/appsettings"})},"legacy-appsettings-wc"),e.jsx(w.Route,{path:"email-templates",element:e.jsx(w.Navigate,{to:"../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates"),e.jsx(w.Route,{path:"email-templates/list",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates-list"),e.jsx(w.Route,{path:"email-templates/create",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates/create",relative:"path",replace:!0})},"legacy-email-templates-create"),e.jsx(w.Route,{path:"workflows/templates",element:e.jsx(w.Navigate,{to:"../email-templates",relative:"path",replace:!0})},"legacy-wf-templates"),e.jsx(w.Route,{path:"workflows/templates/*",element:e.jsx(Oe,{to:"/administration/workflows/email-templates"})},"legacy-wf-templates-wc"),e.jsx(w.Route,{path:"tenants/business",element:e.jsx(w.Navigate,{to:"../tenants/list/enterprise",replace:!0})},"legacy-tenants-biz"),e.jsx(w.Route,{path:"tenants/personal",element:e.jsx(w.Navigate,{to:"../tenants/list/personal",replace:!0})},"legacy-tenants-perso")];case"support":return[e.jsx(w.Route,{path:"dashboard",element:e.jsx(w.Navigate,{to:"tickets",replace:!0})},"legacy-dashboard"),e.jsx(w.Route,{path:"sla",element:e.jsx(w.Navigate,{to:"admin/sla",replace:!0})},"legacy-sla"),e.jsx(w.Route,{path:"templates",element:e.jsx(w.Navigate,{to:"admin/templates",replace:!0})},"legacy-templates"),e.jsx(w.Route,{path:"admin/escalation",element:e.jsx(w.Navigate,{to:"tickets/escalation",replace:!0})},"legacy-admin-esc")];default:return[]}}function $c(){const{isLoading:t,menu:s}=Ce(),{currentTenant:r}=Ee(),{user:a}=Pe(),o=w.useLocation();if(t)return e.jsx(Nt,{});const c=o.pathname.split("/").filter(Boolean),i=c[0]==="t"?c.slice(2):c,d=i.slice(0,2).join("."),u=r?.slug?`/t/${r.slug}/applications`:"/applications",m=i[0]?.toLowerCase(),x=(m?s?.applications.some(f=>f.code?.toLowerCase()===m)??!1:!1)?"permission":"tenant";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(jt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:x,tenantName:r?.name,permissionPath:d||void 0,applicationsUrl:u,userRoles:a?.roles,userPermissions:a?.permissions})})})]})}function Dc(){const{isLoading:t}=Ce();return!!localStorage.getItem("token")&&t?e.jsx(Nt,{}):e.jsx(gc,{})}function Mc(){const{menu:t,isLoading:s}=Ce(),r=n.useMemo(()=>!t||s?[]:t.applications.map(o=>{const c=o.route?.replace(/^\//,"")||o.code,i=Ec(o),d=Ic(o,i),u=Lc(o.code);return e.jsxs(w.Route,{path:c,element:e.jsx(Zt,{}),children:[d,u]},o.code)}),[t,s]),a=e.jsx(e.Fragment,{children:e.jsx(w.Route,{element:e.jsx(ka,{}),children:e.jsxs(w.Route,{element:e.jsx(Aa,{}),children:[r,e.jsx(w.Route,{path:"applications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(fc,{})})}),e.jsx(w.Route,{path:"notifications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(bc,{})})}),e.jsx(w.Route,{path:"administration/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"administration/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"support-client",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"support-client/*",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"user",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"user/*",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"*",element:e.jsx($c,{})})]})})});return e.jsxs(n.Suspense,{fallback:e.jsx(Nt,{}),children:[e.jsx(Qi,{}),e.jsx(tl,{}),e.jsxs(w.Routes,{children:[e.jsx(w.Route,{path:"/",element:e.jsx(vc,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(tc,{})})}),Yl(),e.jsx(w.Route,{path:"/login",element:e.jsx(hc,{})}),e.jsx(w.Route,{path:"/register",element:e.jsx(yc,{})}),e.jsx(w.Route,{path:"/confirm-email",element:e.jsx(jc,{})}),e.jsx(w.Route,{path:"/forgot-password",element:e.jsx(Nc,{})}),e.jsx(w.Route,{path:"/reset-password",element:e.jsx(wc,{})}),e.jsx(w.Route,{path:"/force-change-password",element:e.jsx(Sc,{})}),e.jsx(w.Route,{path:"/auth/callback",element:e.jsx(Cc,{})}),e.jsx(w.Route,{path:"/auth/onboarding",element:e.jsx(kc,{})}),e.jsx(w.Route,{path:"/t/:slug",element:e.jsx(Hs,{}),children:a}),e.jsx(w.Route,{element:e.jsx(Hs,{}),children:a}),e.jsx(w.Route,{path:"/admin",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/admin/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/administration/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/support/*",element:e.jsx(w.Navigate,{to:"/support",replace:!0})}),e.jsx(w.Route,{path:"/dashboard",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/business",element:e.jsx(w.Navigate,{to:"/applications",replace:!0})}),e.jsx(w.Route,{path:"/business/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"*",element:e.jsx(Dc,{})})]})]})}function Xs({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Oc(t,s){return t?"bg-[var(--color-accent-100)] border border-[var(--color-accent-500)]":s?"opacity-50 cursor-not-allowed bg-[var(--bg-secondary)]":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-transparent hover:border-[var(--border-color)]"}function Ra({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["common","navigation"]),{menu:a}=Ce(),{favorites:o,toggleFavorite:c,isFavorite:i,canAddMore:d,maxFavorites:u}=Ke();if(!t)return null;const m=[];a?.applications.forEach(x=>{(x.modules?.length??0)>0&&m.push({app:x,modules:x.modules})});const p=(x,f)=>{const b=[...x.sections||[]].sort((h,j)=>h.displayOrder-j.displayOrder),g=b.length>0&&b[0].route?b[0].route:`/${f.code}/${x.code}`,y={id:x.id,code:x.code,label:x.label,icon:x.icon||"Star",route:g,applicationCode:f.code,applicationLabel:f.label};c(y)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-modal)] shadow-xl w-full max-w-lg max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),r("common:favorites.manageTitle")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r("common:favorites.selectModules",{count:o.length,max:u})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{const x={component:"FavoritesModal",url:window.location.href},f=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent("[Bug] Favorites Modal")}&body=${encodeURIComponent(`## Context
30
+ - Component: ${x.component}
31
+ - URL: ${x.url}
32
32
 
33
33
  ## Description
34
34
 
@@ -43,6 +43,6 @@ ${v.join(`
43
43
  ## Expected Behavior
44
44
 
45
45
  ## Actual Behavior
46
- `)}`;window.open(f,"_blank")},className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors text-[var(--text-secondary)]",title:r("common:buttons.reportBug"),children:e.jsx(l.Bug,{className:"w-5 h-5"})}),e.jsx("button",{onClick:s,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[m.map(({app:g,modules:f})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ws,{name:g.icon||"Folder",className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:g.label})]}),e.jsx("div",{className:"space-y-1 ml-6",children:f.map(b=>{const h=i(b.id),y=!h&&!d;return e.jsxs("button",{onClick:()=>p(b,g),disabled:y,className:`w-full flex items-center gap-3 p-2.5 rounded-[var(--radius-button)] transition-all ${Mc(h,y)}`,children:[e.jsx("div",{className:`w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] ${h?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:e.jsx(Ws,{name:b.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:`flex-1 text-left text-sm ${h?"font-medium text-[var(--color-accent-700)]":"text-[var(--text-primary)]"}`,children:b.label}),h&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-600)]"})]},b.id)})})]},g.id)),m.length===0&&e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:r("common:favorites.noModules")})]}),e.jsx("div",{className:"p-4 border-t border-[var(--border-color)]",children:e.jsx("button",{onClick:s,className:"w-full px-4 py-2 bg-[var(--color-accent-600)] text-white rounded-[var(--radius-button)] hover:bg-[var(--color-accent-700)] transition-colors font-medium",children:r("common:actions.done")})})]})})}function Oc({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Fc({className:t=""}){const{t:s}=ne.useTranslation(["common"]),r=w.useNavigate(),{favorites:a,maxFavorites:o}=Ke(),{triggerExpand:c}=Ke(),{menu:i}=Ce(),[d,u]=n.useState(!1),m=o-a.length,p=f=>{if(i)for(const b of i.applications){const h=b.modules.find(y=>y.id===f.id);if(h?.sections?.length){const y=[...h.sections].sort((x,j)=>x.displayOrder-j.displayOrder)[0];if(y.route)return y.route}}return f.route},g=f=>{const b=p(f);b&&(c(),r(b))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("common:favorites.quickAccess")})]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] rounded-[var(--radius-button)] transition-colors",children:[e.jsx(l.Settings2,{className:"w-3.5 h-3.5"}),s("common:favorites.manage")]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1",children:[a.map(f=>e.jsxs("button",{onClick:()=>g(f),className:"flex flex-col items-center gap-1.5 min-w-[80px] p-3 bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-all group",title:`${f.applicationLabel} - ${f.label}`,children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--color-accent-100)] text-[var(--color-accent-600)] group-hover:bg-[var(--color-accent-600)] group-hover:text-white transition-colors",children:e.jsx(Oc,{name:f.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] truncate max-w-[70px]",children:f.label})]},f.id)),Array.from({length:m}).map((f,b)=>e.jsxs("button",{onClick:()=>u(!0),className:"flex flex-col items-center justify-center gap-1.5 min-w-[80px] p-3 border-2 border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--bg-tertiary)] text-[var(--text-muted)] group-hover:bg-[var(--color-accent-100)] group-hover:text-[var(--color-accent-600)] transition-colors",children:e.jsx(l.Plus,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]",children:s("common:favorites.add")})]},`empty-slot-${b}`))]})]}),e.jsx(Pa,{isOpen:d,onClose:()=>u(!1)})]})}function _c({activities:t,loading:s=!1}){return s?e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(r=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-8 h-8 bg-[var(--bg-secondary)] rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-[var(--bg-secondary)] rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-[var(--bg-secondary)] rounded w-1/4"})]})]},`skeleton-${r}`))}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(l.RefreshCcw,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No activity recorded yet"})]}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-4",children:t.map((r,a)=>e.jsx(qc,{activity:r,isLast:a===t.length-1},r.id))})]})}function qc({activity:t,isLast:s}){const{icon:r,color:a,bgColor:o}=Bc(t.action),c=r;return e.jsxs("div",{className:"relative flex gap-4 pl-0",children:[e.jsx("div",{className:`relative z-10 w-8 h-8 rounded-full flex items-center justify-center ${o}`,children:e.jsx(c,{className:`w-4 h-4 ${a}`})}),e.jsx("div",{className:"flex-1 pb-4 ",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm",children:[t.changedByUserName?e.jsx("span",{className:"font-medium",children:t.changedByUserName}):e.jsx("span",{className:"font-medium text-[var(--text-secondary)]",children:"System"})," ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:Zc(t)})]}),t.fieldChanged&&t.oldValue&&t.newValue&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 bg-[var(--error-bg)] text-[var(--error-text)] rounded line-through",children:t.oldValue}),e.jsx(l.ArrowRight,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"px-2 py-0.5 bg-[var(--success-bg)] text-[var(--success-text)] rounded",children:t.newValue})]})]}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] whitespace-nowrap",children:ed(t.createdAt)})]})})]})}const Uc={Created:{icon:l.PlusCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},StatusChanged:{icon:l.RefreshCcw,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},PriorityChanged:{icon:l.AlertTriangle,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},Assigned:{icon:l.UserPlus,color:"text-[var(--accent-text)]",bgColor:"bg-[var(--accent-bg)]"},Commented:{icon:l.MessageSquare,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},AttachmentAdded:{icon:l.Paperclip,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Resolved:{icon:l.CheckCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},Closed:{icon:l.XCircle,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Reopened:{icon:l.RefreshCcw,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},SlaBreached:{icon:l.AlertTriangle,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Escalated:{icon:l.TrendingUp,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Updated:{icon:l.Edit,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},Deleted:{icon:l.Trash2,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},OnHold:{icon:l.Pause,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},InProgress:{icon:l.Play,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"}},zc={icon:l.RefreshCcw,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"};function Bc(t){return Uc[t]||zc}const Gc=t=>t.oldValue&&t.newValue?`changed status from ${t.oldValue} to ${t.newValue}`:"changed the status",Kc=t=>t.oldValue&&t.newValue?`changed priority from ${t.oldValue} to ${t.newValue}`:"changed the priority",Hc=t=>t.newValue?`assigned to ${t.newValue}`:"unassigned the ticket",Vc=t=>t.newValue==="internal"?"added an internal note":"added a comment",Wc=t=>t.newValue?`added attachment: ${t.newValue}`:"added an attachment",Xc=t=>t.newValue==="response"?"Response SLA was breached":"Resolution SLA was breached",Yc=t=>t.newValue?`escalated to ${t.newValue}`:"escalated this ticket",Jc=t=>t.fieldChanged?`updated ${t.fieldChanged}`:"updated the ticket",Qc={Created:()=>"created this ticket",StatusChanged:Gc,PriorityChanged:Kc,Assigned:Hc,Commented:Vc,AttachmentAdded:Wc,Resolved:()=>"resolved this ticket",Closed:()=>"closed this ticket",Reopened:()=>"reopened this ticket",SlaBreached:Xc,Escalated:Yc,Updated:Jc,OnHold:()=>"put this ticket on hold",InProgress:()=>"started working on this ticket"};function Zc(t){const s=Qc[t.action];return s?s(t):t.action.toLowerCase()}function ed(t){const s=new Date(t),a=new Date().getTime()-s.getTime(),o=Math.floor(a/6e4),c=Math.floor(o/60),i=Math.floor(c/24);return o<1?"Just now":o<60?`${o}m ago`:c<24?`${c}h ago`:i<7?`${i}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function td({responseDueAt:t,resolutionDueAt:s,responseBreached:r,resolutionBreached:a,firstResponseAt:o,isPaused:c,responseSlaPercentage:i=0,resolutionSlaPercentage:d=0,showDetails:u=!1}){const m=new Date,p=new Date(t),g=new Date(s),f=p.getTime()-m.getTime(),b=g.getTime()-m.getTime(),h=!!o;let y="ok",x="green",j=l.CheckCircle;c?(y="paused",x="gray",j=l.Pause):r||a?(y="breached",x="red",j=l.XCircle):(!h&&f<1800*1e3||b<3600*1e3)&&(y="warning",x="yellow",j=l.AlertTriangle);const v={green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",gray:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return u?e.jsxs("div",{className:`p-3 rounded-lg border ${v[x]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Response"}),r&&e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}),!r&&h&&e.jsx("span",{className:"text-[var(--success-text)] font-medium",children:"Completed"}),!r&&!h&&e.jsx("span",{children:Ys(f)})]}),!h&&!r&&e.jsx(Xs,{percentage:i})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Resolution"}),a?e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}):e.jsx("span",{children:Ys(b)})]}),!a&&e.jsx(Xs,{percentage:d})]})]})]}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ${v[x]}`,children:[e.jsx(j,{className:"w-3 h-3"}),y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})}function Xs({percentage:t}){const s=()=>t>=90?"bg-[var(--error-text)]":t>=75?"bg-[var(--warning-text)]":"bg-[var(--success-text)]";return e.jsx("div",{className:"h-1.5 bg-white/50 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${s()}`,style:{width:`${Math.min(t,100)}%`}})})}function Ys(t){if(t<=0)return"Overdue";const s=Math.floor(t/(1e3*60)),r=Math.floor(s/60),a=Math.floor(r/24);if(a>0){const o=r%24;return o>0?`${a}d ${o}h`:`${a}d`}if(r>0){const o=s%60;return o>0?`${r}h ${o}m`:`${r}h`}return`${s}m`}const Js={Greeting:"bg-[var(--info-bg)] text-[var(--info-text)]",Acknowledgment:"bg-[var(--success-bg)] text-[var(--success-text)]",RequestInfo:"bg-[var(--warning-bg)] text-[var(--warning-text)]",InProgress:"bg-[var(--info-bg)] text-[var(--info-text)]",Resolution:"bg-[var(--accent-bg)] text-[var(--accent-text)]",Escalation:"bg-[var(--warning-bg)] text-[var(--warning-text)]",OnHold:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Closure:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Rejection:"bg-[var(--error-bg)] text-[var(--error-text)]",General:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"},sd=[{code:"fr",label:"Français"},{code:"en",label:"English"},{code:"de",label:"Deutsch"},{code:"it",label:"Italiano"}];function rd({isOpen:t,onClose:s,onSelect:r,ticketVariables:a}){const{t:o,i18n:c}=ne.useTranslation("support"),[i,d]=n.useState([]),[u,m]=n.useState(!1),[p,g]=n.useState(null),[f,b]=n.useState(""),[h,y]=n.useState(""),[x,j]=n.useState(c.language?.substring(0,2)||"fr"),[v,S]=n.useState([]),N=n.useCallback(A=>{m(!0),Promise.all([Lt.getAll(void 0,!0,A),Lt.getCategories()]).then(([R,$])=>{d(R),S($)}).catch(console.error).finally(()=>m(!1))},[]);n.useEffect(()=>{t&&(j(c.language?.substring(0,2)||"fr"),N(c.language?.substring(0,2)||"fr"))},[t,c.language,N]);const I=A=>{j(A),N(A)};if(!t)return null;const P=i.filter(A=>{const R=!f||A.title.toLowerCase().includes(f.toLowerCase())||A.content.toLowerCase().includes(f.toLowerCase()),$=!h||A.category===h;return R&&$}),k=async A=>{try{g(A.id);const R=await Lt.render(A.id,a);r(R.content),s()}catch(R){console.error("Failed to render template:",R)}finally{g(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:s,onKeyDown:A=>A.key==="Escape"&&s(),role:"presentation",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-xl shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:A=>A.stopPropagation(),role:"presentation",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-[var(--color-primary-500)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:o("templatePicker.title")})]}),e.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-[var(--bg-secondary)]",children:e.jsx(l.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("div",{className:"flex gap-1",children:sd.map(A=>e.jsx("button",{onClick:()=>I(A.code),className:`px-2 py-1 text-xs rounded transition-colors ${x===A.code?"bg-[var(--color-primary-500)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:A.label},A.code))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(l.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:f,onChange:A=>b(A.target.value),placeholder:o("templatePicker.searchPlaceholder"),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg outline-none focus:ring-1 focus:ring-[var(--color-primary-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("button",{onClick:()=>y(""),className:`px-2 py-1 text-xs rounded-full transition-colors ${h?"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]":"bg-[var(--color-primary-500)] text-white"}`,children:o("templatePicker.allCategories")}),v.map(A=>e.jsx("button",{onClick:()=>y(A===h?"":A),className:`px-2 py-1 text-xs rounded-full transition-colors ${A===h?"bg-[var(--color-primary-500)] text-white":`${Js[A]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"} hover:opacity-80`}`,children:o(`templates.categories.${A}`,{defaultValue:A})},A))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}),!u&&P.length===0&&e.jsx("p",{className:"text-center py-8 text-sm text-[var(--text-tertiary)]",children:o("templatePicker.noResults")}),!u&&P.length>0&&e.jsx("div",{className:"space-y-1",children:P.map(A=>e.jsxs("button",{onClick:()=>k(A),disabled:p!==null,className:"w-full text-left p-3 rounded-lg hover:bg-[var(--bg-secondary)] transition-colors group disabled:opacity-50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full ${Js[A.category]||"bg-[var(--bg-secondary)]"}`,children:o(`templates.categories.${A.category}`,{defaultValue:A.category})}),e.jsx("span",{className:"font-medium text-sm text-[var(--text-primary)]",children:A.title}),p===A.id&&e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin ml-auto"})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] line-clamp-2",children:A.content})]},A.id))})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)]",children:e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center",children:o("templatePicker.selectTemplate")})})]})})}const Qs={Created:{icon:l.Clock,color:"var(--color-primary-500)",labelKey:"history.actions.Created"},StatusChanged:{icon:l.ArrowRightLeft,color:"var(--info-text)",labelKey:"history.actions.StatusChanged"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)",labelKey:"history.actions.PriorityChanged"},Assigned:{icon:l.UserPlus,color:"var(--success-text)",labelKey:"history.actions.Assigned"},Unassigned:{icon:l.UserPlus,color:"var(--text-secondary)",labelKey:"history.actions.Unassigned"},Commented:{icon:l.MessageSquare,color:"var(--color-primary-500)",labelKey:"history.actions.Commented"},InternalCommented:{icon:l.MessageSquare,color:"var(--warning-text)",labelKey:"history.actions.InternalCommented"},AttachmentAdded:{icon:l.Paperclip,color:"var(--success-text)",labelKey:"history.actions.AttachmentAdded"},AttachmentRemoved:{icon:l.Paperclip,color:"var(--error-text)",labelKey:"history.actions.AttachmentRemoved"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.Resolved"},Closed:{icon:l.XCircle,color:"var(--text-secondary)",labelKey:"history.actions.Closed"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)",labelKey:"history.actions.Reopened"},Rejected:{icon:l.XCircle,color:"var(--error-text)",labelKey:"history.actions.Rejected"},SlaResponseBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResponseBreached"},SlaResolutionBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResolutionBreached"},Escalated:{icon:l.ArrowRightLeft,color:"var(--warning-text)",labelKey:"history.actions.Escalated"},TitleChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.TitleChanged"},DescriptionChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.DescriptionChanged"},TypeChanged:{icon:l.ArrowRightLeft,color:"var(--text-secondary)",labelKey:"history.actions.TypeChanged"},SatisfactionSubmitted:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.SatisfactionSubmitted"}},Ta=(t,s,r)=>{const a=new Date(t),c=new Date().getTime()-a.getTime(),i=Math.floor(c/6e4),d=Math.floor(c/36e5),u=Math.floor(c/864e5);return i<1?s("history.timeAgo.now"):i<60?s("history.timeAgo.minutes",{count:i}):d<24?s("history.timeAgo.hours",{count:d}):u<7?s("history.timeAgo.days",{count:u}):a.toLocaleDateString(r,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})},ad=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,Zs=t=>t?.startsWith("image/")||!1,nd=(t,s)=>t?"px-4 py-2.5 shadow-sm rounded-2xl bg-[var(--warning-bg)] border border-[var(--warning-border)]":s?"px-4 py-2.5 shadow-sm rounded-2xl rounded-tr-md bg-[var(--color-accent-600)] text-white":"px-4 py-2.5 shadow-sm rounded-2xl rounded-tl-md bg-[var(--bg-card)] border border-[var(--border-color)]";function od(t,s,r){const a=[];(r?t:t.filter(i=>!i.isInternal)).forEach(i=>{a.push({type:"comment",id:`comment-${i.id}`,timestamp:new Date(i.createdAt),data:i})});const c=["Commented","InternalCommented"];return s.filter(i=>!c.includes(i.action)).forEach(i=>{a.push({type:"activity",id:`activity-${i.id}`,timestamp:new Date(i.createdAt),data:i})}),a.sort((i,d)=>i.timestamp.getTime()-d.timestamp.getTime()),a}function id({activity:t,t:s,locale:r}){const a=Qs[t.action]||Qs.Created,o=a.icon;return e.jsx("div",{className:"flex justify-center my-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm",children:[e.jsx(o,{className:"w-4 h-4",style:{color:a.color}}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s(a.labelKey)}),t.newValue&&t.action==="StatusChanged"&&e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["→ ",t.newValue]}),t.newValue&&t.action==="Assigned"&&e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t.newValue}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Ta(t.createdAt,s,r)})]})})}const ld=t=>{const s=t.trim().split(/\s+/);return s.length>=2?((s[0]?.at(0)??"")+(s.at(-1)?.at(0)??"")).toUpperCase():t.slice(0,2).toUpperCase()},cd=t=>{const s=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];let r=0;for(let a=0;a<t.length;a++)r=t.charCodeAt(a)+((r<<5)-r);return s[Math.abs(r)%s.length]};function er({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const g=new AbortController;return Se.get(t,{responseType:"blob",signal:g.signal}).then(f=>{if(p){const b=URL.createObjectURL(f.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,g.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Image,{className:"w-6 h-6 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}function dd({comment:t,isOwn:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:i,locale:d}){const[u,m]=n.useState(null),p=new Date(t.createdAt).getTime(),g=a.filter(x=>{const j=new Date(x.createdAt).getTime();return Math.abs(j-p)<6e4}),f=g.filter(x=>Zs(x.contentType)),b=g.filter(x=>!Zs(x.contentType)),h=ld(t.userName),y=cd(t.userName);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex gap-3 mb-4 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-white text-sm font-semibold shadow-sm",style:{backgroundColor:y},title:t.userName,children:h}),e.jsxs("div",{className:`flex flex-col max-w-[70%] ${s?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex items-center gap-2 mb-1 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t.userName}),r&&t.isInternal&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:i("conversation.internalNoteLabel")}),t.isEdited&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:i("conversation.edited")})]}),e.jsxs("div",{className:nd(t.isInternal||!1,s),children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:t.content}),f.length>0&&e.jsx("div",{className:`mt-3 grid gap-2 ${f.length>1?"grid-cols-2":"grid-cols-1"}`,children:f.map(x=>e.jsxs("button",{className:"relative cursor-pointer rounded-lg overflow-hidden group",onClick:()=>m(x),type:"button",children:[e.jsx(er,{src:o(x),alt:x.fileName,className:"w-full h-32 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},x.id))}),b.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:b.map(x=>e.jsxs("button",{onClick:()=>c(x),className:`flex items-center gap-2 w-full p-2 rounded-lg transition-colors ${s&&!t.isInternal?"bg-white/10 hover:bg-white/20":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:[e.jsx(l.FileText,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs truncate flex-1 text-left",children:x.fileName}),e.jsx("span",{className:"text-xs opacity-70",children:ad(x.fileSize)}),e.jsx(l.Download,{className:"w-3.5 h-3.5"})]},x.id))})]}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 px-1",children:Ta(t.createdAt,i,d)})]})]}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>m(null),onKeyDown:x=>x.key==="Escape"&&m(null),role:"presentation",children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] w-full",children:[e.jsx("button",{onClick:()=>m(null),className:"absolute -top-10 right-0 text-white hover:text-gray-300",children:e.jsx(l.X,{className:"w-6 h-6"})}),e.jsx(er,{src:o(u),alt:u?.fileName,className:"max-w-full max-h-[80vh] mx-auto object-contain rounded-lg",onClick:x=>x.stopPropagation()}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-4",children:[e.jsx("p",{className:"text-white text-sm",children:u.fileName}),e.jsxs("button",{onClick:x=>{x.stopPropagation(),c(u)},className:"btn btn-secondary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),i("conversation.download")]})]})]})})]})}const ud=(t,s,r)=>t?r("conversation.internalPlaceholder","Ajouter une note interne..."):s?r("conversation.supportPlaceholder","Répondre au client..."):r("conversation.clientPlaceholder","Écrire un message..."),md=t=>`flex items-end gap-2 rounded-xl border ${t?"border-[var(--warning-border)] bg-[var(--warning-bg)]/30":"border-[var(--border-color)] bg-[var(--bg-secondary)]"} p-2`,pd=(t,s)=>`p-2.5 rounded-lg transition-colors ${t?"bg-[var(--color-primary-600)] text-white hover:bg-[var(--color-primary-700)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"} disabled:opacity-50`;function xd({isConnected:t,commentCount:s,t:r}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.MessageSquare,{className:"w-5 h-5 text-[var(--color-accent-600)]"}),e.jsx("h2",{className:"font-semibold",children:r("conversation.title","Conversation")}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["(",s,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:r(t?"conversation.realtimeActive":"conversation.realtimeInactive"),children:[t?e.jsx(l.Wifi,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(l.WifiOff,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:`text-xs ${t?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:r(t?"conversation.live":"conversation.offline")})]})]})}function hd({t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-[var(--text-secondary)]",children:[e.jsx(l.MessageSquare,{className:"w-12 h-12 mb-3 opacity-50"}),e.jsx("p",{children:t("conversation.empty","Aucun message pour le moment")}),e.jsx("p",{className:"text-sm mt-1",children:t("conversation.startHint","Commencez la conversation ci-dessous")})]})}function gd({timeline:t,currentUserName:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,messagesEndRef:i,t:d,locale:u}){return e.jsxs(e.Fragment,{children:[t.map(m=>{if(m.type==="activity")return e.jsx(id,{activity:m.data,t:d,locale:u},m.id);const p=m.data,g=p.userName===s;return e.jsx(dd,{comment:p,isOwn:g,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:d,locale:u},m.id)}),e.jsx("div",{ref:i})]})}function fd({isInternalComment:t,onToggle:s,t:r}){return e.jsx("div",{className:"mb-2",children:e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a=>s(a.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:`text-sm ${t?"text-[var(--warning-text)] font-medium":"text-[var(--text-secondary)]"}`,children:r("conversation.internalNote","Note interne (invisible pour le client)")})]})})}function bd({newComment:t,onCommentChange:s,onKeyDown:r,onSend:a,isInternalComment:o,onInternalToggle:c,sending:i,isSupport:d,textareaRef:u,ticketVariables:m,onOpenTemplatePicker:p,t:g}){const f=t.trim();return e.jsxs("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-card)] p-3",children:[d&&e.jsx(fd,{isInternalComment:o,onToggle:c,t:g}),e.jsxs("div",{className:md(o),children:[e.jsx("textarea",{ref:u,value:t,onChange:b=>s(b.target.value),onKeyDown:r,placeholder:ud(o,d,g),className:"flex-1 bg-transparent border-none outline-none resize-none text-sm min-h-[24px] max-h-[150px] py-1 px-2",rows:1}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&m&&p&&e.jsx("button",{onClick:p,className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-primary-500)] hover:bg-[var(--bg-tertiary)] transition-colors",title:g("templatePicker.buttonTitle"),children:e.jsx(l.FileText,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,disabled:!f||i,className:pd(!!f),children:i?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Send,{className:"w-5 h-5"})})]})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-2 text-center",children:g("conversation.hint","Appuyez sur Entrée pour envoyer, Maj+Entrée pour un saut de ligne")})]})}function vd({t}){return e.jsx("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-secondary)] p-4 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t("conversation.closed","Ce ticket est fermé. Aucun nouveau message ne peut être ajouté.")})})}function Ra({comments:t,activities:s,attachments:r,isSupport:a,isClosed:o,isConnected:c,currentUserName:i,ticketVariables:d,onAddComment:u,onDownloadAttachment:m,getAttachmentUrl:p}){const{t:g,i18n:f}=ne.useTranslation("support"),[b,h]=n.useState(""),[y,x]=n.useState(!1),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useRef(null),P=n.useRef(null),k=od(t,s,a),A=t.filter(C=>a||!C.isInternal).length;n.useEffect(()=>{I.current?.scrollIntoView({behavior:"smooth"})},[k.length]),n.useEffect(()=>{P.current&&(P.current.style.height="auto",P.current.style.height=`${Math.min(P.current.scrollHeight,150)}px`)},[b]);const R=async()=>{if(!(!b.trim()||j))try{v(!0),await u(b,y),h(""),x(!1)}finally{v(!1)}},$=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),R())},q=C=>{h(D=>D?D+`
47
- `+C:C)};return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx(xd,{isConnected:c,commentCount:A,t:g}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 bg-[var(--bg-primary)]",children:k.length===0?e.jsx(hd,{t:g}):e.jsx(gd,{timeline:k,currentUserName:i,isSupport:a,attachments:r,getAttachmentUrl:p,onDownloadAttachment:m,messagesEndRef:I,t:g,locale:f.language})}),o?e.jsx(vd,{t:g}):e.jsx(bd,{newComment:b,onCommentChange:h,onKeyDown:$,onSend:R,isInternalComment:y,onInternalToggle:x,sending:j,isSupport:a,textareaRef:P,ticketVariables:d,onOpenTemplatePicker:a&&d?()=>N(!0):void 0,t:g}),d&&e.jsx(rd,{isOpen:S,onClose:()=>N(!1),onSelect:q,ticketVariables:d})]})}const tr=t=>{const s=t.contentType?.toLowerCase()||"",a=t.fileName.toLowerCase().split(".").pop()||"";if(s.startsWith("image/"))return"image";if(s==="application/pdf")return"pdf";if(s.startsWith("text/")||s==="application/json")return"text";if(s.startsWith("video/"))return"video";if(s.startsWith("audio/"))return"audio";const o=["png","jpg","jpeg","gif","webp","svg","bmp","ico"],c=["txt","csv","json","md","xml","log","html","css","js","ts"],i=["mp4","webm","ogg","mov","avi"],d=["mp3","wav","ogg","aac","m4a"];return o.includes(a)?"image":a==="pdf"?"pdf":c.includes(a)?"text":i.includes(a)?"video":d.includes(a)?"audio":"unknown"},sr=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`;function yd({attachment:t,getUrl:s,onClose:r,onDownload:a}){const{t:o}=ne.useTranslation("support"),[c,i]=n.useState(1),[d,u]=n.useState(0),[m,p]=n.useState(!0),[g,f]=n.useState(null),[b,h]=n.useState(null),[y,x]=n.useState(!1),[j,v]=n.useState(null),S=n.useRef(null),N=t?tr(t):"unknown";n.useEffect(()=>{if(S.current?.id===t?.id||(S.current=t,j&&URL.revokeObjectURL(j),i(1),u(0),p(!0),f(null),h(null),v(null),x(!1),!t))return;const $=tr(t),q=s(t),C=new AbortController;return $==="text"?Se.get(q,{signal:C.signal,responseType:"text"}).then(D=>{h(D.data),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="image"||$==="video"||$==="audio"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="pdf"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):p(!1),()=>{C.abort()}},[t,s,o]),n.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]),n.useEffect(()=>{if(!t)return;const $=q=>{q.key==="Escape"&&(y?x(!1):r()),(q.key==="+"||q.key==="=")&&(q.preventDefault(),i(C=>Math.min(C+.25,3))),q.key==="-"&&(q.preventDefault(),i(C=>Math.max(C-.25,.25))),q.key==="r"&&!q.ctrlKey&&!q.metaKey&&(q.preventDefault(),u(C=>(C+90)%360)),q.key==="f"&&(q.preventDefault(),x(C=>!C))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,y,r]);const I=n.useCallback(()=>i($=>Math.min($+.25,3)),[]),P=n.useCallback(()=>i($=>Math.max($-.25,.25)),[]),k=n.useCallback(()=>u($=>($+90)%360),[]);if(!t)return null;const A=()=>{if(m&&N!=="pdf"&&N!=="image"&&N!=="video"&&N!=="audio")return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(g)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 text-[var(--warning-text)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:g}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]});switch(N){case"image":return e.jsx("div",{className:"relative flex items-center justify-center h-full overflow-auto p-4",children:j?e.jsx("img",{src:j,alt:t.fileName,className:"max-w-none transition-transform duration-200",style:{transform:`scale(${c}) rotate(${d}deg)`,maxHeight:y?"90vh":"70vh"},onClick:$=>$.stopPropagation()}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"pdf":return e.jsx("div",{className:"h-full w-full",children:j?e.jsx("iframe",{src:`${j}#toolbar=1&navpanes=0`,className:"w-full h-full border-0 rounded",title:t.fileName}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"text":return e.jsx("div",{className:"h-full overflow-auto p-4",children:e.jsx("pre",{className:"text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words bg-[var(--bg-secondary)] p-4 rounded-lg",children:b})});case"video":return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:j?e.jsx("video",{src:j,controls:!0,className:"max-w-full max-h-[70vh] rounded-lg",children:o("filePreview.videoNotSupported","Votre navigateur ne supporte pas la lecture vidéo.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"audio":return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6 p-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[var(--color-accent-500)]/20 flex items-center justify-center",children:e.jsx(l.File,{className:"w-12 h-12 text-[var(--color-accent-500)]"})}),e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.fileName}),j?e.jsx("audio",{src:j,controls:!0,className:"w-full max-w-md",children:o("filePreview.audioNotSupported","Votre navigateur ne supporte pas la lecture audio.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})})]});default:return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(l.FileText,{className:"w-10 h-10 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)] mb-1",children:t.fileName}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:sr(t.fileSize)})]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o("filePreview.noPreview","Aperçu non disponible pour ce type de fichier")}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]})}},R=e.jsxs("div",{className:"fixed inset-0 bg-black/90 backdrop-blur-sm flex flex-col z-[100]",onClick:r,onKeyDown:$=>{$.key==="Escape"&&r()},role:"dialog","aria-modal":"true","aria-label":t.fileName,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50",onClick:$=>$.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-white/70 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.fileName}),e.jsx("p",{className:"text-xs text-white/50",children:sr(t.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomOut","Zoom arrière (-)")||"Zoom out",children:e.jsx(l.ZoomOut,{className:"w-5 h-5"})}),e.jsxs("span",{className:"text-white/70 text-sm min-w-[3rem] text-center",children:[Math.round(c*100),"%"]}),e.jsx("button",{onClick:I,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomIn","Zoom avant (+)")||"Zoom in",children:e.jsx(l.ZoomIn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:k,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.rotate","Rotation (R)")||"Rotate",children:e.jsx(l.RotateCw,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-1"})]}),e.jsx("button",{onClick:()=>x($=>!$),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.fullscreen","Plein écran (F)")||"Fullscreen",children:y?e.jsx(l.Minimize2,{className:"w-5 h-5"}):e.jsx(l.Maximize2,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>a(t),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("common.close","Fermer (Échap)")||"Close",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",onClick:$=>$.stopPropagation(),children:A()}),e.jsx("div",{className:"px-4 py-2 bg-black/50 text-center",onClick:$=>$.stopPropagation(),children:e.jsx("p",{className:"text-xs text-white/40",children:o("filePreview.shortcuts","Raccourcis: Échap pour fermer • +/- pour zoomer • R pour rotation • F pour plein écran")})})]});return Ft.createPortal(R,document.body)}const rr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},jd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,ar=t=>t?.startsWith("image/")||!1;function Nd({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const g=new AbortController;return Se.get(t,{responseType:"blob",signal:g.signal}).then(f=>{if(p){const b=URL.createObjectURL(f.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,g.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Image,{className:"w-4 h-4 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}const wd={Created:{icon:l.Plus,color:"var(--success-text)"},StatusChanged:{icon:l.Edit,color:"var(--info-text)"},Assigned:{icon:l.UserCheck,color:"var(--color-accent-600)"},Unassigned:{icon:l.User,color:"var(--warning-text)"},Commented:{icon:l.MessageSquare,color:"var(--text-secondary)"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)"},Closed:{icon:l.XCircle,color:"var(--text-tertiary)"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)"},Escalated:{icon:l.ArrowUpCircle,color:"var(--error-text)"},Started:{icon:l.Play,color:"var(--info-text)"},Paused:{icon:l.Pause,color:"var(--warning-text)"}},Sd=(t,s)=>{const r=new Date(t),o=new Date().getTime()-r.getTime(),c=Math.floor(o/6e4),i=Math.floor(o/36e5),d=Math.floor(o/864e5);return c<1?s("sidebar.timeAgo.justNow",{defaultValue:"Just now"}):c<60?s("sidebar.timeAgo.minutes",{count:c}):i<24?s("sidebar.timeAgo.hours",{count:i}):d<7?s("sidebar.timeAgo.days",{count:d}):r.toLocaleDateString(void 0,{day:"numeric",month:"short"})},Cd=10*1024*1024,nr=[".pdf",".doc",".docx",".xls",".xlsx",".txt",".csv",".zip",".png",".jpg",".jpeg",".gif",".webp"];function lt({section:t,icon:s,title:r,count:a,isExpanded:o,onToggle:c}){return e.jsxs("button",{onClick:()=>c(t),className:"w-full flex items-center gap-2 py-2 px-3 hover:bg-[var(--bg-secondary)] transition-colors rounded-lg",children:[o?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx(s,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-sm flex-1 text-left",children:r}),a!==void 0&&a>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:a})]})}function Ea({ticket:t,attachments:s,activities:r,isSupport:a,saving:o,uploading:c,layout:i="compact",onAssign:d,onStatusChange:u,onResolve:m,onCloseTicket:p,onReopen:g,onEscalate:f,onDownloadAttachment:b,onUploadAttachment:h,getAttachmentUrl:y}){const{t:x}=ne.useTranslation("support"),[j,v]=n.useState(new Set(i==="grid"?["info","system","errors","attachments","actions","history"]:["info","attachments","actions"])),[S,N]=n.useState(null),[I,P]=n.useState(!1),[k,A]=n.useState(null),R=n.useRef(null),$=n.useCallback(M=>{if(M.type.startsWith("image/"))return!0;const re="."+M.name.split(".").pop()?.toLowerCase();return nr.includes(re)},[]),q=n.useCallback(async M=>{if(!(!M||!h)){A(null);for(let re=0;re<M.length;re++){const F=M[re];if(F.size>Cd){A(x("sidebar.fileTooLarge","File too large (max 10 MB)"));continue}if(!$(F)){A(x("sidebar.fileTypeNotAllowed","File type not allowed"));continue}try{await h(F)}catch{A(x("sidebar.uploadError","Upload failed"))}}}},[h,$,x]),C=n.useCallback(M=>{M.preventDefault(),M.stopPropagation()},[]),D=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!0)},[]),Y=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1)},[]),T=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1),q(M.dataTransfer.files)},[q]),z=s.filter(M=>ar(M.contentType)),Z=s.filter(M=>!ar(M.contentType)),H=t.clientContext,J=n.useCallback(M=>{v(re=>{const F=new Set(re);return F.has(M)?F.delete(M):F.add(M),F})},[]),fe=t.status==="Closed"||t.status==="Rejected",B=i==="grid",Q=B?"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden":"px-2 py-1 border-b border-[var(--border-color)]";return e.jsxs("div",{className:B?"":"h-full flex flex-col bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("div",{className:B?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4":"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"info",icon:l.FileText,title:x("details.info","Informations"),isExpanded:j.has("info"),onToggle:J}),j.has("info")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.type","Type")}),e.jsx("dd",{className:"font-medium",children:x(`tickets.types.${t.type}`,{defaultValue:t.type})})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.priority","Priority")}),e.jsx("dd",{children:e.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:rr[t.priority]?.bg,color:rr[t.priority]?.text},children:x(`tickets.priorities.${t.priority}`,{defaultValue:t.priority})})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdBy","Created by")}),e.jsx("dd",{children:t.createdByName||x("sidebar.unknown","Unknown")})]}),e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.assignedTo","Assigned to")}),e.jsxs("dd",{className:"flex flex-col items-end gap-1",children:[(t?.assignees?.length??0)>0?e.jsx("div",{className:"space-y-1",children:t?.assignees?.map(M=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-sm",children:M.fullName}),M.isPrimary&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--color-accent-600)] text-white rounded-md",children:x("sidebar.primary","primary")}),M.assignedViaGroupName&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-secondary)] rounded-md",children:["(",x("sidebar.viaGroup",{groupName:M.assignedViaGroupName}),")"]})]},M.userId))}):e.jsx("span",{className:"text-sm",children:x("sidebar.unassigned","Unassigned")}),d&&e.jsx("button",{onClick:d,className:"p-1 hover:bg-[var(--bg-secondary)] rounded mt-1",children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdAt","Created")}),e.jsx("dd",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),t.updatedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.updatedAt","Updated")}),e.jsx("dd",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]})]})})]}),a&&H&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"system",icon:l.Monitor,title:x("details.systemInfo","Infos système"),isExpanded:j.has("system"),onToggle:J}),j.has("system")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[H?.sourceUrl&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.url","URL")]}),e.jsx("p",{className:"text-xs font-mono break-all",children:H.sourceUrl})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[H.browser&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.browser","Browser")]}),e.jsx("p",{className:"text-xs font-medium",children:H.browser.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.browser.version})]}),H.os&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Laptop,{className:"w-3 h-3"}),x("sidebar.os","OS")]}),e.jsx("p",{className:"text-xs font-medium",children:H.os.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.os.version})]})]}),H.device&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Smartphone,{className:"w-3 h-3"}),x("sidebar.device","Device")]}),e.jsxs("p",{className:"text-xs font-medium",children:[H.device.type||x("sidebar.defaultDeviceType","Desktop"),H.device.screenResolution&&` • ${H.device.screenResolution}`]})]})]})]}),a&&H&&(H?.recentErrors?.length??0)>0&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"errors",icon:l.Bug,title:x("details.errors","Erreurs"),count:H?.recentErrors?.length??0,isExpanded:j.has("errors"),onToggle:J}),j.has("errors")&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:H?.recentErrors?.slice(0,3).map((M,re)=>e.jsxs("div",{className:"p-2 bg-[var(--error-bg)]/30 border border-[var(--error-border)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(l.AlertTriangle,{className:"w-3 h-3 text-[var(--error-text)]"}),M.component&&e.jsx("span",{className:"text-xs px-1 py-0.5 bg-[var(--bg-secondary)] rounded",children:M.component})]}),e.jsx("p",{className:"text-xs font-medium text-[var(--error-text)] line-clamp-2",children:M.message})]},`error-${re}`))})]}),e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"attachments",icon:l.File,title:x("details.attachments","Pièces jointes"),count:s.length,isExpanded:j.has("attachments"),onToggle:J}),j.has("attachments")&&e.jsxs("div",{className:"px-3 pb-3",children:[z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.Image,{className:"w-3 h-3"}),x("sidebar.images","Images")," (",z.length,")"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:z.map(M=>e.jsxs("button",{type:"button",className:"relative cursor-pointer rounded overflow-hidden border border-[var(--border-color)] aspect-square group",onClick:()=>N(M),children:[e.jsx(Nd,{src:y(M),alt:M.fileName,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-5 h-5 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},M.id))})]}),Z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.FileText,{className:"w-3 h-3"}),x("sidebar.documents","Documents")," (",Z.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:Z.map(M=>e.jsxs("div",{className:"flex items-center gap-2 w-full p-2 bg-[var(--bg-secondary)] rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors group",children:[e.jsxs("button",{onClick:()=>N(M),className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[e.jsx(l.FileText,{className:"w-4 h-4 text-[var(--text-secondary)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs block truncate",children:M.fileName}),e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:jd(M.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>N(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors opacity-0 group-hover:opacity-100",title:x("filePreview.view","Aperçu")||"View",children:e.jsx(l.Eye,{className:"w-3.5 h-3.5 text-[var(--color-accent-500)]"})}),e.jsx("button",{onClick:()=>b(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors",title:x("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})]},M.id))})]}),a&&!fe&&h&&e.jsxs("div",{children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:M=>q(M.target.files),accept:nr.join(","),className:"hidden"}),e.jsx("div",{className:`border-2 border-dashed rounded-lg p-3 text-center transition-colors cursor-pointer ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)]"}`,onClick:()=>R.current?.click(),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),R.current?.click())},role:"button",tabIndex:0,onDragOver:C,onDragEnter:D,onDragLeave:Y,onDrop:T,children:c?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-1",children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:x("sidebar.uploading","Uploading...")})]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Plus,{className:"w-5 h-5 mx-auto mb-1 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:I?x("sidebar.dropHere","Drop here"):x("sidebar.addFile","Add a file")})]})}),k&&e.jsx("p",{className:"mt-2 text-xs text-[var(--error-text)]",children:k})]}),s.length===0&&(!a||fe||!h)&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center py-2",children:x("sidebar.noAttachments","No attachments")})]})]}),a&&!B&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"actions",icon:l.User,title:x("details.actions","Actions"),isExpanded:j.has("actions"),onToggle:J}),j.has("actions")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[t.status==="Open"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.startProcessing","Start processing")}),t.status==="InProgress"&&e.jsxs(e.Fragment,{children:[u&&e.jsx("button",{onClick:()=>u("OnHold"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.putOnHold","Put on hold")}),m&&e.jsxs("button",{onClick:m,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.resolve","Resolve")]})]}),t.status==="OnHold"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.resume","Resume")}),t.status==="Resolved"&&p&&e.jsxs("button",{onClick:p,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.XCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.closeTicket","Close ticket")]}),(t.status==="Closed"||t.status==="Resolved")&&g&&e.jsxs("button",{onClick:g,disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:[e.jsx(l.RotateCcw,{className:"w-4 h-4 mr-2"}),x("sidebar.reopen","Reopen")]}),!fe&&f&&e.jsxs("button",{onClick:f,disabled:o,className:"btn w-full text-sm py-2 border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.escalate","Escalate")]}),o&&e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-primary-600)]"})})]})]}),a&&r.length>0&&e.jsxs("div",{className:B?Q:"px-2 py-1",children:[e.jsx(lt,{section:"history",icon:l.History,title:x("details.history","History"),count:r.length,isExpanded:j.has("history"),onToggle:J}),j.has("history")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-2 bottom-2 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-3",children:r.slice(0,10).map((M,re)=>{const F=wd[M.action]||{icon:l.Edit,color:"var(--text-secondary)"},K=F.icon,V=x(`history.actions.${M.action}`,{defaultValue:M.action});return e.jsxs("div",{className:"relative flex gap-3 pl-1",children:[e.jsx("div",{className:"relative z-10 w-5 h-5 rounded-full flex items-center justify-center bg-[var(--bg-card)] border border-[var(--border-color)]",style:{color:F.color},children:e.jsx(K,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[var(--text-primary)]",children:[V,M.newValue&&e.jsxs("span",{className:"text-[var(--text-secondary)] font-normal",children:[" → ",M.newValue]})]}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:Sd(M.createdAt,x)})]})]},`activity-${M.action}-${re}`)})}),r.length>10&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center mt-3",children:x("sidebar.moreActivities",{count:r.length-10})})]})})]})]}),e.jsx(yd,{attachment:S,getUrl:y,onClose:()=>N(null),onDownload:b})]})}const es=["Open","InProgress","Resolved","Closed"],Je={Open:{label:"Ouvert",icon:l.Clock,color:"var(--warning-text)"},InProgress:{label:"En cours",icon:l.Play,color:"var(--info-text)"},OnHold:{label:"En attente",icon:l.Pause,color:"var(--warning-text)"},Resolved:{label:"Résolu",icon:l.CheckCircle,color:"var(--success-text)"},Closed:{label:"Fermé",icon:l.XCircle,color:"var(--text-secondary)"},Rejected:{label:"Rejeté",icon:l.AlertTriangle,color:"var(--error-text)"}},kd=t=>new Date(t).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),Ad=t=>t.isActive?"ring-4 ring-opacity-30":t.isPast?"bg-[var(--success-bg)]":"bg-[var(--bg-secondary)] border-2 border-[var(--border-color)]",Pd=(t,s)=>{if(t.isActive)return s.color;if(t.isPast)return"var(--success-bg)"},Td=(t,s)=>({backgroundColor:Pd(t,s),boxShadow:t.isActive?`0 0 0 4px ${s.color}30`:void 0}),Rd=t=>t.isActive?"white":t.isPast?"var(--success-text)":"var(--text-tertiary)",Ed=t=>t.isActive?"text-[var(--text-primary)]":t.isPast?"text-[var(--success-text)]":"text-[var(--text-tertiary)]",Id=(t,s)=>t.isPast?"var(--success-text)":t.isActive?s.color:"var(--border-color)";function Ld({step:t,config:s}){const r=t.icon;return e.jsx("div",{className:`relative w-10 h-10 rounded-full flex items-center justify-center shrink-0 transition-all ${Ad(t)}`,style:Td(t,s),children:e.jsx(r,{className:"w-5 h-5",style:{color:Rd(t)}})})}function $d({step:t}){return e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:`text-xs font-medium ${Ed(t)}`,children:t.label}),t.date&&(t.isActive||t.isPast)&&e.jsx("p",{className:"text-[10px] text-[var(--text-secondary)] mt-0.5",children:kd(t.date)})]})}function Dd({step:t,config:s,isLast:r}){return r?null:e.jsx("div",{className:"flex-1 h-0.5 mx-2 mt-[-20px]",style:{backgroundColor:Id(t,s)}})}function Md({currentStatus:t,createdAt:s,resolvedAt:r,closedAt:a,activities:o=[],isSupport:c,saving:i,assignees:d,onAssign:u,onStatusChange:m,onResolve:p,onCloseTicket:g,onReopen:f,onEscalate:b}){const{t:h}=ne.useTranslation("support"),y=t==="Rejected",x=o.some(S=>S.action==="Reopened"),v=(()=>{if(y)return[{status:"Open",label:h("tickets.statuses.Open",Je.Open.label),icon:Je.Open.icon,date:s,isActive:!1,isPast:!0,isFuture:!1},{status:"Rejected",label:h("tickets.statuses.Rejected",Je.Rejected.label),icon:Je.Rejected.icon,date:a,isActive:!0,isPast:!1,isFuture:!1}];const S=es.indexOf(t),N=[],I={Open:s};o.filter(k=>k.action==="StatusChanged"&&k.newValue).forEach(k=>{k.newValue&&(I[k.newValue]=k.createdAt)}),r&&(I.Resolved=r),a&&(I.Closed=a);const P=o.some(k=>k.action==="StatusChanged"&&k.newValue==="OnHold");if(es.forEach(k=>{const A=Je[k],R=k===t?S:es.indexOf(k),$=k===t,q=R<S,C=R>S;N.push({status:k,label:h(`tickets.statuses.${k}`,{defaultValue:A.label}),icon:A.icon,date:I[k],isActive:$,isPast:q,isFuture:C})}),P){const k=N.findIndex(A=>A.status==="Resolved");N.splice(k,0,{status:"OnHold",label:h("tickets.statuses.OnHold",Je.OnHold.label),icon:Je.OnHold.icon,date:I.OnHold,isActive:t==="OnHold",isPast:t!=="OnHold"&&t!=="Open"&&t!=="InProgress",isFuture:!1})}return N})();return e.jsx("div",{className:"w-full px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[v.map((S,N)=>{const I=Je[S.status],P=N===v.length-1;return e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:`flex flex-col items-center ${S.isFuture?"opacity-40":""}`,children:[e.jsx(Ld,{step:S,config:I}),e.jsx($d,{step:S})]}),e.jsx(Dd,{step:S,config:I,isLast:P})]},S.status)}),x&&e.jsxs("div",{className:"ml-2 flex items-center gap-1 text-[10px] text-[var(--warning-text)] shrink-0",children:[e.jsx(l.RotateCcw,{className:"w-3 h-3"}),e.jsx("span",{children:h("workflow.reopened","Réouvert")})]})]}),c&&e.jsx("div",{className:"w-px h-12 bg-[var(--border-color)] shrink-0"}),c&&e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[(d?.length??0)>0?e.jsxs("div",{className:"flex items-center -space-x-1.5",title:d?.map(S=>S.fullName).join(", "),children:[d?.slice(0,3).map(S=>e.jsx("div",{className:"w-7 h-7 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white text-[10px] font-medium border-2 border-[var(--bg-card)]",title:`${S.fullName}${S.isPrimary?` (${h("workflow.primary","principal")})`:""}${S.assignedViaGroupName?` (${h("workflow.viaGroup","via")} ${S.assignedViaGroupName})`:""}`,children:S.fullName.charAt(0).toUpperCase()},S.userId)),(d?.length??0)>3&&e.jsxs("div",{className:"w-7 h-7 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[10px] font-medium text-[var(--text-secondary)] border-2 border-[var(--bg-card)]",children:["+",(d?.length??0)-3]})]}):e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] italic",children:h("workflow.notAssigned","Non assigné")}),u&&e.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full border border-dashed border-[var(--border-color)] flex items-center justify-center hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-secondary)] transition-colors",title:h("workflow.assign","Assigner"),children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]}),i&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-primary-600)]"}),t==="Open"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.start","Commencer")]}),t==="InProgress"&&m&&e.jsxs("button",{onClick:()=>m("OnHold"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Pause,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.hold","En attente")]}),t==="InProgress"&&p&&e.jsxs("button",{onClick:p,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.CheckCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.resolve","Résoudre")]}),t==="OnHold"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.resume","Reprendre")]}),t==="Resolved"&&g&&e.jsxs("button",{onClick:g,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.XCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.close","Fermer")]}),(t==="Closed"||t==="Resolved")&&f&&e.jsxs("button",{onClick:f,disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.RotateCcw,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.reopen","Réouvrir")]}),t!=="Closed"&&t!=="Rejected"&&b&&e.jsxs("button",{onClick:b,disabled:i,className:"btn btn-sm text-xs border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.escalate","Escalader")]})]})]})})}const ct={Proposed:{border:"border-blue-500",bg:"bg-blue-50",text:"text-blue-900"},Approved:{border:"border-green-500",bg:"bg-green-50",text:"text-green-900"},Rejected:{border:"border-red-500",bg:"bg-red-50",text:"text-red-900"},Superseded:{border:"border-gray-400",bg:"bg-gray-50",text:"text-gray-700"}},or={Proposed:l.Clock,Approved:l.CheckCircle,Rejected:l.XCircle,Superseded:l.AlertCircle};function Od({ticketId:t,solutions:s,activeSolution:r,mode:a,onProposeSolution:o,onApproveSolution:c,onRejectSolution:i,isLoading:d}){const{t:u}=ne.useTranslation("support"),[m,p]=n.useState(!1),[g,f]=n.useState(""),[b,h]=n.useState(!1),[y,x]=n.useState(""),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useCallback(async()=>{if(!(!g.trim()||!o)){p(!0);try{await o(g),f("")}finally{p(!1)}}},[g,o]),P=n.useCallback(()=>{v(!0)},[]),k=n.useCallback(async()=>{if(!(!y.trim()||!i)){h(!0);try{await i(y),x(""),v(!1)}finally{h(!1)}}},[y,i]),A=R=>{if(!R.autoCloseAt)return null;const $=new Date(R.autoCloseAt),q=new Date,C=$.getTime()-q.getTime(),D=Math.ceil(C/(1e3*60*60*24));return D>0?D:0};return s.length===0&&a==="support"&&o?e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:g,onChange:R=>f(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!g.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:`rounded-lg border-2 p-4 ${ct[r.status].border} ${ct[r.status].bg}`,children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const R=or[r.status];return e.jsx(R,{className:`w-5 h-5 ${ct[r.status].text}`})})(),e.jsxs("div",{children:[e.jsx("h4",{className:`font-semibold ${ct[r.status].text}`,children:u(`solution.status.${r.status.toLowerCase()}`,r.status)}),e.jsxs("p",{className:"text-sm opacity-75",children:[u("solution.solutionNumber","Solution #"),r.solutionNumber," - ",u("solution.proposedBy","Proposed by")," ",r.proposedByUserName||"Unknown"]})]})]})}),e.jsx("div",{className:"bg-white/50 rounded p-3 mb-3 max-h-32 overflow-y-auto",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:r.content})}),r.status==="Proposed"&&r.autoCloseAt&&e.jsx("div",{className:"mb-3 p-2 bg-yellow-100/50 border-l-2 border-yellow-500 rounded",children:e.jsxs("p",{className:"text-sm",children:[u("solution.autoCloseWarning","Will be auto-approved in")," ",e.jsxs("strong",{children:[A(r)," ",u("solution.autoCloseCountdown","days")]}),r.autoCloseWarningSent&&e.jsxs(e.Fragment,{children:[" (",u("solution.warningEmailSent","warning email sent"),")"]})]})}),r.status==="Approved"&&e.jsxs("p",{className:"text-sm",children:[u("solution.approvedBy","Approved by")," ",r.approvedByUserName||"Unknown"," on ",r.approvedAt&&new Date(r.approvedAt).toLocaleDateString()]}),r.status==="Rejected"&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm mb-2",children:[u("solution.rejectedBy","Rejected by")," ",r.rejectedByUserName||"Unknown"," on ",r.rejectedAt&&new Date(r.rejectedAt).toLocaleDateString()]}),r.rejectionReason&&e.jsxs("p",{className:"text-sm bg-white/30 p-2 rounded italic",children:[u("solution.rejectionReason","Reason"),": ",r.rejectionReason]})]}),a==="client"&&r.status==="Proposed"&&e.jsxs("div",{className:"mt-3 flex gap-2 justify-end",children:[e.jsx("button",{onClick:P,disabled:b||d,className:"btn btn-secondary text-sm py-1.5",children:u("solution.rejectSolution","Reject")}),e.jsx("button",{onClick:c,disabled:b||d||!c,className:"btn btn-primary text-sm py-1.5 flex items-center gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}),u("solution.acceptSolution","Approve")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.CheckCircle,{className:"w-3 h-3"}),u("solution.acceptSolution","Approve")]})})]})]}),a==="support"&&o&&!r&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h4",{className:"font-semibold mb-3",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:g,onChange:R=>f(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!g.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}),s.length>1&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(!S),className:"w-full flex items-center gap-2 p-4 hover:bg-[var(--bg-secondary)] transition-colors",children:[S?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsxs("h4",{className:"font-semibold",children:[u("solution.solutionHistory","Solution History")," (",s.length,")"]})]}),S&&e.jsx("div",{className:"border-t border-[var(--border-color)] p-4 space-y-3",children:s.map(R=>e.jsxs("div",{className:`rounded-lg border p-3 ${ct[R.status].border}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const $=or[R.status];return e.jsx($,{className:`w-4 h-4 ${ct[R.status].text}`})})(),e.jsx("span",{className:"text-sm font-medium",children:u(`solution.status.${R.status.toLowerCase()}`,R.status)}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["#",R.solutionNumber]})]}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(R.proposedAt).toLocaleDateString()})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 line-clamp-2",children:R.content}),e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[u("solution.proposedBy","Proposed by")," ",R.proposedByUserName||"Unknown"]})]},R.id))})]}),s.length===0&&a==="client"&&e.jsx("div",{className:"text-center py-6 text-[var(--text-tertiary)]",children:e.jsx("p",{children:u("solution.noSolutions","No solutions proposed yet")})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg shadow-lg p-6 w-96 max-w-[90vw]",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.rejectSolution","Reject Solution")}),e.jsx("textarea",{value:y,onChange:R=>x(R.target.value),placeholder:u("solution.enterRejectReason","Enter reason for rejection..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:b}),e.jsxs("div",{className:"mt-4 flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>v(!1),disabled:b,className:"btn btn-secondary",children:u("common:cancel","Cancel")}),e.jsx("button",{onClick:k,disabled:!y.trim()||b,className:"btn btn-primary flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.rejectSolution","Reject")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),u("solution.rejectSolution","Reject")]})})]})]})})]})}const Fd={getCached:t=>E.get(`/api/support/ai-routing/cached/${t}`)},Ia={analyze:t=>E.get(`/api/support/ai-routing/analyze/${t}`)},La={summarize:t=>E.post(`/api/support/ai-routing/summarize/${t}`)},$a={applyRouting:(t,s)=>E.post(`/api/support/ai-routing/apply/${t}`,s)},ir=Object.freeze(Object.defineProperty({__proto__:null,analyzeApi:Ia,cachedAiApi:Fd,routingApi:$a,summarizeApi:La},Symbol.toStringTag,{value:"Module"}));function Da({classification:t}){const{t:s}=ne.useTranslation("support");if(!t)return null;const r=o=>o>.8?"bg-[var(--success-bg)] text-[var(--success-text)]":o>.5?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]",a=o=>o>.8?s("aiClassification.confidence.high"):o>.5?s("aiClassification.confidence.medium"):s("aiClassification.confidence.low");return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)]",children:s(`tickets.types.${t.suggestedType}`)}),e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--warning-bg)] text-[var(--warning-text)]",children:s(`tickets.priorities.${t.suggestedPriority}`)}),e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${r(t.confidenceScore)}`,children:[a(t.confidenceScore)," (",Math.round(t.confidenceScore*100),"%)"]})]})}function Ma(t){const[s,r]=n.useState(t?.initialData??null),[a,o]=n.useState(!1),[c,i]=n.useState(null),d=n.useRef(null),u=n.useRef(!1);n.useEffect(()=>(u.current=!1,()=>{u.current=!0,d.current?.abort()}),[]);const m=n.useCallback(async f=>{d.current?.abort();const b=new AbortController;d.current=b,o(!0),i(null);try{const h=await f(b.signal);!u.current&&!b.signal.aborted&&r(h)}catch(h){!u.current&&!b.signal.aborted&&i(h instanceof Error?h.message:"Unknown error")}finally{!u.current&&!b.signal.aborted&&o(!1)}},[]),p=n.useCallback(()=>{d.current?.abort(),u.current||o(!1)},[]),g=n.useCallback(()=>{r(null),i(null),o(!1)},[]);return{data:s,loading:a,error:c,execute:m,cancel:p,reset:g}}function _d({ticketId:t,cachedClassification:s,cachedRouting:r,cachedGeneratedAt:a,processing:o,onProcessingStart:c,onProcessingEnd:i}){const{t:d}=ne.useTranslation("support"),u=s||r?{classification:s??null,routingSuggestion:r??null,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:m,loading:p,error:g,execute:f,reset:b}=Ma({initialData:u}),[h,y]=n.useState(!1),x=n.useCallback(async()=>{c?.(),await f(async()=>{const N=await Ia.analyze(t);return i?.(),N})},[t,f,c,i]),j=n.useCallback(async()=>{if(m?.routingSuggestion)try{y(!0);const N={assignToUserId:m.routingSuggestion.suggestedAgents[0]?.userId,assignToGroupId:m.routingSuggestion.suggestedGroupId??void 0,applyPriorityAdjustment:m.routingSuggestion.priorityAdjustment!==null};await $a.applyRouting(t,N),b()}catch{}finally{y(!1)}},[m,b,d]);if(g&&!m)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:g}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});if(!m)return o?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:d("aiRouting.processing")})]})}):e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[p?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Sparkles,{className:"w-4 h-4"}),d("aiRouting.analyze")]});if(p&&!m)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!m.isAiAvailable){const N=m.errorCode?`aiRouting.errors.${m.errorCode}`:null,I=N&&d(N)!==N?d(N):m.errorMessage??d("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:I})]})})}if(!m.classification&&!m.routingSuggestion)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:m.errorMessage??d("aiRouting.notAvailable")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});const v=m?.routingSuggestion,S=a&&!p?new Date(a):null;return e.jsx("div",{className:"card p-6 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"space-y-4",children:[m?.errorMessage&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-[var(--warning-text)] bg-[var(--warning-bg)]/20 rounded p-2",children:[e.jsx(l.AlertCircle,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),e.jsx("p",{children:m.errorMessage})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.Sparkles,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-1"}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:d("aiRouting.suggestedRouting")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-1",title:d("aiRouting.refresh"),children:[p?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("aiRouting.refresh")]})]}),S&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:d("aiRouting.generatedAt",{date:S.toLocaleString()})}),e.jsxs("div",{className:"space-y-3",children:[m?.classification&&e.jsx(Da,{classification:m.classification}),(v?.suggestedAgents?.length??0)>0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-2",children:d("aiRouting.suggestedAgents")}),e.jsx("div",{className:"space-y-1",children:v?.suggestedAgents?.map(N=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium",children:N.userName||N.userId}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[Math.round(N.matchScore*100),"%"]})]},N.userId))})]}),v?.suggestedGroupName&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.suggestedGroup")}),e.jsx("p",{className:"font-medium",children:v.suggestedGroupName})]}),v?.reasoning&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.reasoning")}),e.jsx("p",{className:"italic",children:v.reasoning})]}),e.jsx("div",{className:"pt-3 border-t border-[var(--border-color)] flex gap-2",children:v&&e.jsxs("button",{onClick:j,disabled:h,className:"btn btn-primary btn-sm flex items-center gap-2 flex-1 justify-center",children:[h?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Check,{className:"w-4 h-4"}),d("aiRouting.apply")]})})]})]})]})]})})}function qd({ticketId:t,cachedSummary:s,cachedGeneratedAt:r,processing:a,onProcessingStart:o,onProcessingEnd:c}){const{t:i}=ne.useTranslation("support"),d=s?{summary:s,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:u,loading:m,error:p,execute:g}=Ma({initialData:d}),f=n.useCallback(async()=>{o?.(),await g(async()=>{const y=await La.summarize(t);return c?.(),y})},[t,g,o,c]);if(p&&!u)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:p}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})});if(!u)return a?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:i("aiSummary.processing")})]})}):e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[m?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Zap,{className:"w-4 h-4"}),i("aiSummary.generate")]});if(m&&!u)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!u.isAiAvailable){const y=u.errorCode?`aiRouting.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:x})]})})}if(!u.summary){const y=u.errorCode?`aiSummary.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiSummary.error");return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:x}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})})}const b=u.summary,h=r&&!m?new Date(r):null;return e.jsxs("div",{className:"card p-6 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(l.Zap,{className:"w-5 h-5"}),i("aiSummary.title")]}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-1",title:i("aiSummary.refresh"),children:[m?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("aiSummary.refresh")]})]}),h&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:i("aiSummary.generatedAt",{date:h.toLocaleString()})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.summary")}),e.jsx("p",{className:"text-sm",children:b.summary})]}),b.keyPoints.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.keyPoints")}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:b.keyPoints.map((y,x)=>e.jsx("li",{className:"text-sm",children:y},`point-${x}`))})]}),b.sentiment&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.sentiment")}),e.jsx("p",{className:"text-sm",children:b.sentiment})]}),(b.blockers?.length??0)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.blockers")}),e.jsx("ul",{className:"space-y-2",children:b.blockers?.map((y,x)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] flex-shrink-0 mt-0.5",children:x+1}),e.jsx("span",{className:"text-sm",children:y})]},`blocker-${x}`))})]})]})]})}const je={tickets:{getAll:t=>E.get("/api/support/tickets",{params:t}),getMyTickets:t=>E.get("/api/support/tickets/my-assigned",{params:t}),getById:t=>E.get(`/api/support/tickets/${t}`),create:t=>E.post("/api/support/tickets",t),update:(t,s)=>E.put(`/api/support/tickets/${t}`,s),updateStatus:(t,s)=>E.patch(`/api/support/tickets/${t}/status`,{status:s}),assign:(t,s,r,a)=>E.patch(`/api/support/tickets/${t}/assign`,{assignedToUserId:s,userIds:r,groupIds:a}),resolve:(t,s)=>E.patch(`/api/support/tickets/${t}/resolve`,{resolution:s}),close:t=>E.patch(`/api/support/tickets/${t}/close`),reopen:t=>E.patch(`/api/support/tickets/${t}/reopen`),addComment:(t,s)=>E.post(`/api/support/tickets/${t}/comments`,s),delete:t=>E.delete(`/api/support/tickets/${t}`),getStats:t=>E.get("/api/support/tickets/stats",{params:{tenantId:t}}),getMyAssignedStats:()=>E.get("/api/support/tickets/my-assigned/stats"),getAttachmentUrl:(t,s)=>`/api/support/tickets/${t}/attachments/${s}`,downloadAttachment:(t,s)=>E.get(`/api/support/tickets/${t}/attachments/${s}`,{responseType:"blob"}),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},getActivities:(t,s=10)=>E.get(`/api/support/tickets/${t}/activities`,{params:{limit:s}}),getTicketingProvider:()=>E.get("/api/support/tickets/provider"),getGlpiSyncStats:()=>E.get("/api/support/tickets/glpi-sync-stats"),proposeSolution:(t,s)=>E.post(`/api/support/tickets/${t}/solutions`,{content:s}),getSolutions:t=>E.get(`/api/support/tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/tickets/${t}/solutions/reject`,{reason:s})}},Fe={getAll:t=>E.get("/api/support/my-tickets",{params:t}),getById:t=>E.get(`/api/support/my-tickets/${t}`),create:t=>E.post("/api/support/my-tickets",t),update:(t,s)=>E.put(`/api/support/my-tickets/${t}`,s),addComment:(t,s)=>E.post(`/api/support/my-tickets/${t}/comments`,{content:s}),getStats:()=>E.get("/api/support/my-tickets/stats"),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/my-tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},downloadAttachment:(t,s)=>E.get(`/api/support/my-tickets/${t}/attachments/${s}`,{responseType:"blob"}),deleteAttachment:(t,s)=>E.delete(`/api/support/my-tickets/${t}/attachments/${s}`),getActivities:(t,s=10)=>E.get(`/api/support/my-tickets/${t}/activities`,{params:{limit:s}}),getAttachmentUrl:(t,s)=>`/api/support/my-tickets/${t}/attachments/${s}`,submitSatisfaction:(t,s)=>E.post(`/api/support/my-tickets/${t}/satisfaction`,s),getSatisfaction:t=>E.get(`/api/support/my-tickets/${t}/satisfaction`),getSolutions:t=>E.get(`/api/support/my-tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/my-tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/my-tickets/${t}/solutions/reject`,{reason:s})},Ud={getAll:()=>E.get("/api/support/assignment"),getById:t=>E.get(`/api/support/assignment/${t}`),create:t=>E.post("/api/support/assignment",t),update:(t,s)=>E.put(`/api/support/assignment/${t}`,s),delete:t=>E.delete(`/api/support/assignment/${t}`),activate:t=>E.patch(`/api/support/assignment/${t}/activate`),deactivate:t=>E.patch(`/api/support/assignment/${t}/deactivate`)},zd={getAll:()=>E.get("/api/support/assignment/skills"),getByAgent:t=>E.get("/api/support/assignment/skills",{params:{userId:t}}),update:(t,s)=>E.put(`/api/support/assignment/skills/${t}`,s)},Bd={getByAgent:t=>E.get(`/api/support/assignment/availability/${t}`),update:(t,s)=>E.put(`/api/support/assignment/availability/${t}`,s)},Gd={getByTicket:(t,s=1,r=50)=>E.get("/api/support/assignment/logs",{params:{ticketId:t,page:s,pageSize:r}})},Kd={getByAgent:t=>E.get(`/api/support/assignment/workload/${t}`),getAll:()=>E.get("/api/support/assignment/workload")};function Cs(){const{currentTenant:t}=Ee(),[s,r]=n.useState(null),[a,o]=n.useState(!!t),[c,i]=n.useState(null),d=n.useCallback(async()=>{if(!t){r(null);return}o(!0),i(null);try{const u=await je.tickets.getTicketingProvider();r(u)}catch{i("Failed to load ticketing provider configuration"),r(null)}finally{o(!1)}},[t]);return n.useEffect(()=>{d()},[d]),{provider:s?.provider??"SmartStack",isGlpi:s?.provider==="Glpi",isConfigured:s?.isConfigured??!1,glpiBaseUrl:s?.glpiBaseUrl??void 0,loading:a,error:c,refresh:d}}const ds={Open:"pending",InProgress:"active",OnHold:"warning",Resolved:"active",Closed:"inactive",Rejected:"error"},lr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},Hd=["conversation","description","information","assignment","ai"],Vd={Open:"statusDescriptions.Open",InProgress:"statusDescriptions.InProgress",OnHold:"statusDescriptions.OnHold",Resolved:"statusDescriptions.Resolved",Closed:"statusDescriptions.Closed",Rejected:"statusDescriptions.Rejected"};function Wd({satisfaction:t,showRatingForm:s,ratingValue:r,ratingComment:a,submittingRating:o,onShowForm:c,onRatingChange:i,onCommentChange:d,onCancel:u,onSubmit:m,t:p}){return t?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500 fill-amber-500"}),p("satisfaction.yourRating","Votre évaluation")]}),e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[1,2,3,4,5].map(g=>e.jsx(l.Star,{className:`w-5 h-5 ${g<=t.rating?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)]"}`},g)),e.jsxs("span",{className:"ml-2 text-sm text-[var(--text-secondary)]",children:[t.rating,"/5"]})]}),t.comment&&e.jsxs("p",{className:"text-sm text-[var(--text-secondary)] italic",children:['"',t.comment,'"']})]}):s?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-3",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.rateTitle","Évaluez cette résolution")]}),e.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(g=>e.jsx("button",{type:"button",onClick:()=>i(g),className:"p-1 hover:scale-110 transition-transform",children:e.jsx(l.Star,{className:`w-7 h-7 transition-colors ${g<=r?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)] hover:text-amber-300"}`})},g))}),e.jsx("textarea",{value:a,onChange:g=>d(g.target.value),placeholder:p("satisfaction.commentPlaceholder","Commentaire (optionnel)..."),className:"input w-full h-20 mb-3 text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"btn btn-secondary btn-sm",children:p("common.cancel","Annuler")}),e.jsxs("button",{onClick:m,disabled:r===0||o,className:"btn btn-primary btn-sm",children:[o?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.submit","Envoyer")]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.askTitle","Comment évaluez-vous cette résolution ?")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:p("satisfaction.askDescription","Votre avis nous aide à améliorer notre service.")})]}),e.jsxs("button",{onClick:c,className:"btn btn-primary btn-sm",children:[e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.rateButton","Évaluer")]})]})}function Xd({show:t,resolution:s,saving:r,onResolutionChange:a,onClose:o,onResolve:c,t:i}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:i("resolve.title","Proposer une solution")}),e.jsx("textarea",{value:s,onChange:d=>a(d.target.value),placeholder:i("resolve.placeholder","Décrivez la résolution..."),className:"input w-full h-32 mb-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"btn btn-secondary",children:i("common.cancel","Annuler")}),e.jsxs("button",{onClick:c,disabled:!s.trim()||r,className:"btn btn-primary",children:[r&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),i("resolve.confirm","Proposer")]})]})]})}):null}function Yd({show:t,filteredUsers:s,selectedUserIds:r,selectedGroupIds:a,groups:o,userSearchQuery:c,groupSearchQuery:i,loadingUsers:d,loadingGroups:u,saving:m,activeTab:p,onUserSearchChange:g,onGroupSearchChange:f,onSelectUser:b,onSelectGroup:h,onTabChange:y,onClose:x,onAssign:j,t:v}){const S=n.useMemo(()=>{if(!i.trim())return o;const N=i.toLowerCase();return o.filter(I=>I.name.toLowerCase().includes(N))},[o,i]);return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4 max-h-[80vh] flex flex-col",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:v("assign.title","Assigner le ticket")}),e.jsxs("div",{className:"flex gap-2 mb-4 border-b border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>y("users"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="users"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabUsers","Utilisateurs")}),e.jsx("button",{onClick:()=>y("groups"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="groups"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabGroups","Groupes")})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(l.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:p==="users"?c:i,onChange:N=>p==="users"?g(N.target.value):f(N.target.value),placeholder:p==="users"?v("assign.searchUserPlaceholder","Rechercher un utilisateur..."):v("assign.searchGroupPlaceholder","Rechercher un groupe..."),className:"input w-full pl-10",autoFocus:!0})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mb-4",children:[p==="users"&&e.jsx(e.Fragment,{children:d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:s.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noUsersFound","Aucun utilisateur trouvé")}):s.map(N=>e.jsxs("button",{onClick:()=>b(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${r.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:r.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.fullName.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:N.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:N.email})]})]},N.id))})}),p==="groups"&&e.jsx(e.Fragment,{children:u?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:S.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noGroupsFound","Aucun groupe trouvé")}):S.map(N=>e.jsxs("button",{onClick:()=>h(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${a.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:a.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.name.charAt(0).toUpperCase()}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:N.name})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] flex-shrink-0",children:N.memberCount})]},N.id))})})]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-4 px-3 py-2 bg-[var(--bg-secondary)] rounded",children:v("assign.selectedSummary","{{userCount}} utilisateur(s), {{groupCount}} groupe(s) sélectionné(s)",{userCount:r.length,groupCount:a.length})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{x(),g(""),f("")},className:"btn btn-secondary",children:v("common.cancel","Annuler")}),e.jsxs("button",{onClick:j,disabled:m||d||u,className:"btn btn-primary",children:[m&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),v("assign.confirm","Assigner")]})]})]})}):null}const Jd=["Supervisor","Manager","Director"];function Qd({show:t,escalationLevel:s,escalationReason:r,saving:a,onLevelChange:o,onReasonChange:c,onClose:i,onEscalate:d,t:u}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--warning-bg)] flex items-center justify-center",children:e.jsx(l.ArrowUpCircle,{className:"w-5 h-5 text-[var(--warning-text)]"})}),e.jsx("h2",{className:"text-xl font-bold",children:u("escalate.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:u("escalate.description")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.level")}),e.jsx("div",{className:"space-y-2",children:Jd.map(m=>e.jsxs("button",{onClick:()=>o(m),className:`w-full flex items-center gap-3 px-4 py-3 text-left rounded-lg border transition-colors ${s===m?"border-[var(--warning-border)] bg-[var(--warning-bg)]":"border-[var(--border-color)] hover:bg-[var(--bg-secondary)]"}`,children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${s===m?"border-[var(--warning-text)]":"border-[var(--border-color)]"}`,children:s===m&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-[var(--warning-text)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u(`escalate.levels.${m}`)}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:u(`escalate.levels.${m}Desc`)})]})]},m))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.reason")}),e.jsx("textarea",{value:r,onChange:m=>c(m.target.value),placeholder:u("escalate.reasonPlaceholder"),className:"input w-full h-24"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{i(),o("Supervisor"),c("")},className:"btn btn-secondary",children:u("common.cancel")}),e.jsxs("button",{onClick:d,disabled:a,className:"btn border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[a&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),u("escalate.confirm")]})]})]})}):null}function Zd(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,createdByName:t.createdBy?.fullName,assignedToName:t.assignedTo?.fullName,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,assignees:t.assignees,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:s.isInternal,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,contentType:s.contentType,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,clientContext:t.clientContext,externalProvider:t.externalProvider,externalId:t.externalId,externalUrl:t.externalUrl,isExternallyManaged:t.isExternallyManaged,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function eu(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:!1,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function cr(t,s){return s==="support"?Zd(t):eu(t)}const tu=()=>{const[t,s]=n.useState(null),[r,a]=n.useState(!0),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState(null),[p,g]=n.useState([]),[f,b]=n.useState(!1),[h,y]=n.useState({title:"",priority:"Medium"}),[x,j]=n.useState(!1),[v,S]=n.useState(!1),[N,I]=n.useState(!1),[P,k]=n.useState(""),[A,R]=n.useState("Supervisor"),[$,q]=n.useState(""),[C,D]=n.useState([]),[Y,T]=n.useState([]),[z,Z]=n.useState([]),[H,J]=n.useState(!1),[fe,B]=n.useState(""),[Q,M]=n.useState(""),[re,F]=n.useState([]),[K,V]=n.useState(!1),[ae,ue]=n.useState("users"),[G,ce]=n.useState(null),[de,he]=n.useState(!1),[pe,ye]=n.useState(0),[qe,Ue]=n.useState(""),[Ve,U]=n.useState(!1);return{ticket:t,setTicket:s,loading:r,setLoading:a,saving:o,setSaving:c,uploading:i,setUploading:d,error:u,setError:m,activities:p,setActivities:g,isEditing:f,setIsEditing:b,editForm:h,setEditForm:y,showAssignModal:x,setShowAssignModal:j,showResolveModal:v,setShowResolveModal:S,showEscalateModal:N,setShowEscalateModal:I,resolution:P,setResolution:k,escalationLevel:A,setEscalationLevel:R,escalationReason:$,setEscalationReason:q,users:C,setUsers:D,selectedUserIds:Y,setSelectedUserIds:T,selectedGroupIds:z,setSelectedGroupIds:Z,loadingUsers:H,setLoadingUsers:J,userSearchQuery:fe,setUserSearchQuery:B,groupSearchQuery:Q,setGroupSearchQuery:M,groups:re,setGroups:F,loadingGroups:K,setLoadingGroups:V,assignModalTab:ae,setAssignModalTab:ue,satisfaction:G,setSatisfaction:ce,showRatingForm:de,setShowRatingForm:he,ratingValue:pe,setRatingValue:ye,ratingComment:qe,setRatingComment:Ue,submittingRating:Ve,setSubmittingRating:U}},su=(t,s)=>t?s?.email||"":(s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.email)||"",ru=(t,s,r)=>{const a=s.get("tab");t==="conversation"?a&&(s.delete("tab"),r(s,{replace:!0})):a!==t&&r({tab:t},{replace:!0})},au=(t,s)=>{const r=t.get("tab");return r&&s.includes(r)?r:"conversation"};function nu({ticket:t,isSupport:s,isEditing:r,saving:a,editForm:o,error:c,onEditToggle:i,onSave:d,onEditFormChange:u,onErrorClear:m,t:p}){return e.jsxs("div",{className:"flex-shrink-0 border-b border-[var(--border-color)] bg-[var(--bg-card)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>window.history.back(),className:"btn btn-ghost p-2",children:e.jsx(l.ArrowLeft,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:t.ticketNumber}),t.externalId&&t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80",children:[e.jsx(l.ExternalLink,{className:"w-3 h-3"}),"GLPI #",t.externalId]}),e.jsx(Ot,{status:ds[t.status]||"pending",label:t.status}),e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:lr[t.priority]?.bg,color:lr[t.priority]?.text},children:t.priority})]}),s&&r?e.jsx("input",{type:"text",value:o.title,onChange:g=>u({...o,title:g.target.value}),className:"input w-full text-lg font-bold"}):e.jsx("h1",{className:"text-lg font-bold truncate",children:t.title})]}),e.jsx("div",{className:"flex items-center gap-2",children:s&&r?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!1),className:"btn btn-ghost p-2",children:e.jsx(l.X,{className:"w-5 h-5"})}),e.jsx("button",{onClick:d,disabled:a,className:"btn btn-primary",children:a?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Save,{className:"w-4 h-4"})})]}):e.jsx(e.Fragment,{children:s&&!t.isExternallyManaged&&e.jsx("button",{onClick:()=>i(!0),className:"btn btn-ghost p-2",title:"Modifier",children:e.jsx(l.Edit2,{className:"w-5 h-5"})})})})]}),c&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm flex-1",children:c}),e.jsx("button",{onClick:m,className:"p-1 hover:bg-[var(--error-border)] rounded",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),t.isExternallyManaged&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] flex items-center gap-3",children:[e.jsx(l.ShieldAlert,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-[var(--info-text)]",children:p("glpi.readOnlyBanner","This ticket is managed by GLPI and is read-only.")})}),t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-sm bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80 flex items-center gap-1.5",children:[e.jsx(l.ExternalLink,{className:"w-4 h-4"}),p("glpi.viewInGlpi","View in GLPI")]})]})]})}function ou({ticket:t,isSupport:s,satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowRatingForm:d,onRatingChange:u,onCommentChange:m,onCancelRating:p,onSubmitRating:g,t:f}){return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:f(Vd[t.status]||"statusDescriptions.InProgress")})}),t.resolution&&e.jsxs("div",{className:"mt-3 p-4 rounded-lg bg-[var(--success-bg)] border border-[var(--success-border)]",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 text-[var(--success-text)] mb-1",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),f("resolution.title","Résolution")]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.resolution})]}),!s&&(t.status==="Resolved"||t.status==="Closed")&&e.jsx("div",{className:"mt-3 p-4 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx(Wd,{satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowForm:d,onRatingChange:u,onCommentChange:m,onCancel:p,onSubmit:g,t:f})})]})}function iu({activeTab:t,commentCount:s,isSupport:r,assigneeCount:a,onTabChange:o,t:c}){const i=[{id:"conversation",icon:l.MessageSquare,label:c("tabs.conversation"),badge:s},{id:"description",icon:l.FileText,label:c("tabs.description"),badge:0},{id:"information",icon:l.Info,label:c("tabs.information"),badge:0},...r?[{id:"assignment",icon:l.Users,label:c("tabs.assignment"),badge:a},{id:"ai",icon:l.Sparkles,label:c("tabs.ai"),badge:0}]:[]];return e.jsx("div",{className:"flex-shrink-0 flex border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:i.map(({id:d,icon:u,label:m,badge:p})=>e.jsxs("button",{onClick:()=>o(d),className:`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${t===d?"border-[var(--color-accent-600)] text-[var(--color-accent-600)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--border-color)]"}`,children:[e.jsx(u,{className:"w-4 h-4"}),m,p>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:p})]},d))})}function lu({activeTab:t,ticket:s,activities:r,isSupport:a,isClosed:o,isReadOnly:c,isConnected:i,currentUserName:d,saving:u,uploading:m,onAddComment:p,onDownloadAttachment:g,onUploadAttachment:f,onStatusChange:b,onAssign:h,onResolve:y,onClose:x,onReopen:j,onEscalate:v,getAttachmentUrl:S,onProposeSolution:N,onApproveSolution:I,onRejectSolution:P,t:k}){if(t==="description")return e.jsx("div",{className:"h-full overflow-y-auto p-6 bg-[var(--bg-primary)]",children:s.description?e.jsx("div",{className:"prose prose-sm max-w-none text-[var(--text-primary)] leading-relaxed [&_a]:text-[var(--color-accent-600)] [&_a]:underline",dangerouslySetInnerHTML:{__html:Qa.sanitize(s.description)}}):e.jsx("p",{className:"text-[var(--text-tertiary)] italic",children:k("tabs.noDescription")})});if(t==="conversation"){const A=n.useMemo(()=>{if(s)return{ticketNumber:s.ticketNumber??"",ticketTitle:s.title??"",userName:s.createdBy?.fullName??"",userFirstName:s.createdBy?.fullName?.split(" ")[0]??"",userLastName:s.createdBy?.fullName?.split(" ").slice(1).join(" ")??"",userEmail:s.createdBy?.email??"",priority:s.priority??"",type:s.type??"",status:s.status??"",agentName:s.assignedTo?.fullName??"",agentFirstName:s.assignedTo?.fullName?.split(" ")[0]??"",createdAt:s.createdAt?new Date(s.createdAt).toLocaleDateString():"",resolvedAt:s.resolvedAt?new Date(s.resolvedAt).toLocaleDateString():"",resolution:s.resolution??""}},[s]);return e.jsxs("div",{className:"h-full flex flex-col",children:[(s.activeSolution||s.hasPendingSolution||a&&!o&&s.status!=="Closed")&&e.jsx("div",{className:"p-4 border-b border-[var(--border-color)]",children:e.jsx(Od,{ticketId:s.id,solutions:s.solutions??[],activeSolution:s.activeSolution,mode:a?"support":"client",onProposeSolution:!c&&a?N:void 0,onApproveSolution:c?void 0:I,onRejectSolution:c?void 0:P,isLoading:u})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ra,{ticketId:s.id,comments:s.comments,activities:r.map(R=>({id:R.id,action:R.action,oldValue:R.oldValue??null,newValue:R.newValue??null,changedByUserName:"changedByUserName"in R?R.changedByUserName:null,createdAt:R.createdAt})),attachments:s.attachments,isSupport:a,isClosed:o||c,isConnected:i,currentUserName:d,ticketVariables:A,onAddComment:p,onDownloadAttachment:g,getAttachmentUrl:S})})]})}return t==="assignment"?e.jsx(cu,{ticket:s,canAssign:!c&&!!h,onAssign:h,t:k}):t==="ai"?e.jsx(uu,{ticket:s,t:k}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(Ea,{ticket:s,attachments:s.attachments,activities:r.map(A=>({action:A.action,newValue:A.newValue,createdAt:A.createdAt})),isSupport:a,saving:u,uploading:m,isReadOnly:c,layout:"grid",onAssign:c?void 0:h,onStatusChange:c?void 0:b,onResolve:c?void 0:y,onCloseTicket:c?void 0:x,onReopen:c?void 0:j,onEscalate:c?void 0:v,onDownloadAttachment:g,onUploadAttachment:c?void 0:f,getAttachmentUrl:S})})})}function cu({ticket:t,canAssign:s,onAssign:r,t:a}){const[o,c]=n.useState([]),[i,d]=n.useState(!1);n.useEffect(()=>{t?.id&&(d(!0),Gd.getByTicket(t.id).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1)))},[t?.id]);const u=t.assignees??[];return e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:a("tabs.assignmentCurrentAssignees")}),s&&r&&e.jsx("button",{onClick:r,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:a("tabs.assignmentAssign")})]}),u.length===0?e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoAssignees")}):e.jsx("div",{className:"space-y-2",children:u.map(m=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-[var(--bg-secondary)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] flex items-center justify-center text-xs font-medium",children:(m.fullName||m.email||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName||m.email}),m.assignedViaGroupName&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)]",children:a("tabs.assignmentViaGroup",{group:m.assignedViaGroupName})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.isPrimary&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:a("tabs.assignmentPrimary")}),m.assignedAt&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(m.assignedAt).toLocaleDateString()})]})]},m.userId))})]}),e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)] mb-4",children:a("tabs.assignmentLogs")}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!i&&o.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoLogs")}),!i&&o.length>0&&e.jsx("div",{className:"space-y-2",children:o.map(m=>e.jsxs("div",{className:"flex items-start gap-3 p-2 rounded-md border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("div",{className:`mt-0.5 w-2 h-2 rounded-full flex-shrink-0 ${m.success?"bg-[var(--success-text)]":"bg-[var(--error-text)]"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)]",children:[e.jsx("span",{className:"font-medium",children:m.strategyUsed}),m.reason&&e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[" — ",m.reason]})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:new Date(m.createdAt).toLocaleString()})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${m.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:m.success?a("tabs.assignmentSuccess"):a("tabs.assignmentFailed")})]},m.id))})]})]})})}const du=12e4;function dr(t){const s=sessionStorage.getItem(t);return s?Date.now()-Number(s)>du?(sessionStorage.removeItem(t),!1):!0:!1}function uu({ticket:t,t:s}){const[r,a]=n.useState(null),[o,c]=n.useState(!0),i=`ai_routing_${t.id}`,d=`ai_summary_${t.id}`,[u,m]=n.useState(()=>dr(i)),[p,g]=n.useState(()=>dr(d));n.useEffect(()=>{let x=!1;return(async()=>{try{const{cachedAiApi:v}=await Promise.resolve().then(()=>ir),S=await v.getCached(t.id);x||(a(S),S.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),S.summary&&(sessionStorage.removeItem(d),g(!1)))}catch{}finally{x||c(!1)}})(),()=>{x=!0}},[t.id,i,d]),n.useEffect(()=>{if(!u&&!p)return;let x=!1;const v=setInterval(async()=>{try{const{cachedAiApi:S}=await Promise.resolve().then(()=>ir),N=await S.getCached(t.id);if(x)return;a(N),u&&N.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),p&&N.summary&&(sessionStorage.removeItem(d),g(!1))}catch{}},3e3);return()=>{x=!0,clearInterval(v)}},[u,p,t.id,i,d]);const f=n.useCallback(()=>{sessionStorage.setItem(i,Date.now().toString()),m(!0)},[i]),b=n.useCallback(()=>{sessionStorage.removeItem(i),m(!1)},[i]),h=n.useCallback(()=>{sessionStorage.setItem(d,Date.now().toString()),g(!0)},[d]),y=n.useCallback(()=>{sessionStorage.removeItem(d),g(!1)},[d]);return o?e.jsx("div",{className:"h-full overflow-y-auto p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[(t.aiClassification||r?.classification)&&e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3 text-[var(--text-primary)]",children:s("aiClassification.title")}),e.jsx(Da,{classification:t.aiClassification||r?.classification})]}),e.jsx(_d,{ticketId:t.id,cachedClassification:r?.classification,cachedRouting:r?.routingSuggestion,cachedGeneratedAt:r?.routingSuggestionGeneratedAt,processing:u,onProcessingStart:f,onProcessingEnd:b}),e.jsx(qd,{ticketId:t.id,cachedSummary:r?.summary,cachedGeneratedAt:r?.summaryGeneratedAt,processing:p,onProcessingStart:h,onProcessingEnd:y})]})})}function mu({mode:t}){const{id:s}=w.useParams(),r=w.useNavigate(),{t:a}=ne.useTranslation("support"),{user:o,hasPermission:c}=Pe(),[i,d]=w.useSearchParams(),{isGlpi:u}=Cs(),m=t==="support",p=su(m,o),[g,f]=n.useState(()=>au(i,Hd));n.useEffect(()=>{ru(g,i,d)},[g,i,d]);const{ticket:b,setTicket:h,loading:y,setLoading:x,saving:j,setSaving:v,uploading:S,setUploading:N,error:I,setError:P,activities:k,setActivities:A,isEditing:R,setIsEditing:$,editForm:q,setEditForm:C,showAssignModal:D,setShowAssignModal:Y,showResolveModal:T,setShowResolveModal:z,showEscalateModal:Z,setShowEscalateModal:H,resolution:J,setResolution:fe,escalationLevel:B,setEscalationLevel:Q,escalationReason:M,setEscalationReason:re,users:F,setUsers:K,selectedUserIds:V,setSelectedUserIds:ae,selectedGroupIds:ue,setSelectedGroupIds:G,loadingUsers:ce,setLoadingUsers:de,userSearchQuery:he,setUserSearchQuery:pe,groupSearchQuery:ye,setGroupSearchQuery:qe,groups:Ue,setGroups:Ve,loadingGroups:U,setLoadingGroups:W,assignModalTab:ee,setAssignModalTab:te,satisfaction:se,setSatisfaction:me,showRatingForm:ie,setShowRatingForm:ve,ratingValue:be,setRatingValue:Ie,ratingComment:Me,setRatingComment:Le,submittingRating:ze,setSubmittingRating:et}=tu(),We=n.useCallback(async()=>{if(s)try{const X=m?await je.tickets.getActivities(s,50):await Fe.getActivities(s,50);A(X)}catch(X){console.error("Failed to load activities",X)}},[s,m]),At=n.useCallback(async()=>{if(!(!s||m))try{const X=await Fe.getSatisfaction(s);me(X)}catch(X){console.error("Failed to load satisfaction",X)}},[s,m]),ke=n.useCallback(async()=>{if(s)try{if(x(!0),P(null),m){const X=await je.tickets.getById(s);if(!X){h(null);return}h(cr(X,t)),C({title:X.title,priority:X.priority})}else{const X=await Fe.getById(s);if(!X){h(null);return}h(cr(X,t)),At()}We()}catch(X){P(a("error.loadFailed","Impossible de charger le ticket")),console.error(X)}finally{x(!1)}},[s,m,t,We,At,a]),L=n.useCallback(X=>{if(X.ticketId===s){if(!m&&X.isInternal)return;h(xe=>!xe||xe.comments.some(De=>De.id===X.id)?xe:{...xe,comments:[...xe.comments,{id:X.id,userName:X.userName,content:X.content,isInternal:X.isInternal,isEdited:X.isEdited,createdAt:X.createdAt}]})}},[s,m]),le=n.useCallback(X=>{X.ticketId===s&&ke()},[s,ke]),{isConnected:we}=aa({ticketId:s,onCommentAdded:L,onTicketUpdated:le});n.useEffect(()=>{ke()},[ke]),n.useEffect(()=>{(async()=>{if(!(!D||F.length>0||!m))try{de(!0);const xe=await E.get("/api/support/tickets/assignable-users"),De=Array.isArray(xe)?xe:[];K(De.map(Re=>({id:Re.id,email:Re.email,fullName:`${Re.firstName} ${Re.lastName}`}))),(b?.assignees?.length??0)>0&&b?.assignees&&ae(b.assignees.map(Re=>Re.userId))}catch(xe){console.error("Failed to load users",xe)}finally{de(!1)}})()},[D,F.length,m,b?.assignees]),n.useEffect(()=>{(async()=>{if(!(!D||!m))try{W(!0);const xe=await E.get("/api/support/tickets/assignable-groups"),De=Array.isArray(xe)?xe:[];Ve(De.map(Re=>({id:Re.id,name:Re.name,memberCount:Re.memberCount})))}catch(xe){console.error("Failed to load groups",xe)}finally{W(!1)}})()},[D,m]);const Ae=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.update(s,{title:q.title,priority:q.priority,description:b?.description||""}),await ke(),$(!1)}catch{P(a("error.updateFailed","Impossible de mettre à jour le ticket"))}finally{v(!1)}},$e=async X=>{if(!(!s||!m))try{v(!0),await je.tickets.updateStatus(s,X),await ke()}catch{P(a("error.statusFailed","Impossible de changer le statut"))}finally{v(!1)}},ht=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.assign(s,V.length>0?V[0]:null,V.length>0?V:void 0,ue.length>0?ue:void 0),await ke(),Y(!1),ae([]),G([]),te("users")}catch{P(a("error.assignFailed","Impossible d'assigner le ticket"))}finally{v(!1)}},rt=async()=>{if(!(!s||!J.trim()||!m))try{v(!0),await je.tickets.proposeSolution(s,J),await ke(),z(!1),fe("")}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Oa=async X=>{if(s)try{v(!0),m&&await je.tickets.proposeSolution(s,X),await ke()}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Fa=async()=>{if(s)try{v(!0),m?await je.tickets.approveSolution(s):await Fe.approveSolution(s),await ke()}catch{P(a("error.approveFailed","Impossible d'approuver la solution"))}finally{v(!1)}},_a=async X=>{if(s)try{v(!0),m?await je.tickets.rejectSolution(s,X):await Fe.rejectSolution(s,X),await ke()}catch{P(a("error.rejectFailed","Impossible de rejeter la solution"))}finally{v(!1)}},ks=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.close(s),await ke()}catch{P(a("error.closeFailed","Impossible de fermer le ticket"))}finally{v(!1)}},As=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.reopen(s),await ke()}catch{P(a("error.reopenFailed","Impossible de réouvrir le ticket"))}finally{v(!1)}},qa=async()=>{if(!(!s||!m||!B))try{v(!0),await da.escalateTicket(s,B,M||void 0),await ke(),H(!1),Q("Supervisor"),re("")}catch{P(a("error.escalateFailed","Failed to escalate ticket"))}finally{v(!1)}},Ua=async(X,xe)=>{!s||!X.trim()||(m?await je.tickets.addComment(s,{content:X,isInternal:xe}):await Fe.addComment(s,X),await ke())},za=async()=>{if(!(!s||be===0||m))try{et(!0);const X=await Fe.submitSatisfaction(s,{rating:be,comment:Me.trim()||void 0});me(X),ve(!1),Ie(0),Le("")}catch(X){const xe=X instanceof Error?X.message:a("error.ratingFailed","Failed to submit rating");P(xe)}finally{et(!1)}},Ba=async X=>{if(s)try{const xe=m?await je.tickets.downloadAttachment(s,X.id):await Fe.downloadAttachment(s,X.id),De=window.URL.createObjectURL(xe),Re=document.createElement("a");Re.href=De,Re.setAttribute("download",X.fileName),document.body.appendChild(Re),Re.click(),Re.remove(),window.URL.revokeObjectURL(De)}catch{P(a("error.downloadFailed","Impossible de télécharger le fichier"))}},Ga=async X=>{if(!(!s||!m))try{N(!0),await je.tickets.uploadAttachment(s,X),await ke()}catch(xe){throw P(a("error.uploadFailed","Failed to upload file")),xe}finally{N(!1)}},Ka=X=>s?m?je.tickets.getAttachmentUrl(s,X.id):`/api/support/my-tickets/${s}/attachments/${X.id}`:"",Ha=n.useMemo(()=>{if(!he.trim())return F;const X=he.toLowerCase();return F.filter(xe=>xe.fullName.toLowerCase().includes(X)||xe.email.toLowerCase().includes(X))},[F,he]),Va=n.useCallback(X=>{ae(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]),Wa=n.useCallback(X=>{G(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]);if(y)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})});if(!b)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:a("error.notFound","Ticket non trouvé")}),e.jsx("button",{onClick:()=>r(-1),className:"btn btn-secondary",children:a("common.goBack","Retour")})]});const Xa=b.status==="Closed"||b.status==="Rejected",tt=u||!!b.isExternallyManaged,Ps=!tt&&c("support.tickets.assign");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(nu,{ticket:b,isSupport:m,isEditing:R,saving:j,editForm:q,error:I,onEditToggle:$,onSave:Ae,onEditFormChange:C,onErrorClear:()=>P(null),t:a}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(ou,{ticket:b,isSupport:m,satisfaction:se,showRatingForm:ie,ratingValue:be,ratingComment:Me,submittingRating:ze,onShowRatingForm:()=>ve(!0),onRatingChange:Ie,onCommentChange:Le,onCancelRating:()=>{ve(!1),Ie(0),Le("")},onSubmitRating:za,t:a}),e.jsx(Md,{currentStatus:b.status,createdAt:b.createdAt,resolvedAt:b.resolvedAt,closedAt:b.closedAt,activities:k.map(X=>({action:X.action,newValue:X.newValue,createdAt:X.createdAt})),isSupport:m,saving:j,assignees:b.assignees,onAssign:Ps?()=>Y(!0):void 0,onStatusChange:tt?void 0:$e,onResolve:tt?void 0:()=>z(!0),onCloseTicket:tt?void 0:ks,onReopen:tt?void 0:As,onEscalate:tt?void 0:()=>H(!0)})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx(iu,{activeTab:g,commentCount:b.comments.length,isSupport:m,assigneeCount:b.assignees?.length??0,onTabChange:f,t:a}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(lu,{activeTab:g,ticket:b,activities:k,isSupport:m,isClosed:Xa,isReadOnly:tt,isConnected:we,currentUserName:p,saving:j,uploading:S,onAddComment:Ua,onDownloadAttachment:Ba,onUploadAttachment:Ga,onStatusChange:$e,onAssign:Ps?()=>Y(!0):void 0,onResolve:()=>z(!0),onClose:ks,onReopen:As,onEscalate:()=>H(!0),getAttachmentUrl:Ka,onProposeSolution:Oa,onApproveSolution:Fa,onRejectSolution:_a,t:a})})]}),e.jsx(Xd,{show:m&&T,resolution:J,saving:j,onResolutionChange:fe,onClose:()=>z(!1),onResolve:rt,t:a}),e.jsx(Yd,{show:m&&D,filteredUsers:Ha,selectedUserIds:V,selectedGroupIds:ue,groups:Ue,userSearchQuery:he,groupSearchQuery:ye,loadingUsers:ce,loadingGroups:U,saving:j,activeTab:ee,onUserSearchChange:pe,onGroupSearchChange:qe,onSelectUser:Va,onSelectGroup:Wa,onTabChange:te,onClose:()=>{Y(!1),ae([]),G([]),te("users"),pe(""),qe("")},onAssign:ht,t:a}),e.jsx(Qd,{show:m&&Z,escalationLevel:B,escalationReason:M,saving:j,onLevelChange:Q,onReasonChange:re,onClose:()=>H(!1),onEscalate:qa,t:a})]})}const ur="support_tickets_view_mode",pu={Open:["InProgress","OnHold","Rejected"],InProgress:["OnHold","Resolved","Rejected"],OnHold:["InProgress","Resolved","Open"],Resolved:["Closed","Open"],Closed:["Open"],Rejected:["Open"]};function mr(t,s){return t===s?!1:pu[t]?.includes(s)??!1}const ts={Low:"var(--info-bg)",Medium:"var(--warning-bg)",High:"var(--error-bg)",Critical:"var(--error-text)"};function xu({mode:t,showDrafts:s=!1,basePath:r,title:a,subtitle:o,createPath:c}){const{t:i}=ne.useTranslation(["support","admin","common"]),d=w.useNavigate(),{currentTenant:u,userTenants:m,hasMultipleTenants:p,isGlobalView:g}=Ee(),{isGlpi:f}=Cs(),[b,h]=n.useState([]),[y,x]=n.useState(null),[j,v]=n.useState(!0),[S,N]=n.useState(1),[I,P]=n.useState(1),[k,A]=n.useState(0),[R,$]=n.useState(""),[q,C]=n.useState(""),[D,Y]=n.useState(""),[T,z]=n.useState(""),[Z,H]=n.useState(""),[J,fe]=n.useState(()=>localStorage.getItem(ur)||"table"),[B,Q]=n.useState(!1),[M,re]=n.useState([]),[F,K]=n.useState(!0),[V,ae]=n.useState(null),[ue,G]=n.useState(null),[ce,de]=n.useState(null),he=(t==="admin"||t==="assigned")&&(p||g),pe=n.useCallback(async()=>{try{v(!0);const L={page:S,pageSize:20,search:R||void 0,status:q||void 0,type:D||void 0,priority:T||void 0,tenantId:Z||void 0};let le;t==="admin"?le=await je.tickets.getAll(L):t==="assigned"?le=await je.tickets.getMyTickets(L):le=await Fe.getAll(L),h(le?.items??[]),P(le?.totalPages??1),A(le?.totalCount??0)}catch(L){console.error("Failed to load tickets:",L),h([]),P(1),A(0)}finally{v(!1)}},[t,S,R,q,D,T,Z]),ye=n.useCallback(async()=>{try{let L;t==="admin"?L=await je.tickets.getStats(Z||void 0):t==="assigned"?L=await je.tickets.getMyAssignedStats():L=await Fe.getStats(),x(L)}catch(L){console.error("Failed to load stats:",L)}},[t,Z]);n.useEffect(()=>{pe()},[pe]),n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{if(s){const L=Ge.getAllDrafts();re(L)}},[s]),n.useEffect(()=>{localStorage.setItem(ur,J)},[J]);const qe=L=>{Ge.deleteDraft(L),re(Ge.getAllDrafts())},Ue=L=>{d(`${c}?draft=${L.id}`)},Ve=L=>{const we=new Date().getTime()-L.getTime(),Ae=Math.floor(we/6e4),$e=Math.floor(we/36e5),ht=Math.floor(we/864e5);return Ae<1?i("common:time.justNow","Just now"):Ae<60?i("common:time.minutesAgo",{count:Ae}):$e<24?i("common:time.hoursAgo",{count:$e}):i("common:time.daysAgo",{count:ht})},U=L=>{L.preventDefault(),N(1),pe()},W=L=>{f||ae(L)},ee=()=>{ae(null),G(null)},te=(L,le)=>{L.preventDefault(),G(le)},se=()=>{G(null)},me=L=>V?mr(V.status,L):!1,ie=async(L,le)=>{if(L.preventDefault(),de(null),!V||V.status===le){ae(null),G(null);return}if(!mr(V.status,le)){de(i("list.invalidTransition",{from:i(`tickets.statuses.${V.status}`),to:i(`tickets.statuses.${le}`)})),ae(null),G(null),setTimeout(()=>de(null),4e3);return}try{h(we=>we.map(Ae=>Ae.id===V.id?{...Ae,status:le}:Ae)),(t==="admin"||t==="assigned")&&await je.tickets.updateStatus(V.id,le),ye(),pe()}catch(we){console.error("Failed to update ticket status:",we);const Ae=we?.response?.data?.message||we?.response?.data?.detail||"";de(Ae||i("list.statusUpdateFailed")),setTimeout(()=>de(null),4e3),pe()}finally{ae(null),G(null)}},ve=async L=>{if(confirm(i("list.confirmDelete",{number:L.ticketNumber})))try{await je.tickets.delete(L.id),pe(),ye()}catch(le){console.error("Failed to delete ticket:",le)}},be=L=>`${r}/${L}`,Ie=L=>{if(!he)return null;const le="tenantId"in L?L.tenantId??null:null,we="tenantName"in L?L.tenantName??null:null,Ae=vs(le,u?.id??null);return Ae==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):Ae==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:we}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:we})},Me=()=>{if(!y)return null;const L=y,le=y,we=t==="admin"||t==="assigned",Ae=we?[{label:i("list.stats.total"),value:L.total,color:"blue"},{label:i("list.stats.open"),value:L.open,color:"yellow"},{label:i("list.stats.inProgress"),value:L.inProgress,color:"blue"},{label:i("list.stats.onHold"),value:L.onHold,color:"yellow"},{label:i("list.stats.resolved"),value:L.resolved,color:"green"},{label:i("list.stats.closed"),value:L.closed,color:"neutral"},{label:i("list.stats.critical"),value:L.critical,color:"red"},{label:i("list.stats.highPriority"),value:L.highPriority,color:"yellow"}]:[{label:i("list.stats.total"),value:le.total,color:"blue"},{label:i("list.stats.open"),value:le.open,color:"yellow"},{label:i("list.stats.inProgress"),value:le.inProgress,color:"blue"},{label:i("list.stats.resolved"),value:le.resolved,color:"green"},{label:i("list.stats.closed"),value:le.closed,color:"neutral"}],$e={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)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-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)]"},ht=we?"lg:grid-cols-8":"lg:grid-cols-5";return e.jsx("div",{className:`grid grid-cols-2 md:grid-cols-4 ${ht} gap-4 mb-6`,children:Ae.map(rt=>e.jsxs("div",{className:`card p-4 text-center border ${$e[rt.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:rt.value}),e.jsx("div",{className:"text-sm opacity-80",children:rt.label})]},rt.label))})},Le=()=>e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.number")}),he&&e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.tenant","Workspace")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.title")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.type")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.status")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.priority")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.assignee")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.comments")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.created")}),e.jsx("th",{className:"text-right p-4 font-medium",children:i("list.table.actions")})]})}),e.jsx("tbody",{children:b.map(L=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] hover:bg-[var(--bg-hover)] cursor-pointer",onClick:()=>d(be(L.id)),children:[e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"font-mono text-sm",children:L.ticketNumber})}),he&&e.jsx("td",{className:"p-4",children:Ie(L)}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"GLPI"})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})})}),e.jsx("td",{className:"p-4",children:e.jsx(Ot,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"assignedToName"in L&&L.assignedToName||"-"}),"assigneeCount"in L&&L.assigneeCount>1&&e.jsxs("span",{className:"ml-1 text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:["+",L.assigneeCount-1]})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:L.commentCount})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:new Date(L.createdAt).toLocaleDateString()})}),e.jsx("td",{className:"p-4 text-right",onClick:le=>le.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>d(be(L.id)),className:"btn btn-ghost p-2",title:i("list.actions.view"),children:e.jsx(l.Eye,{className:"w-4 h-4"})}),L.externalUrl&&e.jsx("a",{href:L.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-ghost p-2 text-[var(--info-text)]",title:"Open in GLPI",onClick:le=>le.stopPropagation(),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),t==="admin"&&!f&&e.jsx("button",{onClick:()=>ve(L),disabled:L.isExternallyManaged,className:"btn btn-ghost p-2 text-[var(--error-text)] disabled:opacity-50 disabled:cursor-not-allowed",title:L.isExternallyManaged?"Cannot delete externally managed tickets":i("list.actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]})})]},L.id))})]}),b.length===0&&!j&&e.jsxs("div",{className:"p-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),ze=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[b.map(L=>e.jsxs("button",{type:"button",className:"card p-4 hover:shadow-lg cursor-pointer transition-shadow text-left w-full",onClick:()=>d(be(L.id)),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:L.ticketNumber}),Ie(L)]}),e.jsx(Ot,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-medium line-clamp-2 flex-1",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] whitespace-nowrap",children:"GLPI"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)] bg-[var(--bg-secondary)]",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:new Date(L.createdAt).toLocaleDateString()}),e.jsx("span",{children:i("list.comments_other",{count:L.commentCount})})]})]},L.id)),b.length===0&&!j&&e.jsxs("div",{className:"col-span-full card p-12 text-center",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),et=L=>e.jsxs(ja,{onClick:()=>d(be(L.id)),isDragging:V?.id===L.id,onDragStart:()=>W(L),onDragEnd:ee,children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx("span",{children:L.ticketNumber}),Ie(L)]}),e.jsx("div",{className:"font-medium mb-2 line-clamp-2",children:L.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:i("list.comments_other",{count:L.commentCount})})]})]},L.id),We=()=>{const L=[{status:"Open",label:i("tickets.statuses.Open"),color:"warning"},{status:"InProgress",label:i("tickets.statuses.InProgress"),color:"default"},{status:"OnHold",label:i("tickets.statuses.OnHold"),color:"warning"},{status:"Resolved",label:i("tickets.statuses.Resolved"),color:"success"},{status:"Closed",label:i("tickets.statuses.Closed"),color:"default"}];return e.jsxs("div",{className:"space-y-3",children:[ce&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:ce}),e.jsx("button",{onClick:()=>de(null),className:"ml-auto text-[var(--error-text)] hover:opacity-70",children:"×"})]}),e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:L.map(le=>{const we=b.filter($e=>$e.status===le.status),Ae=V!=null&&!me(le.status)&&V.status!==le.status;return e.jsx(ya,{title:le.label,count:we.length,color:le.color,isDragOver:ue===le.status,isDropDisabled:Ae,onDragOver:$e=>te($e,le.status),onDragLeave:se,onDrop:$e=>ie($e,le.status),children:we.map(et)},le.status)})})]})},At=()=>!s||M.length===0?null:e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileEdit,{className:"w-5 h-5 text-[var(--warning-text)]"}),e.jsx("h2",{className:"font-semibold",children:i("common:drafts.title","Drafts")}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] rounded-full",children:M.length})]}),e.jsx("button",{onClick:()=>K(!F),className:"btn btn-ghost text-sm",children:F?i("common:actions.hide","Hide"):i("common:actions.show","Show")})]}),F&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:M.map(L=>e.jsx("button",{type:"button",className:"p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--warning-border)] hover:border-[var(--warning-text)] transition-colors cursor-pointer text-left w-full",onClick:()=>Ue(L),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:L.title||i("common:drafts.untitled","Untitled draft")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-[var(--text-secondary)] flex-wrap",children:[L.tenantName&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded truncate max-w-[120px]",children:L.tenantName}),L.type&&e.jsx("span",{className:"px-1.5 py-0.5 bg-[var(--bg-tertiary)] rounded",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),Ve(L.updatedAt)]})]})]}),e.jsx("button",{onClick:le=>{le.stopPropagation(),qe(L.id)},className:"p-1 hover:bg-[var(--error-bg)] rounded text-[var(--text-secondary)] hover:text-[var(--error-text)]",title:i("common:actions.delete","Delete"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})},L.id))})]}),ke=()=>t==="admin"||t==="assigned"?he?"md:grid-cols-4":"md:grid-cols-3":"md:grid-cols-2";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(l.Headphones,{className:"w-6 h-6"}),a]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o})]}),!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary flex items-center gap-2",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),i("list.newTicket")]})]}),Me(),At(),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("form",{onSubmit:U,className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",placeholder:i("list.searchPlaceholder"),value:R,onChange:L=>$(L.target.value),className:"input w-full pl-10"})]}),e.jsx("button",{type:"submit",className:"btn btn-secondary",children:i("list.search")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(!B),className:`btn ${B?"btn-primary":"btn-secondary"} flex items-center gap-2`,children:[e.jsx(l.Filter,{className:"w-4 h-4"}),i("list.filters")]}),e.jsx(va,{viewMode:J,onChange:fe})]})]}),B&&e.jsxs("div",{className:`card p-4 grid grid-cols-1 ${ke()} gap-4`,children:[he&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.tenant","Workspace")}),e.jsxs("select",{value:Z,onChange:L=>{H(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTenants","All Workspaces")}),m.filter(L=>L.status==="Active").map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.status")}),e.jsxs("select",{value:q,onChange:L=>{C(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allStatuses")}),e.jsx("option",{value:"Open",children:i("tickets.statuses.Open")}),e.jsx("option",{value:"InProgress",children:i("tickets.statuses.InProgress")}),e.jsx("option",{value:"OnHold",children:i("tickets.statuses.OnHold")}),e.jsx("option",{value:"Resolved",children:i("tickets.statuses.Resolved")}),e.jsx("option",{value:"Closed",children:i("tickets.statuses.Closed")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.type")}),e.jsxs("select",{value:D,onChange:L=>{Y(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTypes")}),e.jsx("option",{value:"Bug",children:i("tickets.types.Bug")}),e.jsx("option",{value:"FeatureRequest",children:i("tickets.types.FeatureRequest")}),e.jsx("option",{value:"ApplicationRequest",children:i("tickets.types.ApplicationRequest")}),e.jsx("option",{value:"Support",children:i("tickets.types.Support")}),e.jsx("option",{value:"Question",children:i("tickets.types.Question")})]})]}),(t==="admin"||t==="assigned")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.priority")}),e.jsxs("select",{value:T,onChange:L=>{z(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allPriorities")}),e.jsx("option",{value:"Low",children:i("tickets.priorities.Low")}),e.jsx("option",{value:"Medium",children:i("tickets.priorities.Medium")}),e.jsx("option",{value:"High",children:i("tickets.priorities.High")}),e.jsx("option",{value:"Critical",children:i("tickets.priorities.Critical")})]})]})]}),j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})}):e.jsxs(e.Fragment,{children:[J==="table"&&Le(),J==="cards"&&ze(),J==="kanban"&&We()]}),!j&&I>1&&e.jsx(Na,{page:S,totalPages:I,totalCount:k,onPageChange:N})]})}exports.ActivityTimeline=_c;exports.AdminSidebar=Mi;exports.AppHeader=Nt;exports.AppLayout=ga;exports.AppSwitcher=ia;exports.AuthLayout=di;exports.AuthProvider=wr;exports.Avatar=wi;exports.Breadcrumb=gi;exports.CreateTicketButton=pa;exports.DataTable=vi;exports.DataView=yi;exports.DocPanelProvider=Qr;exports.DocsLayout=fa;exports.DynamicRouter=Dc;exports.EntityCard=Ns;exports.ErrorFallback=Ur;exports.ExtendablePage=co;exports.ExtensionProvider=Xr;exports.FavoritesBar=Fc;exports.FavoritesModal=Pa;exports.FavoritesProvider=Tr;exports.FeatureGate=Gi;exports.FeatureRouteGuard=ws;exports.Fill=Hr;exports.Footer=js;exports.GlobalErrorBoundary=zr;exports.Header=ys;exports.KanbanBoard=Ai;exports.KanbanCard=ja;exports.KanbanColumn=ya;exports.LanguageSwitcher=bs;exports.LicenseActivationDialog=wa;exports.LicenseContentBanner=ha;exports.LicenseGuard=Ca;exports.LicenseProvider=kr;exports.LicenseStatusBadge=Ki;exports.ModuleSidebar=xa;exports.NetworkError=ps;exports.NotificationBell=ua;exports.PAGE_KEYS=_;exports.PageHeader=Pi;exports.PageRegistry=O;exports.Pagination=Na;exports.PermissionMatrix=Ti;exports.ProtectedRoute=Sa;exports.ProviderCard=Ci;exports.PublicLayout=ba;exports.RoleBadge=Si;exports.RouteErrorBoundary=Bi;exports.SessionProvider=qr;exports.SessionWarningModal=_r;exports.SidebarProvider=Ir;exports.SignalRProvider=Mr;exports.SlaBadge=td;exports.Slot=Kr;exports.SlotFillProvider=Gr;exports.SmartStackProvider=mo;exports.StatusBadge=Ot;exports.TemplateCard=ki;exports.ThemeCustomizer=Ii;exports.ThemeProvider=vr;exports.ThemeSwitcher=Kt;exports.TicketConversation=Ra;exports.TicketDetailView=mu;exports.TicketSidebar=Ea;exports.TicketsListView=xu;exports.Tooltip=ma;exports.UnderDevelopment=Li;exports.UnlockReason=on;exports.UserSidebar=Oi;exports.ViewToggle=va;exports.WILDCARD_PERMISSION=jr;exports.adminApi=Ne;exports.api=E;exports.apiClient=Se;exports.authApi=Mt;exports.availabilityApi=Bd;exports.browserInfoService=Zr;exports.changeLanguage=xs;exports.createAdminApi=fr;exports.createSlotFill=so;exports.dashboardApi=Bo;exports.detectDeviceType=ka;exports.errorContextService=$t;exports.getClientIpAddress=Aa;exports.getTenantBadgeVariant=vs;exports.hasAllLicenseFeatures=Sr;exports.hasFullAccess=jt;exports.hasPermission=Un;exports.hasRouteAccess=Nr;exports.logService=Te;exports.matchesWildcard=Ct;exports.myTicketsApi=Fe;exports.notificationsApi=st;exports.parseUserAgent=cc;exports.rulesApi=Ud;exports.skillsApi=zd;exports.slaApi=da;exports.supportApi=je;exports.templatesApi=Lt;exports.tenantAnalyticsApi=cs;exports.ticketDraftService=Ge;exports.useActivePage=lo;exports.useAuth=Pe;exports.useClientContext=ho;exports.useCollapsibleState=go;exports.useDocPanel=Gt;exports.useEntityPermissions=na;exports.useExtensions=kt;exports.useFavorites=Ke;exports.useFeatureConfig=qt;exports.useFormFieldExtensions=ao;exports.useHasExtension=no;exports.useLicense=He;exports.useNavigation=Ce;exports.usePageOverride=Bt;exports.usePageTracking=sa;exports.usePermissionMatrix=No;exports.usePermissionSync=wo;exports.useRouteConfig=Po;exports.useSessionMonitor=Fr;exports.useSidebar=Ut;exports.useSignalR=ra;exports.useSignalRContext=Or;exports.useSlotFill=Br;exports.useSlotHasContent=to;exports.useTableColumnExtensions=ro;exports.useTenant=Ee;exports.useTenantUrl=Ze;exports.useTheme=St;exports.useTicketSignalR=aa;exports.useTicketingProvider=Cs;exports.useUserPermissions=Eo;exports.userApi=_t;exports.withPageOverride=io;exports.workloadApi=Kd;
48
- //# sourceMappingURL=index-vXiLh35n.js.map
46
+ `)}`;window.open(f,"_blank")},className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors text-[var(--text-secondary)]",title:r("common:buttons.reportBug"),children:e.jsx(l.Bug,{className:"w-5 h-5"})}),e.jsx("button",{onClick:s,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[m.map(({app:x,modules:f})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Xs,{name:x.icon||"Folder",className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:x.label})]}),e.jsx("div",{className:"space-y-1 ml-6",children:f.map(b=>{const g=i(b.id),y=!g&&!d;return e.jsxs("button",{onClick:()=>p(b,x),disabled:y,className:`w-full flex items-center gap-3 p-2.5 rounded-[var(--radius-button)] transition-all ${Oc(g,y)}`,children:[e.jsx("div",{className:`w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] ${g?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:e.jsx(Xs,{name:b.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:`flex-1 text-left text-sm ${g?"font-medium text-[var(--color-accent-700)]":"text-[var(--text-primary)]"}`,children:b.label}),g&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-600)]"})]},b.id)})})]},x.id)),m.length===0&&e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:r("common:favorites.noModules")})]}),e.jsx("div",{className:"p-4 border-t border-[var(--border-color)]",children:e.jsx("button",{onClick:s,className:"w-full px-4 py-2 bg-[var(--color-accent-600)] text-white rounded-[var(--radius-button)] hover:bg-[var(--color-accent-700)] transition-colors font-medium",children:r("common:actions.done")})})]})})}function Fc({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function _c({className:t=""}){const{t:s}=ne.useTranslation(["common"]),r=w.useNavigate(),{favorites:a,maxFavorites:o}=Ke(),{triggerExpand:c}=Ke(),{menu:i}=Ce(),[d,u]=n.useState(!1),m=o-a.length,p=f=>{if(i)for(const b of i.applications){const g=b.modules.find(y=>y.id===f.id);if(g?.sections?.length){const y=[...g.sections].sort((h,j)=>h.displayOrder-j.displayOrder)[0];if(y.route)return y.route}}return f.route},x=f=>{const b=p(f);b&&(c(),r(b))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("common:favorites.quickAccess")})]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] rounded-[var(--radius-button)] transition-colors",children:[e.jsx(l.Settings2,{className:"w-3.5 h-3.5"}),s("common:favorites.manage")]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1",children:[a.map(f=>e.jsxs("button",{onClick:()=>x(f),className:"flex flex-col items-center gap-1.5 min-w-[80px] p-3 bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-all group",title:`${f.applicationLabel} - ${f.label}`,children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--color-accent-100)] text-[var(--color-accent-600)] group-hover:bg-[var(--color-accent-600)] group-hover:text-white transition-colors",children:e.jsx(Fc,{name:f.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] truncate max-w-[70px]",children:f.label})]},f.id)),Array.from({length:m}).map((f,b)=>e.jsxs("button",{onClick:()=>u(!0),className:"flex flex-col items-center justify-center gap-1.5 min-w-[80px] p-3 border-2 border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--bg-tertiary)] text-[var(--text-muted)] group-hover:bg-[var(--color-accent-100)] group-hover:text-[var(--color-accent-600)] transition-colors",children:e.jsx(l.Plus,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]",children:s("common:favorites.add")})]},`empty-slot-${b}`))]})]}),e.jsx(Ra,{isOpen:d,onClose:()=>u(!1)})]})}function Uc({activities:t,loading:s=!1}){return s?e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(r=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-8 h-8 bg-[var(--bg-secondary)] rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-[var(--bg-secondary)] rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-[var(--bg-secondary)] rounded w-1/4"})]})]},`skeleton-${r}`))}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(l.RefreshCcw,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No activity recorded yet"})]}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-4",children:t.map((r,a)=>e.jsx(qc,{activity:r,isLast:a===t.length-1},r.id))})]})}function qc({activity:t,isLast:s}){const{icon:r,color:a,bgColor:o}=Gc(t.action),c=r;return e.jsxs("div",{className:"relative flex gap-4 pl-0",children:[e.jsx("div",{className:`relative z-10 w-8 h-8 rounded-full flex items-center justify-center ${o}`,children:e.jsx(c,{className:`w-4 h-4 ${a}`})}),e.jsx("div",{className:"flex-1 pb-4 ",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm",children:[t.changedByUserName?e.jsx("span",{className:"font-medium",children:t.changedByUserName}):e.jsx("span",{className:"font-medium text-[var(--text-secondary)]",children:"System"})," ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:ed(t)})]}),t.fieldChanged&&t.oldValue&&t.newValue&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 bg-[var(--error-bg)] text-[var(--error-text)] rounded line-through",children:t.oldValue}),e.jsx(l.ArrowRight,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"px-2 py-0.5 bg-[var(--success-bg)] text-[var(--success-text)] rounded",children:t.newValue})]})]}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] whitespace-nowrap",children:td(t.createdAt)})]})})]})}const Bc={Created:{icon:l.PlusCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},StatusChanged:{icon:l.RefreshCcw,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},PriorityChanged:{icon:l.AlertTriangle,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},Assigned:{icon:l.UserPlus,color:"text-[var(--accent-text)]",bgColor:"bg-[var(--accent-bg)]"},Commented:{icon:l.MessageSquare,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},AttachmentAdded:{icon:l.Paperclip,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Resolved:{icon:l.CheckCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},Closed:{icon:l.XCircle,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Reopened:{icon:l.RefreshCcw,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},SlaBreached:{icon:l.AlertTriangle,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Escalated:{icon:l.TrendingUp,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Updated:{icon:l.Edit,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},Deleted:{icon:l.Trash2,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},OnHold:{icon:l.Pause,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},InProgress:{icon:l.Play,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"}},zc={icon:l.RefreshCcw,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"};function Gc(t){return Bc[t]||zc}const Kc=t=>t.oldValue&&t.newValue?`changed status from ${t.oldValue} to ${t.newValue}`:"changed the status",Hc=t=>t.oldValue&&t.newValue?`changed priority from ${t.oldValue} to ${t.newValue}`:"changed the priority",Vc=t=>t.newValue?`assigned to ${t.newValue}`:"unassigned the ticket",Wc=t=>t.newValue==="internal"?"added an internal note":"added a comment",Xc=t=>t.newValue?`added attachment: ${t.newValue}`:"added an attachment",Yc=t=>t.newValue==="response"?"Response SLA was breached":"Resolution SLA was breached",Jc=t=>t.newValue?`escalated to ${t.newValue}`:"escalated this ticket",Qc=t=>t.fieldChanged?`updated ${t.fieldChanged}`:"updated the ticket",Zc={Created:()=>"created this ticket",StatusChanged:Kc,PriorityChanged:Hc,Assigned:Vc,Commented:Wc,AttachmentAdded:Xc,Resolved:()=>"resolved this ticket",Closed:()=>"closed this ticket",Reopened:()=>"reopened this ticket",SlaBreached:Yc,Escalated:Jc,Updated:Qc,OnHold:()=>"put this ticket on hold",InProgress:()=>"started working on this ticket"};function ed(t){const s=Zc[t.action];return s?s(t):t.action.toLowerCase()}function td(t){const s=new Date(t),a=new Date().getTime()-s.getTime(),o=Math.floor(a/6e4),c=Math.floor(o/60),i=Math.floor(c/24);return o<1?"Just now":o<60?`${o}m ago`:c<24?`${c}h ago`:i<7?`${i}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function sd({responseDueAt:t,resolutionDueAt:s,responseBreached:r,resolutionBreached:a,firstResponseAt:o,isPaused:c,responseSlaPercentage:i=0,resolutionSlaPercentage:d=0,showDetails:u=!1}){const m=new Date,p=new Date(t),x=new Date(s),f=p.getTime()-m.getTime(),b=x.getTime()-m.getTime(),g=!!o;let y="ok",h="green",j=l.CheckCircle;c?(y="paused",h="gray",j=l.Pause):r||a?(y="breached",h="red",j=l.XCircle):(!g&&f<1800*1e3||b<3600*1e3)&&(y="warning",h="yellow",j=l.AlertTriangle);const v={green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",gray:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return u?e.jsxs("div",{className:`p-3 rounded-lg border ${v[h]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Response"}),r&&e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}),!r&&g&&e.jsx("span",{className:"text-[var(--success-text)] font-medium",children:"Completed"}),!r&&!g&&e.jsx("span",{children:Js(f)})]}),!g&&!r&&e.jsx(Ys,{percentage:i})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Resolution"}),a?e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}):e.jsx("span",{children:Js(b)})]}),!a&&e.jsx(Ys,{percentage:d})]})]})]}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ${v[h]}`,children:[e.jsx(j,{className:"w-3 h-3"}),y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})}function Ys({percentage:t}){const s=()=>t>=90?"bg-[var(--error-text)]":t>=75?"bg-[var(--warning-text)]":"bg-[var(--success-text)]";return e.jsx("div",{className:"h-1.5 bg-white/50 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${s()}`,style:{width:`${Math.min(t,100)}%`}})})}function Js(t){if(t<=0)return"Overdue";const s=Math.floor(t/(1e3*60)),r=Math.floor(s/60),a=Math.floor(r/24);if(a>0){const o=r%24;return o>0?`${a}d ${o}h`:`${a}d`}if(r>0){const o=s%60;return o>0?`${r}h ${o}m`:`${r}h`}return`${s}m`}const Qs={Greeting:"bg-[var(--info-bg)] text-[var(--info-text)]",Acknowledgment:"bg-[var(--success-bg)] text-[var(--success-text)]",RequestInfo:"bg-[var(--warning-bg)] text-[var(--warning-text)]",InProgress:"bg-[var(--info-bg)] text-[var(--info-text)]",Resolution:"bg-[var(--accent-bg)] text-[var(--accent-text)]",Escalation:"bg-[var(--warning-bg)] text-[var(--warning-text)]",OnHold:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Closure:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Rejection:"bg-[var(--error-bg)] text-[var(--error-text)]",General:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"},rd=[{code:"fr",label:"Français"},{code:"en",label:"English"},{code:"de",label:"Deutsch"},{code:"it",label:"Italiano"}];function ad({isOpen:t,onClose:s,onSelect:r,ticketVariables:a}){const{t:o,i18n:c}=ne.useTranslation("support"),[i,d]=n.useState([]),[u,m]=n.useState(!1),[p,x]=n.useState(null),[f,b]=n.useState(""),[g,y]=n.useState(""),[h,j]=n.useState(c.language?.substring(0,2)||"fr"),[v,S]=n.useState([]),N=n.useCallback(A=>{m(!0),Promise.all([Et.getAll(void 0,!0,A),Et.getCategories()]).then(([R,$])=>{d(R),S($)}).catch(console.error).finally(()=>m(!1))},[]);n.useEffect(()=>{t&&(j(c.language?.substring(0,2)||"fr"),N(c.language?.substring(0,2)||"fr"))},[t,c.language,N]);const I=A=>{j(A),N(A)};if(!t)return null;const P=i.filter(A=>{const R=!f||A.title.toLowerCase().includes(f.toLowerCase())||A.content.toLowerCase().includes(f.toLowerCase()),$=!g||A.category===g;return R&&$}),k=async A=>{try{x(A.id);const R=await Et.render(A.id,a);r(R.content),s()}catch(R){console.error("Failed to render template:",R)}finally{x(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:s,onKeyDown:A=>A.key==="Escape"&&s(),role:"presentation",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-xl shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:A=>A.stopPropagation(),role:"presentation",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-[var(--color-primary-500)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:o("templatePicker.title")})]}),e.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-[var(--bg-secondary)]",children:e.jsx(l.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("div",{className:"flex gap-1",children:rd.map(A=>e.jsx("button",{onClick:()=>I(A.code),className:`px-2 py-1 text-xs rounded transition-colors ${h===A.code?"bg-[var(--color-primary-500)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:A.label},A.code))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(l.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:f,onChange:A=>b(A.target.value),placeholder:o("templatePicker.searchPlaceholder"),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg outline-none focus:ring-1 focus:ring-[var(--color-primary-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("button",{onClick:()=>y(""),className:`px-2 py-1 text-xs rounded-full transition-colors ${g?"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]":"bg-[var(--color-primary-500)] text-white"}`,children:o("templatePicker.allCategories")}),v.map(A=>e.jsx("button",{onClick:()=>y(A===g?"":A),className:`px-2 py-1 text-xs rounded-full transition-colors ${A===g?"bg-[var(--color-primary-500)] text-white":`${Qs[A]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"} hover:opacity-80`}`,children:o(`templates.categories.${A}`,{defaultValue:A})},A))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}),!u&&P.length===0&&e.jsx("p",{className:"text-center py-8 text-sm text-[var(--text-tertiary)]",children:o("templatePicker.noResults")}),!u&&P.length>0&&e.jsx("div",{className:"space-y-1",children:P.map(A=>e.jsxs("button",{onClick:()=>k(A),disabled:p!==null,className:"w-full text-left p-3 rounded-lg hover:bg-[var(--bg-secondary)] transition-colors group disabled:opacity-50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full ${Qs[A.category]||"bg-[var(--bg-secondary)]"}`,children:o(`templates.categories.${A.category}`,{defaultValue:A.category})}),e.jsx("span",{className:"font-medium text-sm text-[var(--text-primary)]",children:A.title}),p===A.id&&e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin ml-auto"})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] line-clamp-2",children:A.content})]},A.id))})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)]",children:e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center",children:o("templatePicker.selectTemplate")})})]})})}const Zs={Created:{icon:l.Clock,color:"var(--color-primary-500)",labelKey:"history.actions.Created"},StatusChanged:{icon:l.ArrowRightLeft,color:"var(--info-text)",labelKey:"history.actions.StatusChanged"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)",labelKey:"history.actions.PriorityChanged"},Assigned:{icon:l.UserPlus,color:"var(--success-text)",labelKey:"history.actions.Assigned"},Unassigned:{icon:l.UserPlus,color:"var(--text-secondary)",labelKey:"history.actions.Unassigned"},Commented:{icon:l.MessageSquare,color:"var(--color-primary-500)",labelKey:"history.actions.Commented"},InternalCommented:{icon:l.MessageSquare,color:"var(--warning-text)",labelKey:"history.actions.InternalCommented"},AttachmentAdded:{icon:l.Paperclip,color:"var(--success-text)",labelKey:"history.actions.AttachmentAdded"},AttachmentRemoved:{icon:l.Paperclip,color:"var(--error-text)",labelKey:"history.actions.AttachmentRemoved"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.Resolved"},Closed:{icon:l.XCircle,color:"var(--text-secondary)",labelKey:"history.actions.Closed"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)",labelKey:"history.actions.Reopened"},Rejected:{icon:l.XCircle,color:"var(--error-text)",labelKey:"history.actions.Rejected"},SlaResponseBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResponseBreached"},SlaResolutionBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResolutionBreached"},Escalated:{icon:l.ArrowRightLeft,color:"var(--warning-text)",labelKey:"history.actions.Escalated"},TitleChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.TitleChanged"},DescriptionChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.DescriptionChanged"},TypeChanged:{icon:l.ArrowRightLeft,color:"var(--text-secondary)",labelKey:"history.actions.TypeChanged"},SatisfactionSubmitted:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.SatisfactionSubmitted"}},Ea=(t,s,r)=>{const a=new Date(t),c=new Date().getTime()-a.getTime(),i=Math.floor(c/6e4),d=Math.floor(c/36e5),u=Math.floor(c/864e5);return i<1?s("history.timeAgo.now"):i<60?s("history.timeAgo.minutes",{count:i}):d<24?s("history.timeAgo.hours",{count:d}):u<7?s("history.timeAgo.days",{count:u}):a.toLocaleDateString(r,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})},nd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,er=t=>t?.startsWith("image/")||!1,od=(t,s)=>t?"px-4 py-2.5 shadow-sm rounded-2xl bg-[var(--warning-bg)] border border-[var(--warning-border)]":s?"px-4 py-2.5 shadow-sm rounded-2xl rounded-tr-md bg-[var(--color-accent-600)] text-white":"px-4 py-2.5 shadow-sm rounded-2xl rounded-tl-md bg-[var(--bg-card)] border border-[var(--border-color)]";function id(t,s,r){const a=[];(r?t:t.filter(i=>!i.isInternal)).forEach(i=>{a.push({type:"comment",id:`comment-${i.id}`,timestamp:new Date(i.createdAt),data:i})});const c=["Commented","InternalCommented"];return s.filter(i=>!c.includes(i.action)).forEach(i=>{a.push({type:"activity",id:`activity-${i.id}`,timestamp:new Date(i.createdAt),data:i})}),a.sort((i,d)=>i.timestamp.getTime()-d.timestamp.getTime()),a}function ld({activity:t,t:s,locale:r}){const a=Zs[t.action]||Zs.Created,o=a.icon;return e.jsx("div",{className:"flex justify-center my-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm",children:[e.jsx(o,{className:"w-4 h-4",style:{color:a.color}}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s(a.labelKey)}),t.newValue&&t.action==="StatusChanged"&&e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["→ ",t.newValue]}),t.newValue&&t.action==="Assigned"&&e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t.newValue}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Ea(t.createdAt,s,r)})]})})}const cd=t=>{const s=t.trim().split(/\s+/);return s.length>=2?((s[0]?.at(0)??"")+(s.at(-1)?.at(0)??"")).toUpperCase():t.slice(0,2).toUpperCase()},dd=t=>{const s=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];let r=0;for(let a=0;a<t.length;a++)r=t.charCodeAt(a)+((r<<5)-r);return s[Math.abs(r)%s.length]};function tr({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const x=new AbortController;return Se.get(t,{responseType:"blob",signal:x.signal}).then(f=>{if(p){const b=URL.createObjectURL(f.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,x.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Image,{className:"w-6 h-6 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}function ud({comment:t,isOwn:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:i,locale:d}){const[u,m]=n.useState(null),p=new Date(t.createdAt).getTime(),x=a.filter(h=>{const j=new Date(h.createdAt).getTime();return Math.abs(j-p)<6e4}),f=x.filter(h=>er(h.contentType)),b=x.filter(h=>!er(h.contentType)),g=cd(t.userName),y=dd(t.userName);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex gap-3 mb-4 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-white text-sm font-semibold shadow-sm",style:{backgroundColor:y},title:t.userName,children:g}),e.jsxs("div",{className:`flex flex-col max-w-[70%] ${s?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex items-center gap-2 mb-1 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t.userName}),r&&t.isInternal&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:i("conversation.internalNoteLabel")}),t.isEdited&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:i("conversation.edited")})]}),e.jsxs("div",{className:od(t.isInternal||!1,s),children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:t.content}),f.length>0&&e.jsx("div",{className:`mt-3 grid gap-2 ${f.length>1?"grid-cols-2":"grid-cols-1"}`,children:f.map(h=>e.jsxs("button",{className:"relative cursor-pointer rounded-lg overflow-hidden group",onClick:()=>m(h),type:"button",children:[e.jsx(tr,{src:o(h),alt:h.fileName,className:"w-full h-32 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},h.id))}),b.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:b.map(h=>e.jsxs("button",{onClick:()=>c(h),className:`flex items-center gap-2 w-full p-2 rounded-lg transition-colors ${s&&!t.isInternal?"bg-white/10 hover:bg-white/20":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:[e.jsx(l.FileText,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs truncate flex-1 text-left",children:h.fileName}),e.jsx("span",{className:"text-xs opacity-70",children:nd(h.fileSize)}),e.jsx(l.Download,{className:"w-3.5 h-3.5"})]},h.id))})]}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 px-1",children:Ea(t.createdAt,i,d)})]})]}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>m(null),onKeyDown:h=>h.key==="Escape"&&m(null),role:"presentation",children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] w-full",children:[e.jsx("button",{onClick:()=>m(null),className:"absolute -top-10 right-0 text-white hover:text-gray-300",children:e.jsx(l.X,{className:"w-6 h-6"})}),e.jsx(tr,{src:o(u),alt:u?.fileName,className:"max-w-full max-h-[80vh] mx-auto object-contain rounded-lg",onClick:h=>h.stopPropagation()}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-4",children:[e.jsx("p",{className:"text-white text-sm",children:u.fileName}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),c(u)},className:"btn btn-secondary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),i("conversation.download")]})]})]})})]})}const md=(t,s,r)=>t?r("conversation.internalPlaceholder","Ajouter une note interne..."):s?r("conversation.supportPlaceholder","Répondre au client..."):r("conversation.clientPlaceholder","Écrire un message..."),pd=t=>`flex items-end gap-2 rounded-xl border ${t?"border-[var(--warning-border)] bg-[var(--warning-bg)]/30":"border-[var(--border-color)] bg-[var(--bg-secondary)]"} p-2`,xd=(t,s)=>`p-2.5 rounded-lg transition-colors ${t?"bg-[var(--color-primary-600)] text-white hover:bg-[var(--color-primary-700)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"} disabled:opacity-50`;function hd({isConnected:t,commentCount:s,t:r}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.MessageSquare,{className:"w-5 h-5 text-[var(--color-accent-600)]"}),e.jsx("h2",{className:"font-semibold",children:r("conversation.title","Conversation")}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["(",s,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:r(t?"conversation.realtimeActive":"conversation.realtimeInactive"),children:[t?e.jsx(l.Wifi,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(l.WifiOff,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:`text-xs ${t?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:r(t?"conversation.live":"conversation.offline")})]})]})}function gd({t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-[var(--text-secondary)]",children:[e.jsx(l.MessageSquare,{className:"w-12 h-12 mb-3 opacity-50"}),e.jsx("p",{children:t("conversation.empty","Aucun message pour le moment")}),e.jsx("p",{className:"text-sm mt-1",children:t("conversation.startHint","Commencez la conversation ci-dessous")})]})}function fd({timeline:t,currentUserName:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,messagesEndRef:i,t:d,locale:u}){return e.jsxs(e.Fragment,{children:[t.map(m=>{if(m.type==="activity")return e.jsx(ld,{activity:m.data,t:d,locale:u},m.id);const p=m.data,x=p.userName===s;return e.jsx(ud,{comment:p,isOwn:x,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:d,locale:u},m.id)}),e.jsx("div",{ref:i})]})}function bd({isInternalComment:t,onToggle:s,t:r}){return e.jsx("div",{className:"mb-2",children:e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a=>s(a.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:`text-sm ${t?"text-[var(--warning-text)] font-medium":"text-[var(--text-secondary)]"}`,children:r("conversation.internalNote","Note interne (invisible pour le client)")})]})})}function vd({newComment:t,onCommentChange:s,onKeyDown:r,onSend:a,isInternalComment:o,onInternalToggle:c,sending:i,isSupport:d,textareaRef:u,ticketVariables:m,onOpenTemplatePicker:p,t:x}){const f=t.trim();return e.jsxs("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-card)] p-3",children:[d&&e.jsx(bd,{isInternalComment:o,onToggle:c,t:x}),e.jsxs("div",{className:pd(o),children:[e.jsx("textarea",{ref:u,value:t,onChange:b=>s(b.target.value),onKeyDown:r,placeholder:md(o,d,x),className:"flex-1 bg-transparent border-none outline-none resize-none text-sm min-h-[24px] max-h-[150px] py-1 px-2",rows:1}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&m&&p&&e.jsx("button",{onClick:p,className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-primary-500)] hover:bg-[var(--bg-tertiary)] transition-colors",title:x("templatePicker.buttonTitle"),children:e.jsx(l.FileText,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,disabled:!f||i,className:xd(!!f),children:i?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Send,{className:"w-5 h-5"})})]})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-2 text-center",children:x("conversation.hint","Appuyez sur Entrée pour envoyer, Maj+Entrée pour un saut de ligne")})]})}function yd({t}){return e.jsx("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-secondary)] p-4 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t("conversation.closed","Ce ticket est fermé. Aucun nouveau message ne peut être ajouté.")})})}function Ia({comments:t,activities:s,attachments:r,isSupport:a,isClosed:o,isConnected:c,currentUserName:i,ticketVariables:d,onAddComment:u,onDownloadAttachment:m,getAttachmentUrl:p}){const{t:x,i18n:f}=ne.useTranslation("support"),[b,g]=n.useState(""),[y,h]=n.useState(!1),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useRef(null),P=n.useRef(null),k=id(t,s,a),A=t.filter(C=>a||!C.isInternal).length;n.useEffect(()=>{I.current?.scrollIntoView({behavior:"smooth"})},[k.length]),n.useEffect(()=>{P.current&&(P.current.style.height="auto",P.current.style.height=`${Math.min(P.current.scrollHeight,150)}px`)},[b]);const R=async()=>{if(!(!b.trim()||j))try{v(!0),await u(b,y),g(""),h(!1)}finally{v(!1)}},$=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),R())},U=C=>{g(D=>D?D+`
47
+ `+C:C)};return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx(hd,{isConnected:c,commentCount:A,t:x}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 bg-[var(--bg-primary)]",children:k.length===0?e.jsx(gd,{t:x}):e.jsx(fd,{timeline:k,currentUserName:i,isSupport:a,attachments:r,getAttachmentUrl:p,onDownloadAttachment:m,messagesEndRef:I,t:x,locale:f.language})}),o?e.jsx(yd,{t:x}):e.jsx(vd,{newComment:b,onCommentChange:g,onKeyDown:$,onSend:R,isInternalComment:y,onInternalToggle:h,sending:j,isSupport:a,textareaRef:P,ticketVariables:d,onOpenTemplatePicker:a&&d?()=>N(!0):void 0,t:x}),d&&e.jsx(ad,{isOpen:S,onClose:()=>N(!1),onSelect:U,ticketVariables:d})]})}const sr=t=>{const s=t.contentType?.toLowerCase()||"",a=t.fileName.toLowerCase().split(".").pop()||"";if(s.startsWith("image/"))return"image";if(s==="application/pdf")return"pdf";if(s.startsWith("text/")||s==="application/json")return"text";if(s.startsWith("video/"))return"video";if(s.startsWith("audio/"))return"audio";const o=["png","jpg","jpeg","gif","webp","svg","bmp","ico"],c=["txt","csv","json","md","xml","log","html","css","js","ts"],i=["mp4","webm","ogg","mov","avi"],d=["mp3","wav","ogg","aac","m4a"];return o.includes(a)?"image":a==="pdf"?"pdf":c.includes(a)?"text":i.includes(a)?"video":d.includes(a)?"audio":"unknown"},rr=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`;function jd({attachment:t,getUrl:s,onClose:r,onDownload:a}){const{t:o}=ne.useTranslation("support"),[c,i]=n.useState(1),[d,u]=n.useState(0),[m,p]=n.useState(!0),[x,f]=n.useState(null),[b,g]=n.useState(null),[y,h]=n.useState(!1),[j,v]=n.useState(null),S=n.useRef(null),N=t?sr(t):"unknown";n.useEffect(()=>{if(S.current?.id===t?.id||(S.current=t,j&&URL.revokeObjectURL(j),i(1),u(0),p(!0),f(null),g(null),v(null),h(!1),!t))return;const $=sr(t),U=s(t),C=new AbortController;return $==="text"?Se.get(U,{signal:C.signal,responseType:"text"}).then(D=>{g(D.data),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="image"||$==="video"||$==="audio"?Se.get(U,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="pdf"?Se.get(U,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(f(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):p(!1),()=>{C.abort()}},[t,s,o]),n.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]),n.useEffect(()=>{if(!t)return;const $=U=>{U.key==="Escape"&&(y?h(!1):r()),(U.key==="+"||U.key==="=")&&(U.preventDefault(),i(C=>Math.min(C+.25,3))),U.key==="-"&&(U.preventDefault(),i(C=>Math.max(C-.25,.25))),U.key==="r"&&!U.ctrlKey&&!U.metaKey&&(U.preventDefault(),u(C=>(C+90)%360)),U.key==="f"&&(U.preventDefault(),h(C=>!C))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,y,r]);const I=n.useCallback(()=>i($=>Math.min($+.25,3)),[]),P=n.useCallback(()=>i($=>Math.max($-.25,.25)),[]),k=n.useCallback(()=>u($=>($+90)%360),[]);if(!t)return null;const A=()=>{if(m&&N!=="pdf"&&N!=="image"&&N!=="video"&&N!=="audio")return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(x)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 text-[var(--warning-text)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:x}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]});switch(N){case"image":return e.jsx("div",{className:"relative flex items-center justify-center h-full overflow-auto p-4",children:j?e.jsx("img",{src:j,alt:t.fileName,className:"max-w-none transition-transform duration-200",style:{transform:`scale(${c}) rotate(${d}deg)`,maxHeight:y?"90vh":"70vh"},onClick:$=>$.stopPropagation()}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"pdf":return e.jsx("div",{className:"h-full w-full",children:j?e.jsx("iframe",{src:`${j}#toolbar=1&navpanes=0`,className:"w-full h-full border-0 rounded",title:t.fileName}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"text":return e.jsx("div",{className:"h-full overflow-auto p-4",children:e.jsx("pre",{className:"text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words bg-[var(--bg-secondary)] p-4 rounded-lg",children:b})});case"video":return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:j?e.jsx("video",{src:j,controls:!0,className:"max-w-full max-h-[70vh] rounded-lg",children:o("filePreview.videoNotSupported","Votre navigateur ne supporte pas la lecture vidéo.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"audio":return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6 p-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[var(--color-accent-500)]/20 flex items-center justify-center",children:e.jsx(l.File,{className:"w-12 h-12 text-[var(--color-accent-500)]"})}),e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.fileName}),j?e.jsx("audio",{src:j,controls:!0,className:"w-full max-w-md",children:o("filePreview.audioNotSupported","Votre navigateur ne supporte pas la lecture audio.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})})]});default:return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(l.FileText,{className:"w-10 h-10 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)] mb-1",children:t.fileName}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:rr(t.fileSize)})]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o("filePreview.noPreview","Aperçu non disponible pour ce type de fichier")}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]})}},R=e.jsxs("div",{className:"fixed inset-0 bg-black/90 backdrop-blur-sm flex flex-col z-[100]",onClick:r,onKeyDown:$=>{$.key==="Escape"&&r()},role:"dialog","aria-modal":"true","aria-label":t.fileName,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50",onClick:$=>$.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-white/70 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.fileName}),e.jsx("p",{className:"text-xs text-white/50",children:rr(t.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomOut","Zoom arrière (-)")||"Zoom out",children:e.jsx(l.ZoomOut,{className:"w-5 h-5"})}),e.jsxs("span",{className:"text-white/70 text-sm min-w-[3rem] text-center",children:[Math.round(c*100),"%"]}),e.jsx("button",{onClick:I,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomIn","Zoom avant (+)")||"Zoom in",children:e.jsx(l.ZoomIn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:k,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.rotate","Rotation (R)")||"Rotate",children:e.jsx(l.RotateCw,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-1"})]}),e.jsx("button",{onClick:()=>h($=>!$),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.fullscreen","Plein écran (F)")||"Fullscreen",children:y?e.jsx(l.Minimize2,{className:"w-5 h-5"}):e.jsx(l.Maximize2,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>a(t),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("common.close","Fermer (Échap)")||"Close",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",onClick:$=>$.stopPropagation(),children:A()}),e.jsx("div",{className:"px-4 py-2 bg-black/50 text-center",onClick:$=>$.stopPropagation(),children:e.jsx("p",{className:"text-xs text-white/40",children:o("filePreview.shortcuts","Raccourcis: Échap pour fermer • +/- pour zoomer • R pour rotation • F pour plein écran")})})]});return Ot.createPortal(R,document.body)}const ar={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},Nd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,nr=t=>t?.startsWith("image/")||!1;function wd({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const x=new AbortController;return Se.get(t,{responseType:"blob",signal:x.signal}).then(f=>{if(p){const b=URL.createObjectURL(f.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,x.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Image,{className:"w-4 h-4 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}const Sd={Created:{icon:l.Plus,color:"var(--success-text)"},StatusChanged:{icon:l.Edit,color:"var(--info-text)"},Assigned:{icon:l.UserCheck,color:"var(--color-accent-600)"},Unassigned:{icon:l.User,color:"var(--warning-text)"},Commented:{icon:l.MessageSquare,color:"var(--text-secondary)"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)"},Closed:{icon:l.XCircle,color:"var(--text-tertiary)"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)"},Escalated:{icon:l.ArrowUpCircle,color:"var(--error-text)"},Started:{icon:l.Play,color:"var(--info-text)"},Paused:{icon:l.Pause,color:"var(--warning-text)"}},Cd=(t,s)=>{const r=new Date(t),o=new Date().getTime()-r.getTime(),c=Math.floor(o/6e4),i=Math.floor(o/36e5),d=Math.floor(o/864e5);return c<1?s("sidebar.timeAgo.justNow",{defaultValue:"Just now"}):c<60?s("sidebar.timeAgo.minutes",{count:c}):i<24?s("sidebar.timeAgo.hours",{count:i}):d<7?s("sidebar.timeAgo.days",{count:d}):r.toLocaleDateString(void 0,{day:"numeric",month:"short"})},kd=10*1024*1024,or=[".pdf",".doc",".docx",".xls",".xlsx",".txt",".csv",".zip",".png",".jpg",".jpeg",".gif",".webp"];function lt({section:t,icon:s,title:r,count:a,isExpanded:o,onToggle:c}){return e.jsxs("button",{onClick:()=>c(t),className:"w-full flex items-center gap-2 py-2 px-3 hover:bg-[var(--bg-secondary)] transition-colors rounded-lg",children:[o?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx(s,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-sm flex-1 text-left",children:r}),a!==void 0&&a>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:a})]})}function La({ticket:t,attachments:s,activities:r,isSupport:a,saving:o,uploading:c,layout:i="compact",onAssign:d,onStatusChange:u,onResolve:m,onCloseTicket:p,onReopen:x,onEscalate:f,onDownloadAttachment:b,onUploadAttachment:g,getAttachmentUrl:y}){const{t:h}=ne.useTranslation("support"),[j,v]=n.useState(new Set(i==="grid"?["info","system","errors","attachments","actions","history"]:["info","attachments","actions"])),[S,N]=n.useState(null),[I,P]=n.useState(!1),[k,A]=n.useState(null),R=n.useRef(null),$=n.useCallback(M=>{if(M.type.startsWith("image/"))return!0;const re="."+M.name.split(".").pop()?.toLowerCase();return or.includes(re)},[]),U=n.useCallback(async M=>{if(!(!M||!g)){A(null);for(let re=0;re<M.length;re++){const F=M[re];if(F.size>kd){A(h("sidebar.fileTooLarge","File too large (max 10 MB)"));continue}if(!$(F)){A(h("sidebar.fileTypeNotAllowed","File type not allowed"));continue}try{await g(F)}catch{A(h("sidebar.uploadError","Upload failed"))}}}},[g,$,h]),C=n.useCallback(M=>{M.preventDefault(),M.stopPropagation()},[]),D=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!0)},[]),Y=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1)},[]),T=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1),U(M.dataTransfer.files)},[U]),B=s.filter(M=>nr(M.contentType)),Z=s.filter(M=>!nr(M.contentType)),H=t.clientContext,J=n.useCallback(M=>{v(re=>{const F=new Set(re);return F.has(M)?F.delete(M):F.add(M),F})},[]),fe=t.status==="Closed"||t.status==="Rejected",z=i==="grid",Q=z?"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden":"px-2 py-1 border-b border-[var(--border-color)]";return e.jsxs("div",{className:z?"":"h-full flex flex-col bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("div",{className:z?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4":"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"info",icon:l.FileText,title:h("details.info","Informations"),isExpanded:j.has("info"),onToggle:J}),j.has("info")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.type","Type")}),e.jsx("dd",{className:"font-medium",children:h(`tickets.types.${t.type}`,{defaultValue:t.type})})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.priority","Priority")}),e.jsx("dd",{children:e.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:ar[t.priority]?.bg,color:ar[t.priority]?.text},children:h(`tickets.priorities.${t.priority}`,{defaultValue:t.priority})})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.createdBy","Created by")}),e.jsx("dd",{children:t.createdByName||h("sidebar.unknown","Unknown")})]}),e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.assignedTo","Assigned to")}),e.jsxs("dd",{className:"flex flex-col items-end gap-1",children:[(t?.assignees?.length??0)>0?e.jsx("div",{className:"space-y-1",children:t?.assignees?.map(M=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-sm",children:M.fullName}),M.isPrimary&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--color-accent-600)] text-white rounded-md",children:h("sidebar.primary","primary")}),M.assignedViaGroupName&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-secondary)] rounded-md",children:["(",h("sidebar.viaGroup",{groupName:M.assignedViaGroupName}),")"]})]},M.userId))}):e.jsx("span",{className:"text-sm",children:h("sidebar.unassigned","Unassigned")}),d&&e.jsx("button",{onClick:d,className:"p-1 hover:bg-[var(--bg-secondary)] rounded mt-1",children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.createdAt","Created")}),e.jsx("dd",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),t.updatedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:h("sidebar.updatedAt","Updated")}),e.jsx("dd",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]})]})})]}),a&&H&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"system",icon:l.Monitor,title:h("details.systemInfo","Infos système"),isExpanded:j.has("system"),onToggle:J}),j.has("system")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[H?.sourceUrl&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),h("sidebar.url","URL")]}),e.jsx("p",{className:"text-xs font-mono break-all",children:H.sourceUrl})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[H.browser&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),h("sidebar.browser","Browser")]}),e.jsx("p",{className:"text-xs font-medium",children:H.browser.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.browser.version})]}),H.os&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Laptop,{className:"w-3 h-3"}),h("sidebar.os","OS")]}),e.jsx("p",{className:"text-xs font-medium",children:H.os.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.os.version})]})]}),H.device&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Smartphone,{className:"w-3 h-3"}),h("sidebar.device","Device")]}),e.jsxs("p",{className:"text-xs font-medium",children:[H.device.type||h("sidebar.defaultDeviceType","Desktop"),H.device.screenResolution&&` • ${H.device.screenResolution}`]})]})]})]}),a&&H&&(H?.recentErrors?.length??0)>0&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"errors",icon:l.Bug,title:h("details.errors","Erreurs"),count:H?.recentErrors?.length??0,isExpanded:j.has("errors"),onToggle:J}),j.has("errors")&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:H?.recentErrors?.slice(0,3).map((M,re)=>e.jsxs("div",{className:"p-2 bg-[var(--error-bg)]/30 border border-[var(--error-border)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(l.AlertTriangle,{className:"w-3 h-3 text-[var(--error-text)]"}),M.component&&e.jsx("span",{className:"text-xs px-1 py-0.5 bg-[var(--bg-secondary)] rounded",children:M.component})]}),e.jsx("p",{className:"text-xs font-medium text-[var(--error-text)] line-clamp-2",children:M.message})]},`error-${re}`))})]}),e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"attachments",icon:l.File,title:h("details.attachments","Pièces jointes"),count:s.length,isExpanded:j.has("attachments"),onToggle:J}),j.has("attachments")&&e.jsxs("div",{className:"px-3 pb-3",children:[B.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.Image,{className:"w-3 h-3"}),h("sidebar.images","Images")," (",B.length,")"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:B.map(M=>e.jsxs("button",{type:"button",className:"relative cursor-pointer rounded overflow-hidden border border-[var(--border-color)] aspect-square group",onClick:()=>N(M),children:[e.jsx(wd,{src:y(M),alt:M.fileName,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-5 h-5 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},M.id))})]}),Z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.FileText,{className:"w-3 h-3"}),h("sidebar.documents","Documents")," (",Z.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:Z.map(M=>e.jsxs("div",{className:"flex items-center gap-2 w-full p-2 bg-[var(--bg-secondary)] rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors group",children:[e.jsxs("button",{onClick:()=>N(M),className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[e.jsx(l.FileText,{className:"w-4 h-4 text-[var(--text-secondary)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs block truncate",children:M.fileName}),e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:Nd(M.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>N(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors opacity-0 group-hover:opacity-100",title:h("filePreview.view","Aperçu")||"View",children:e.jsx(l.Eye,{className:"w-3.5 h-3.5 text-[var(--color-accent-500)]"})}),e.jsx("button",{onClick:()=>b(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors",title:h("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})]},M.id))})]}),a&&!fe&&g&&e.jsxs("div",{children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:M=>U(M.target.files),accept:or.join(","),className:"hidden"}),e.jsx("div",{className:`border-2 border-dashed rounded-lg p-3 text-center transition-colors cursor-pointer ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)]"}`,onClick:()=>R.current?.click(),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),R.current?.click())},role:"button",tabIndex:0,onDragOver:C,onDragEnter:D,onDragLeave:Y,onDrop:T,children:c?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-1",children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:h("sidebar.uploading","Uploading...")})]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Plus,{className:"w-5 h-5 mx-auto mb-1 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:I?h("sidebar.dropHere","Drop here"):h("sidebar.addFile","Add a file")})]})}),k&&e.jsx("p",{className:"mt-2 text-xs text-[var(--error-text)]",children:k})]}),s.length===0&&(!a||fe||!g)&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center py-2",children:h("sidebar.noAttachments","No attachments")})]})]}),a&&!z&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"actions",icon:l.User,title:h("details.actions","Actions"),isExpanded:j.has("actions"),onToggle:J}),j.has("actions")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[t.status==="Open"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:h("sidebar.startProcessing","Start processing")}),t.status==="InProgress"&&e.jsxs(e.Fragment,{children:[u&&e.jsx("button",{onClick:()=>u("OnHold"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:h("sidebar.putOnHold","Put on hold")}),m&&e.jsxs("button",{onClick:m,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 mr-2"}),h("sidebar.resolve","Resolve")]})]}),t.status==="OnHold"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:h("sidebar.resume","Resume")}),t.status==="Resolved"&&p&&e.jsxs("button",{onClick:p,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.XCircle,{className:"w-4 h-4 mr-2"}),h("sidebar.closeTicket","Close ticket")]}),(t.status==="Closed"||t.status==="Resolved")&&x&&e.jsxs("button",{onClick:x,disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:[e.jsx(l.RotateCcw,{className:"w-4 h-4 mr-2"}),h("sidebar.reopen","Reopen")]}),!fe&&f&&e.jsxs("button",{onClick:f,disabled:o,className:"btn w-full text-sm py-2 border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),h("sidebar.escalate","Escalate")]}),o&&e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-primary-600)]"})})]})]}),a&&r.length>0&&e.jsxs("div",{className:z?Q:"px-2 py-1",children:[e.jsx(lt,{section:"history",icon:l.History,title:h("details.history","History"),count:r.length,isExpanded:j.has("history"),onToggle:J}),j.has("history")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-2 bottom-2 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-3",children:r.slice(0,10).map((M,re)=>{const F=Sd[M.action]||{icon:l.Edit,color:"var(--text-secondary)"},K=F.icon,V=h(`history.actions.${M.action}`,{defaultValue:M.action});return e.jsxs("div",{className:"relative flex gap-3 pl-1",children:[e.jsx("div",{className:"relative z-10 w-5 h-5 rounded-full flex items-center justify-center bg-[var(--bg-card)] border border-[var(--border-color)]",style:{color:F.color},children:e.jsx(K,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[var(--text-primary)]",children:[V,M.newValue&&e.jsxs("span",{className:"text-[var(--text-secondary)] font-normal",children:[" → ",M.newValue]})]}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:Cd(M.createdAt,h)})]})]},`activity-${M.action}-${re}`)})}),r.length>10&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center mt-3",children:h("sidebar.moreActivities",{count:r.length-10})})]})})]})]}),e.jsx(jd,{attachment:S,getUrl:y,onClose:()=>N(null),onDownload:b})]})}const es=["Open","InProgress","Resolved","Closed"],Je={Open:{label:"Ouvert",icon:l.Clock,color:"var(--warning-text)"},InProgress:{label:"En cours",icon:l.Play,color:"var(--info-text)"},OnHold:{label:"En attente",icon:l.Pause,color:"var(--warning-text)"},Resolved:{label:"Résolu",icon:l.CheckCircle,color:"var(--success-text)"},Closed:{label:"Fermé",icon:l.XCircle,color:"var(--text-secondary)"},Rejected:{label:"Rejeté",icon:l.AlertTriangle,color:"var(--error-text)"}},Ad=t=>new Date(t).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),Pd=t=>t.isActive?"ring-4 ring-opacity-30":t.isPast?"bg-[var(--success-bg)]":"bg-[var(--bg-secondary)] border-2 border-[var(--border-color)]",Td=(t,s)=>{if(t.isActive)return s.color;if(t.isPast)return"var(--success-bg)"},Rd=(t,s)=>({backgroundColor:Td(t,s),boxShadow:t.isActive?`0 0 0 4px ${s.color}30`:void 0}),Ed=t=>t.isActive?"white":t.isPast?"var(--success-text)":"var(--text-tertiary)",Id=t=>t.isActive?"text-[var(--text-primary)]":t.isPast?"text-[var(--success-text)]":"text-[var(--text-tertiary)]",Ld=(t,s)=>t.isPast?"var(--success-text)":t.isActive?s.color:"var(--border-color)";function $d({step:t,config:s}){const r=t.icon;return e.jsx("div",{className:`relative w-10 h-10 rounded-full flex items-center justify-center shrink-0 transition-all ${Pd(t)}`,style:Rd(t,s),children:e.jsx(r,{className:"w-5 h-5",style:{color:Ed(t)}})})}function Dd({step:t}){return e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:`text-xs font-medium ${Id(t)}`,children:t.label}),t.date&&(t.isActive||t.isPast)&&e.jsx("p",{className:"text-[10px] text-[var(--text-secondary)] mt-0.5",children:Ad(t.date)})]})}function Md({step:t,config:s,isLast:r}){return r?null:e.jsx("div",{className:"flex-1 h-0.5 mx-2 mt-[-20px]",style:{backgroundColor:Ld(t,s)}})}function Od({currentStatus:t,createdAt:s,resolvedAt:r,closedAt:a,activities:o=[],isSupport:c,saving:i,assignees:d,onAssign:u,onStatusChange:m,onResolve:p,onCloseTicket:x,onReopen:f,onEscalate:b}){const{t:g}=ne.useTranslation("support"),y=t==="Rejected",h=o.some(S=>S.action==="Reopened"),v=(()=>{if(y)return[{status:"Open",label:g("tickets.statuses.Open",Je.Open.label),icon:Je.Open.icon,date:s,isActive:!1,isPast:!0,isFuture:!1},{status:"Rejected",label:g("tickets.statuses.Rejected",Je.Rejected.label),icon:Je.Rejected.icon,date:a,isActive:!0,isPast:!1,isFuture:!1}];const S=es.indexOf(t),N=[],I={Open:s};o.filter(k=>k.action==="StatusChanged"&&k.newValue).forEach(k=>{k.newValue&&(I[k.newValue]=k.createdAt)}),r&&(I.Resolved=r),a&&(I.Closed=a);const P=o.some(k=>k.action==="StatusChanged"&&k.newValue==="OnHold");if(es.forEach(k=>{const A=Je[k],R=k===t?S:es.indexOf(k),$=k===t,U=R<S,C=R>S;N.push({status:k,label:g(`tickets.statuses.${k}`,{defaultValue:A.label}),icon:A.icon,date:I[k],isActive:$,isPast:U,isFuture:C})}),P){const k=N.findIndex(A=>A.status==="Resolved");N.splice(k,0,{status:"OnHold",label:g("tickets.statuses.OnHold",Je.OnHold.label),icon:Je.OnHold.icon,date:I.OnHold,isActive:t==="OnHold",isPast:t!=="OnHold"&&t!=="Open"&&t!=="InProgress",isFuture:!1})}return N})();return e.jsx("div",{className:"w-full px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[v.map((S,N)=>{const I=Je[S.status],P=N===v.length-1;return e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:`flex flex-col items-center ${S.isFuture?"opacity-40":""}`,children:[e.jsx($d,{step:S,config:I}),e.jsx(Dd,{step:S})]}),e.jsx(Md,{step:S,config:I,isLast:P})]},S.status)}),h&&e.jsxs("div",{className:"ml-2 flex items-center gap-1 text-[10px] text-[var(--warning-text)] shrink-0",children:[e.jsx(l.RotateCcw,{className:"w-3 h-3"}),e.jsx("span",{children:g("workflow.reopened","Réouvert")})]})]}),c&&e.jsx("div",{className:"w-px h-12 bg-[var(--border-color)] shrink-0"}),c&&e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[(d?.length??0)>0?e.jsxs("div",{className:"flex items-center -space-x-1.5",title:d?.map(S=>S.fullName).join(", "),children:[d?.slice(0,3).map(S=>e.jsx("div",{className:"w-7 h-7 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white text-[10px] font-medium border-2 border-[var(--bg-card)]",title:`${S.fullName}${S.isPrimary?` (${g("workflow.primary","principal")})`:""}${S.assignedViaGroupName?` (${g("workflow.viaGroup","via")} ${S.assignedViaGroupName})`:""}`,children:S.fullName.charAt(0).toUpperCase()},S.userId)),(d?.length??0)>3&&e.jsxs("div",{className:"w-7 h-7 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[10px] font-medium text-[var(--text-secondary)] border-2 border-[var(--bg-card)]",children:["+",(d?.length??0)-3]})]}):e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] italic",children:g("workflow.notAssigned","Non assigné")}),u&&e.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full border border-dashed border-[var(--border-color)] flex items-center justify-center hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-secondary)] transition-colors",title:g("workflow.assign","Assigner"),children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]}),i&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-primary-600)]"}),t==="Open"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.start","Commencer")]}),t==="InProgress"&&m&&e.jsxs("button",{onClick:()=>m("OnHold"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Pause,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.hold","En attente")]}),t==="InProgress"&&p&&e.jsxs("button",{onClick:p,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.CheckCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.resolve","Résoudre")]}),t==="OnHold"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.resume","Reprendre")]}),t==="Resolved"&&x&&e.jsxs("button",{onClick:x,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.XCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.close","Fermer")]}),(t==="Closed"||t==="Resolved")&&f&&e.jsxs("button",{onClick:f,disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.RotateCcw,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.reopen","Réouvrir")]}),t!=="Closed"&&t!=="Rejected"&&b&&e.jsxs("button",{onClick:b,disabled:i,className:"btn btn-sm text-xs border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.escalate","Escalader")]})]})]})})}const ct={Proposed:{border:"border-blue-500",bg:"bg-blue-50",text:"text-blue-900"},Approved:{border:"border-green-500",bg:"bg-green-50",text:"text-green-900"},Rejected:{border:"border-red-500",bg:"bg-red-50",text:"text-red-900"},Superseded:{border:"border-gray-400",bg:"bg-gray-50",text:"text-gray-700"}},ir={Proposed:l.Clock,Approved:l.CheckCircle,Rejected:l.XCircle,Superseded:l.AlertCircle};function Fd({ticketId:t,solutions:s,activeSolution:r,mode:a,onProposeSolution:o,onApproveSolution:c,onRejectSolution:i,isLoading:d}){const{t:u}=ne.useTranslation("support"),[m,p]=n.useState(!1),[x,f]=n.useState(""),[b,g]=n.useState(!1),[y,h]=n.useState(""),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useCallback(async()=>{if(!(!x.trim()||!o)){p(!0);try{await o(x),f("")}finally{p(!1)}}},[x,o]),P=n.useCallback(()=>{v(!0)},[]),k=n.useCallback(async()=>{if(!(!y.trim()||!i)){g(!0);try{await i(y),h(""),v(!1)}finally{g(!1)}}},[y,i]),A=R=>{if(!R.autoCloseAt)return null;const $=new Date(R.autoCloseAt),U=new Date,C=$.getTime()-U.getTime(),D=Math.ceil(C/(1e3*60*60*24));return D>0?D:0};return s.length===0&&a==="support"&&o?e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:x,onChange:R=>f(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!x.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:`rounded-lg border-2 p-4 ${ct[r.status].border} ${ct[r.status].bg}`,children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const R=ir[r.status];return e.jsx(R,{className:`w-5 h-5 ${ct[r.status].text}`})})(),e.jsxs("div",{children:[e.jsx("h4",{className:`font-semibold ${ct[r.status].text}`,children:u(`solution.status.${r.status.toLowerCase()}`,r.status)}),e.jsxs("p",{className:"text-sm opacity-75",children:[u("solution.solutionNumber","Solution #"),r.solutionNumber," - ",u("solution.proposedBy","Proposed by")," ",r.proposedByUserName||"Unknown"]})]})]})}),e.jsx("div",{className:"bg-white/50 rounded p-3 mb-3 max-h-32 overflow-y-auto",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:r.content})}),r.status==="Proposed"&&r.autoCloseAt&&e.jsx("div",{className:"mb-3 p-2 bg-yellow-100/50 border-l-2 border-yellow-500 rounded",children:e.jsxs("p",{className:"text-sm",children:[u("solution.autoCloseWarning","Will be auto-approved in")," ",e.jsxs("strong",{children:[A(r)," ",u("solution.autoCloseCountdown","days")]}),r.autoCloseWarningSent&&e.jsxs(e.Fragment,{children:[" (",u("solution.warningEmailSent","warning email sent"),")"]})]})}),r.status==="Approved"&&e.jsxs("p",{className:"text-sm",children:[u("solution.approvedBy","Approved by")," ",r.approvedByUserName||"Unknown"," on ",r.approvedAt&&new Date(r.approvedAt).toLocaleDateString()]}),r.status==="Rejected"&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm mb-2",children:[u("solution.rejectedBy","Rejected by")," ",r.rejectedByUserName||"Unknown"," on ",r.rejectedAt&&new Date(r.rejectedAt).toLocaleDateString()]}),r.rejectionReason&&e.jsxs("p",{className:"text-sm bg-white/30 p-2 rounded italic",children:[u("solution.rejectionReason","Reason"),": ",r.rejectionReason]})]}),a==="client"&&r.status==="Proposed"&&e.jsxs("div",{className:"mt-3 flex gap-2 justify-end",children:[e.jsx("button",{onClick:P,disabled:b||d,className:"btn btn-secondary text-sm py-1.5",children:u("solution.rejectSolution","Reject")}),e.jsx("button",{onClick:c,disabled:b||d||!c,className:"btn btn-primary text-sm py-1.5 flex items-center gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}),u("solution.acceptSolution","Approve")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.CheckCircle,{className:"w-3 h-3"}),u("solution.acceptSolution","Approve")]})})]})]}),a==="support"&&o&&!r&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h4",{className:"font-semibold mb-3",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:x,onChange:R=>f(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!x.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}),s.length>1&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(!S),className:"w-full flex items-center gap-2 p-4 hover:bg-[var(--bg-secondary)] transition-colors",children:[S?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsxs("h4",{className:"font-semibold",children:[u("solution.solutionHistory","Solution History")," (",s.length,")"]})]}),S&&e.jsx("div",{className:"border-t border-[var(--border-color)] p-4 space-y-3",children:s.map(R=>e.jsxs("div",{className:`rounded-lg border p-3 ${ct[R.status].border}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const $=ir[R.status];return e.jsx($,{className:`w-4 h-4 ${ct[R.status].text}`})})(),e.jsx("span",{className:"text-sm font-medium",children:u(`solution.status.${R.status.toLowerCase()}`,R.status)}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["#",R.solutionNumber]})]}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(R.proposedAt).toLocaleDateString()})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 line-clamp-2",children:R.content}),e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[u("solution.proposedBy","Proposed by")," ",R.proposedByUserName||"Unknown"]})]},R.id))})]}),s.length===0&&a==="client"&&e.jsx("div",{className:"text-center py-6 text-[var(--text-tertiary)]",children:e.jsx("p",{children:u("solution.noSolutions","No solutions proposed yet")})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg shadow-lg p-6 w-96 max-w-[90vw]",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.rejectSolution","Reject Solution")}),e.jsx("textarea",{value:y,onChange:R=>h(R.target.value),placeholder:u("solution.enterRejectReason","Enter reason for rejection..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:b}),e.jsxs("div",{className:"mt-4 flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>v(!1),disabled:b,className:"btn btn-secondary",children:u("common:cancel","Cancel")}),e.jsx("button",{onClick:k,disabled:!y.trim()||b,className:"btn btn-primary flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.rejectSolution","Reject")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),u("solution.rejectSolution","Reject")]})})]})]})})]})}const _d={getCached:t=>E.get(`/api/support/ai-routing/cached/${t}`)},$a={analyze:t=>E.get(`/api/support/ai-routing/analyze/${t}`)},Da={summarize:t=>E.post(`/api/support/ai-routing/summarize/${t}`)},Ma={applyRouting:(t,s)=>E.post(`/api/support/ai-routing/apply/${t}`,s)},lr=Object.freeze(Object.defineProperty({__proto__:null,analyzeApi:$a,cachedAiApi:_d,routingApi:Ma,summarizeApi:Da},Symbol.toStringTag,{value:"Module"}));function Oa({classification:t}){const{t:s}=ne.useTranslation("support");if(!t)return null;const r=o=>o>.8?"bg-[var(--success-bg)] text-[var(--success-text)]":o>.5?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]",a=o=>o>.8?s("aiClassification.confidence.high"):o>.5?s("aiClassification.confidence.medium"):s("aiClassification.confidence.low");return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)]",children:s(`tickets.types.${t.suggestedType}`)}),e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--warning-bg)] text-[var(--warning-text)]",children:s(`tickets.priorities.${t.suggestedPriority}`)}),e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${r(t.confidenceScore)}`,children:[a(t.confidenceScore)," (",Math.round(t.confidenceScore*100),"%)"]})]})}function Fa(t){const[s,r]=n.useState(t?.initialData??null),[a,o]=n.useState(!1),[c,i]=n.useState(null),d=n.useRef(null),u=n.useRef(!1);n.useEffect(()=>(u.current=!1,()=>{u.current=!0,d.current?.abort()}),[]);const m=n.useCallback(async f=>{d.current?.abort();const b=new AbortController;d.current=b,o(!0),i(null);try{const g=await f(b.signal);!u.current&&!b.signal.aborted&&r(g)}catch(g){!u.current&&!b.signal.aborted&&i(g instanceof Error?g.message:"Unknown error")}finally{!u.current&&!b.signal.aborted&&o(!1)}},[]),p=n.useCallback(()=>{d.current?.abort(),u.current||o(!1)},[]),x=n.useCallback(()=>{r(null),i(null),o(!1)},[]);return{data:s,loading:a,error:c,execute:m,cancel:p,reset:x}}function Ud({ticketId:t,cachedClassification:s,cachedRouting:r,cachedGeneratedAt:a,processing:o,onProcessingStart:c,onProcessingEnd:i}){const{t:d}=ne.useTranslation("support"),u=s||r?{classification:s??null,routingSuggestion:r??null,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:m,loading:p,error:x,execute:f,reset:b}=Fa({initialData:u}),[g,y]=n.useState(!1),h=n.useCallback(async()=>{c?.(),await f(async()=>{const N=await $a.analyze(t);return i?.(),N})},[t,f,c,i]),j=n.useCallback(async()=>{if(m?.routingSuggestion)try{y(!0);const N={assignToUserId:m.routingSuggestion.suggestedAgents[0]?.userId,assignToGroupId:m.routingSuggestion.suggestedGroupId??void 0,applyPriorityAdjustment:m.routingSuggestion.priorityAdjustment!==null};await Ma.applyRouting(t,N),b()}catch{}finally{y(!1)}},[m,b,d]);if(x&&!m)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:x}),e.jsxs("button",{onClick:h,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});if(!m)return o?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:d("aiRouting.processing")})]})}):e.jsxs("button",{onClick:h,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[p?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Sparkles,{className:"w-4 h-4"}),d("aiRouting.analyze")]});if(p&&!m)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!m.isAiAvailable){const N=m.errorCode?`aiRouting.errors.${m.errorCode}`:null,I=N&&d(N)!==N?d(N):m.errorMessage??d("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:I})]})})}if(!m.classification&&!m.routingSuggestion)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:m.errorMessage??d("aiRouting.notAvailable")}),e.jsxs("button",{onClick:h,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});const v=m?.routingSuggestion,S=a&&!p?new Date(a):null;return e.jsx("div",{className:"card p-6 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"space-y-4",children:[m?.errorMessage&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-[var(--warning-text)] bg-[var(--warning-bg)]/20 rounded p-2",children:[e.jsx(l.AlertCircle,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),e.jsx("p",{children:m.errorMessage})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.Sparkles,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-1"}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:d("aiRouting.suggestedRouting")}),e.jsxs("button",{onClick:h,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-1",title:d("aiRouting.refresh"),children:[p?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("aiRouting.refresh")]})]}),S&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:d("aiRouting.generatedAt",{date:S.toLocaleString()})}),e.jsxs("div",{className:"space-y-3",children:[m?.classification&&e.jsx(Oa,{classification:m.classification}),(v?.suggestedAgents?.length??0)>0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-2",children:d("aiRouting.suggestedAgents")}),e.jsx("div",{className:"space-y-1",children:v?.suggestedAgents?.map(N=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium",children:N.userName||N.userId}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[Math.round(N.matchScore*100),"%"]})]},N.userId))})]}),v?.suggestedGroupName&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.suggestedGroup")}),e.jsx("p",{className:"font-medium",children:v.suggestedGroupName})]}),v?.reasoning&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.reasoning")}),e.jsx("p",{className:"italic",children:v.reasoning})]}),e.jsx("div",{className:"pt-3 border-t border-[var(--border-color)] flex gap-2",children:v&&e.jsxs("button",{onClick:j,disabled:g,className:"btn btn-primary btn-sm flex items-center gap-2 flex-1 justify-center",children:[g?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Check,{className:"w-4 h-4"}),d("aiRouting.apply")]})})]})]})]})]})})}function qd({ticketId:t,cachedSummary:s,cachedGeneratedAt:r,processing:a,onProcessingStart:o,onProcessingEnd:c}){const{t:i}=ne.useTranslation("support"),d=s?{summary:s,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:u,loading:m,error:p,execute:x}=Fa({initialData:d}),f=n.useCallback(async()=>{o?.(),await x(async()=>{const y=await Da.summarize(t);return c?.(),y})},[t,x,o,c]);if(p&&!u)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:p}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})});if(!u)return a?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:i("aiSummary.processing")})]})}):e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[m?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Zap,{className:"w-4 h-4"}),i("aiSummary.generate")]});if(m&&!u)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!u.isAiAvailable){const y=u.errorCode?`aiRouting.errors.${u.errorCode}`:null,h=y&&i(y)!==y?i(y):u.errorMessage??i("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:h})]})})}if(!u.summary){const y=u.errorCode?`aiSummary.errors.${u.errorCode}`:null,h=y&&i(y)!==y?i(y):u.errorMessage??i("aiSummary.error");return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:h}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})})}const b=u.summary,g=r&&!m?new Date(r):null;return e.jsxs("div",{className:"card p-6 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(l.Zap,{className:"w-5 h-5"}),i("aiSummary.title")]}),e.jsxs("button",{onClick:f,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-1",title:i("aiSummary.refresh"),children:[m?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("aiSummary.refresh")]})]}),g&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:i("aiSummary.generatedAt",{date:g.toLocaleString()})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.summary")}),e.jsx("p",{className:"text-sm",children:b.summary})]}),b.keyPoints.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.keyPoints")}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:b.keyPoints.map((y,h)=>e.jsx("li",{className:"text-sm",children:y},`point-${h}`))})]}),b.sentiment&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.sentiment")}),e.jsx("p",{className:"text-sm",children:b.sentiment})]}),(b.blockers?.length??0)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.blockers")}),e.jsx("ul",{className:"space-y-2",children:b.blockers?.map((y,h)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] flex-shrink-0 mt-0.5",children:h+1}),e.jsx("span",{className:"text-sm",children:y})]},`blocker-${h}`))})]})]})]})}const je={tickets:{getAll:t=>E.get("/api/support/tickets",{params:t}),getMyTickets:t=>E.get("/api/support/tickets/my-assigned",{params:t}),getById:t=>E.get(`/api/support/tickets/${t}`),create:t=>E.post("/api/support/tickets",t),update:(t,s)=>E.put(`/api/support/tickets/${t}`,s),updateStatus:(t,s)=>E.patch(`/api/support/tickets/${t}/status`,{status:s}),assign:(t,s,r,a)=>E.patch(`/api/support/tickets/${t}/assign`,{assignedToUserId:s,userIds:r,groupIds:a}),resolve:(t,s)=>E.patch(`/api/support/tickets/${t}/resolve`,{resolution:s}),close:t=>E.patch(`/api/support/tickets/${t}/close`),reopen:t=>E.patch(`/api/support/tickets/${t}/reopen`),addComment:(t,s)=>E.post(`/api/support/tickets/${t}/comments`,s),delete:t=>E.delete(`/api/support/tickets/${t}`),getStats:t=>E.get("/api/support/tickets/stats",{params:{tenantId:t}}),getMyAssignedStats:()=>E.get("/api/support/tickets/my-assigned/stats"),getAttachmentUrl:(t,s)=>`/api/support/tickets/${t}/attachments/${s}`,downloadAttachment:(t,s)=>E.get(`/api/support/tickets/${t}/attachments/${s}`,{responseType:"blob"}),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},getActivities:(t,s=10)=>E.get(`/api/support/tickets/${t}/activities`,{params:{limit:s}}),getTicketingProvider:()=>E.get("/api/support/tickets/provider"),getGlpiSyncStats:()=>E.get("/api/support/tickets/glpi-sync-stats"),proposeSolution:(t,s)=>E.post(`/api/support/tickets/${t}/solutions`,{content:s}),getSolutions:t=>E.get(`/api/support/tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/tickets/${t}/solutions/reject`,{reason:s})}},Fe={getAll:t=>E.get("/api/support/my-tickets",{params:t}),getById:t=>E.get(`/api/support/my-tickets/${t}`),create:t=>E.post("/api/support/my-tickets",t),update:(t,s)=>E.put(`/api/support/my-tickets/${t}`,s),addComment:(t,s)=>E.post(`/api/support/my-tickets/${t}/comments`,{content:s}),getStats:()=>E.get("/api/support/my-tickets/stats"),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/my-tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},downloadAttachment:(t,s)=>E.get(`/api/support/my-tickets/${t}/attachments/${s}`,{responseType:"blob"}),deleteAttachment:(t,s)=>E.delete(`/api/support/my-tickets/${t}/attachments/${s}`),getActivities:(t,s=10)=>E.get(`/api/support/my-tickets/${t}/activities`,{params:{limit:s}}),getAttachmentUrl:(t,s)=>`/api/support/my-tickets/${t}/attachments/${s}`,submitSatisfaction:(t,s)=>E.post(`/api/support/my-tickets/${t}/satisfaction`,s),getSatisfaction:t=>E.get(`/api/support/my-tickets/${t}/satisfaction`),getSolutions:t=>E.get(`/api/support/my-tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/my-tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/my-tickets/${t}/solutions/reject`,{reason:s})},Bd={getAll:()=>E.get("/api/support/assignment"),getById:t=>E.get(`/api/support/assignment/${t}`),create:t=>E.post("/api/support/assignment",t),update:(t,s)=>E.put(`/api/support/assignment/${t}`,s),delete:t=>E.delete(`/api/support/assignment/${t}`),activate:t=>E.patch(`/api/support/assignment/${t}/activate`),deactivate:t=>E.patch(`/api/support/assignment/${t}/deactivate`)},zd={getAll:()=>E.get("/api/support/assignment/skills"),getByAgent:t=>E.get("/api/support/assignment/skills",{params:{userId:t}}),update:(t,s)=>E.put(`/api/support/assignment/skills/${t}`,s)},Gd={getByAgent:t=>E.get(`/api/support/assignment/availability/${t}`),update:(t,s)=>E.put(`/api/support/assignment/availability/${t}`,s)},Kd={getByTicket:(t,s=1,r=50)=>E.get("/api/support/assignment/logs",{params:{ticketId:t,page:s,pageSize:r}})},Hd={getByAgent:t=>E.get(`/api/support/assignment/workload/${t}`),getAll:()=>E.get("/api/support/assignment/workload")};function ks(){const{currentTenant:t}=Ee(),[s,r]=n.useState(null),[a,o]=n.useState(!!t),[c,i]=n.useState(null),d=n.useCallback(async()=>{if(!t){r(null);return}o(!0),i(null);try{const u=await je.tickets.getTicketingProvider();r(u)}catch{i("Failed to load ticketing provider configuration"),r(null)}finally{o(!1)}},[t]);return n.useEffect(()=>{d()},[d]),{provider:s?.provider??"SmartStack",isGlpi:s?.provider==="Glpi",isConfigured:s?.isConfigured??!1,glpiBaseUrl:s?.glpiBaseUrl??void 0,loading:a,error:c,refresh:d}}const ds={Open:"pending",InProgress:"active",OnHold:"warning",Resolved:"active",Closed:"inactive",Rejected:"error"},cr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},Vd=["conversation","description","information","assignment","ai"],Wd={Open:"statusDescriptions.Open",InProgress:"statusDescriptions.InProgress",OnHold:"statusDescriptions.OnHold",Resolved:"statusDescriptions.Resolved",Closed:"statusDescriptions.Closed",Rejected:"statusDescriptions.Rejected"};function Xd({satisfaction:t,showRatingForm:s,ratingValue:r,ratingComment:a,submittingRating:o,onShowForm:c,onRatingChange:i,onCommentChange:d,onCancel:u,onSubmit:m,t:p}){return t?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500 fill-amber-500"}),p("satisfaction.yourRating","Votre évaluation")]}),e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[1,2,3,4,5].map(x=>e.jsx(l.Star,{className:`w-5 h-5 ${x<=t.rating?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)]"}`},x)),e.jsxs("span",{className:"ml-2 text-sm text-[var(--text-secondary)]",children:[t.rating,"/5"]})]}),t.comment&&e.jsxs("p",{className:"text-sm text-[var(--text-secondary)] italic",children:['"',t.comment,'"']})]}):s?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-3",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.rateTitle","Évaluez cette résolution")]}),e.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(x=>e.jsx("button",{type:"button",onClick:()=>i(x),className:"p-1 hover:scale-110 transition-transform",children:e.jsx(l.Star,{className:`w-7 h-7 transition-colors ${x<=r?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)] hover:text-amber-300"}`})},x))}),e.jsx("textarea",{value:a,onChange:x=>d(x.target.value),placeholder:p("satisfaction.commentPlaceholder","Commentaire (optionnel)..."),className:"input w-full h-20 mb-3 text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"btn btn-secondary btn-sm",children:p("common.cancel","Annuler")}),e.jsxs("button",{onClick:m,disabled:r===0||o,className:"btn btn-primary btn-sm",children:[o?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.submit","Envoyer")]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.askTitle","Comment évaluez-vous cette résolution ?")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:p("satisfaction.askDescription","Votre avis nous aide à améliorer notre service.")})]}),e.jsxs("button",{onClick:c,className:"btn btn-primary btn-sm",children:[e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.rateButton","Évaluer")]})]})}function Yd({show:t,resolution:s,saving:r,onResolutionChange:a,onClose:o,onResolve:c,t:i}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:i("resolve.title","Proposer une solution")}),e.jsx("textarea",{value:s,onChange:d=>a(d.target.value),placeholder:i("resolve.placeholder","Décrivez la résolution..."),className:"input w-full h-32 mb-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"btn btn-secondary",children:i("common.cancel","Annuler")}),e.jsxs("button",{onClick:c,disabled:!s.trim()||r,className:"btn btn-primary",children:[r&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),i("resolve.confirm","Proposer")]})]})]})}):null}function Jd({show:t,filteredUsers:s,selectedUserIds:r,selectedGroupIds:a,groups:o,userSearchQuery:c,groupSearchQuery:i,loadingUsers:d,loadingGroups:u,saving:m,activeTab:p,onUserSearchChange:x,onGroupSearchChange:f,onSelectUser:b,onSelectGroup:g,onTabChange:y,onClose:h,onAssign:j,t:v}){const S=n.useMemo(()=>{if(!i.trim())return o;const N=i.toLowerCase();return o.filter(I=>I.name.toLowerCase().includes(N))},[o,i]);return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4 max-h-[80vh] flex flex-col",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:v("assign.title","Assigner le ticket")}),e.jsxs("div",{className:"flex gap-2 mb-4 border-b border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>y("users"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="users"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabUsers","Utilisateurs")}),e.jsx("button",{onClick:()=>y("groups"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="groups"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabGroups","Groupes")})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(l.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:p==="users"?c:i,onChange:N=>p==="users"?x(N.target.value):f(N.target.value),placeholder:p==="users"?v("assign.searchUserPlaceholder","Rechercher un utilisateur..."):v("assign.searchGroupPlaceholder","Rechercher un groupe..."),className:"input w-full pl-10",autoFocus:!0})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mb-4",children:[p==="users"&&e.jsx(e.Fragment,{children:d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:s.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noUsersFound","Aucun utilisateur trouvé")}):s.map(N=>e.jsxs("button",{onClick:()=>b(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${r.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:r.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.fullName.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:N.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:N.email})]})]},N.id))})}),p==="groups"&&e.jsx(e.Fragment,{children:u?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:S.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noGroupsFound","Aucun groupe trouvé")}):S.map(N=>e.jsxs("button",{onClick:()=>g(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${a.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:a.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.name.charAt(0).toUpperCase()}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:N.name})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] flex-shrink-0",children:N.memberCount})]},N.id))})})]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-4 px-3 py-2 bg-[var(--bg-secondary)] rounded",children:v("assign.selectedSummary","{{userCount}} utilisateur(s), {{groupCount}} groupe(s) sélectionné(s)",{userCount:r.length,groupCount:a.length})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{h(),x(""),f("")},className:"btn btn-secondary",children:v("common.cancel","Annuler")}),e.jsxs("button",{onClick:j,disabled:m||d||u,className:"btn btn-primary",children:[m&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),v("assign.confirm","Assigner")]})]})]})}):null}const Qd=["Supervisor","Manager","Director"];function Zd({show:t,escalationLevel:s,escalationReason:r,saving:a,onLevelChange:o,onReasonChange:c,onClose:i,onEscalate:d,t:u}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--warning-bg)] flex items-center justify-center",children:e.jsx(l.ArrowUpCircle,{className:"w-5 h-5 text-[var(--warning-text)]"})}),e.jsx("h2",{className:"text-xl font-bold",children:u("escalate.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:u("escalate.description")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.level")}),e.jsx("div",{className:"space-y-2",children:Qd.map(m=>e.jsxs("button",{onClick:()=>o(m),className:`w-full flex items-center gap-3 px-4 py-3 text-left rounded-lg border transition-colors ${s===m?"border-[var(--warning-border)] bg-[var(--warning-bg)]":"border-[var(--border-color)] hover:bg-[var(--bg-secondary)]"}`,children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${s===m?"border-[var(--warning-text)]":"border-[var(--border-color)]"}`,children:s===m&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-[var(--warning-text)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u(`escalate.levels.${m}`)}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:u(`escalate.levels.${m}Desc`)})]})]},m))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.reason")}),e.jsx("textarea",{value:r,onChange:m=>c(m.target.value),placeholder:u("escalate.reasonPlaceholder"),className:"input w-full h-24"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{i(),o("Supervisor"),c("")},className:"btn btn-secondary",children:u("common.cancel")}),e.jsxs("button",{onClick:d,disabled:a,className:"btn border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[a&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),u("escalate.confirm")]})]})]})}):null}function eu(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,createdByName:t.createdBy?.fullName,assignedToName:t.assignedTo?.fullName,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,assignees:t.assignees,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:s.isInternal,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,contentType:s.contentType,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,clientContext:t.clientContext,externalProvider:t.externalProvider,externalId:t.externalId,externalUrl:t.externalUrl,isExternallyManaged:t.isExternallyManaged,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function tu(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:!1,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function dr(t,s){return s==="support"?eu(t):tu(t)}const su=()=>{const[t,s]=n.useState(null),[r,a]=n.useState(!0),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState(null),[p,x]=n.useState([]),[f,b]=n.useState(!1),[g,y]=n.useState({title:"",priority:"Medium"}),[h,j]=n.useState(!1),[v,S]=n.useState(!1),[N,I]=n.useState(!1),[P,k]=n.useState(""),[A,R]=n.useState("Supervisor"),[$,U]=n.useState(""),[C,D]=n.useState([]),[Y,T]=n.useState([]),[B,Z]=n.useState([]),[H,J]=n.useState(!1),[fe,z]=n.useState(""),[Q,M]=n.useState(""),[re,F]=n.useState([]),[K,V]=n.useState(!1),[ae,ue]=n.useState("users"),[G,ce]=n.useState(null),[de,he]=n.useState(!1),[pe,ye]=n.useState(0),[Ue,qe]=n.useState(""),[Ve,q]=n.useState(!1);return{ticket:t,setTicket:s,loading:r,setLoading:a,saving:o,setSaving:c,uploading:i,setUploading:d,error:u,setError:m,activities:p,setActivities:x,isEditing:f,setIsEditing:b,editForm:g,setEditForm:y,showAssignModal:h,setShowAssignModal:j,showResolveModal:v,setShowResolveModal:S,showEscalateModal:N,setShowEscalateModal:I,resolution:P,setResolution:k,escalationLevel:A,setEscalationLevel:R,escalationReason:$,setEscalationReason:U,users:C,setUsers:D,selectedUserIds:Y,setSelectedUserIds:T,selectedGroupIds:B,setSelectedGroupIds:Z,loadingUsers:H,setLoadingUsers:J,userSearchQuery:fe,setUserSearchQuery:z,groupSearchQuery:Q,setGroupSearchQuery:M,groups:re,setGroups:F,loadingGroups:K,setLoadingGroups:V,assignModalTab:ae,setAssignModalTab:ue,satisfaction:G,setSatisfaction:ce,showRatingForm:de,setShowRatingForm:he,ratingValue:pe,setRatingValue:ye,ratingComment:Ue,setRatingComment:qe,submittingRating:Ve,setSubmittingRating:q}},ru=(t,s)=>t?s?.email||"":(s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.email)||"",au=(t,s,r)=>{const a=s.get("tab");t==="conversation"?a&&(s.delete("tab"),r(s,{replace:!0})):a!==t&&r({tab:t},{replace:!0})},nu=(t,s)=>{const r=t.get("tab");return r&&s.includes(r)?r:"conversation"};function ou({ticket:t,isSupport:s,isEditing:r,saving:a,editForm:o,error:c,onEditToggle:i,onSave:d,onEditFormChange:u,onErrorClear:m,t:p}){return e.jsxs("div",{className:"flex-shrink-0 border-b border-[var(--border-color)] bg-[var(--bg-card)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>window.history.back(),className:"btn btn-ghost p-2",children:e.jsx(l.ArrowLeft,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:t.ticketNumber}),t.externalId&&t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80",children:[e.jsx(l.ExternalLink,{className:"w-3 h-3"}),"GLPI #",t.externalId]}),e.jsx(Mt,{status:ds[t.status]||"pending",label:t.status}),e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:cr[t.priority]?.bg,color:cr[t.priority]?.text},children:t.priority})]}),s&&r?e.jsx("input",{type:"text",value:o.title,onChange:x=>u({...o,title:x.target.value}),className:"input w-full text-lg font-bold"}):e.jsx("h1",{className:"text-lg font-bold truncate",children:t.title})]}),e.jsx("div",{className:"flex items-center gap-2",children:s&&r?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!1),className:"btn btn-ghost p-2",children:e.jsx(l.X,{className:"w-5 h-5"})}),e.jsx("button",{onClick:d,disabled:a,className:"btn btn-primary",children:a?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Save,{className:"w-4 h-4"})})]}):e.jsx(e.Fragment,{children:s&&!t.isExternallyManaged&&e.jsx("button",{onClick:()=>i(!0),className:"btn btn-ghost p-2",title:"Modifier",children:e.jsx(l.Edit2,{className:"w-5 h-5"})})})})]}),c&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm flex-1",children:c}),e.jsx("button",{onClick:m,className:"p-1 hover:bg-[var(--error-border)] rounded",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),t.isExternallyManaged&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] flex items-center gap-3",children:[e.jsx(l.ShieldAlert,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-[var(--info-text)]",children:p("glpi.readOnlyBanner","This ticket is managed by GLPI and is read-only.")})}),t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-sm bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80 flex items-center gap-1.5",children:[e.jsx(l.ExternalLink,{className:"w-4 h-4"}),p("glpi.viewInGlpi","View in GLPI")]})]})]})}function iu({ticket:t,isSupport:s,satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowRatingForm:d,onRatingChange:u,onCommentChange:m,onCancelRating:p,onSubmitRating:x,t:f}){return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:f(Wd[t.status]||"statusDescriptions.InProgress")})}),t.resolution&&e.jsxs("div",{className:"mt-3 p-4 rounded-lg bg-[var(--success-bg)] border border-[var(--success-border)]",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 text-[var(--success-text)] mb-1",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),f("resolution.title","Résolution")]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.resolution})]}),!s&&(t.status==="Resolved"||t.status==="Closed")&&e.jsx("div",{className:"mt-3 p-4 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx(Xd,{satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowForm:d,onRatingChange:u,onCommentChange:m,onCancel:p,onSubmit:x,t:f})})]})}function lu({activeTab:t,commentCount:s,isSupport:r,assigneeCount:a,onTabChange:o,t:c}){const i=[{id:"conversation",icon:l.MessageSquare,label:c("tabs.conversation"),badge:s},{id:"description",icon:l.FileText,label:c("tabs.description"),badge:0},{id:"information",icon:l.Info,label:c("tabs.information"),badge:0},...r?[{id:"assignment",icon:l.Users,label:c("tabs.assignment"),badge:a},{id:"ai",icon:l.Sparkles,label:c("tabs.ai"),badge:0}]:[]];return e.jsx("div",{className:"flex-shrink-0 flex border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:i.map(({id:d,icon:u,label:m,badge:p})=>e.jsxs("button",{onClick:()=>o(d),className:`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${t===d?"border-[var(--color-accent-600)] text-[var(--color-accent-600)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--border-color)]"}`,children:[e.jsx(u,{className:"w-4 h-4"}),m,p>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:p})]},d))})}function cu({activeTab:t,ticket:s,activities:r,isSupport:a,isClosed:o,isReadOnly:c,isConnected:i,currentUserName:d,saving:u,uploading:m,onAddComment:p,onDownloadAttachment:x,onUploadAttachment:f,onStatusChange:b,onAssign:g,onResolve:y,onClose:h,onReopen:j,onEscalate:v,getAttachmentUrl:S,onProposeSolution:N,onApproveSolution:I,onRejectSolution:P,t:k}){if(t==="description")return e.jsx("div",{className:"h-full overflow-y-auto p-6 bg-[var(--bg-primary)]",children:s.description?e.jsx("div",{className:"prose prose-sm max-w-none text-[var(--text-primary)] leading-relaxed [&_a]:text-[var(--color-accent-600)] [&_a]:underline",dangerouslySetInnerHTML:{__html:en.sanitize(s.description)}}):e.jsx("p",{className:"text-[var(--text-tertiary)] italic",children:k("tabs.noDescription")})});if(t==="conversation"){const A=n.useMemo(()=>{if(s)return{ticketNumber:s.ticketNumber??"",ticketTitle:s.title??"",userName:s.createdBy?.fullName??"",userFirstName:s.createdBy?.fullName?.split(" ")[0]??"",userLastName:s.createdBy?.fullName?.split(" ").slice(1).join(" ")??"",userEmail:s.createdBy?.email??"",priority:s.priority??"",type:s.type??"",status:s.status??"",agentName:s.assignedTo?.fullName??"",agentFirstName:s.assignedTo?.fullName?.split(" ")[0]??"",createdAt:s.createdAt?new Date(s.createdAt).toLocaleDateString():"",resolvedAt:s.resolvedAt?new Date(s.resolvedAt).toLocaleDateString():"",resolution:s.resolution??""}},[s]);return e.jsxs("div",{className:"h-full flex flex-col",children:[(s.activeSolution||s.hasPendingSolution||a&&!o&&s.status!=="Closed")&&e.jsx("div",{className:"p-4 border-b border-[var(--border-color)]",children:e.jsx(Fd,{ticketId:s.id,solutions:s.solutions??[],activeSolution:s.activeSolution,mode:a?"support":"client",onProposeSolution:!c&&a?N:void 0,onApproveSolution:c?void 0:I,onRejectSolution:c?void 0:P,isLoading:u})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ia,{ticketId:s.id,comments:s.comments,activities:r.map(R=>({id:R.id,action:R.action,oldValue:R.oldValue??null,newValue:R.newValue??null,changedByUserName:"changedByUserName"in R?R.changedByUserName:null,createdAt:R.createdAt})),attachments:s.attachments,isSupport:a,isClosed:o||c,isConnected:i,currentUserName:d,ticketVariables:A,onAddComment:p,onDownloadAttachment:x,getAttachmentUrl:S})})]})}return t==="assignment"?e.jsx(du,{ticket:s,canAssign:!c&&!!g,onAssign:g,t:k}):t==="ai"?e.jsx(mu,{ticket:s,t:k}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(La,{ticket:s,attachments:s.attachments,activities:r.map(A=>({action:A.action,newValue:A.newValue,createdAt:A.createdAt})),isSupport:a,saving:u,uploading:m,isReadOnly:c,layout:"grid",onAssign:c?void 0:g,onStatusChange:c?void 0:b,onResolve:c?void 0:y,onCloseTicket:c?void 0:h,onReopen:c?void 0:j,onEscalate:c?void 0:v,onDownloadAttachment:x,onUploadAttachment:c?void 0:f,getAttachmentUrl:S})})})}function du({ticket:t,canAssign:s,onAssign:r,t:a}){const[o,c]=n.useState([]),[i,d]=n.useState(!1);n.useEffect(()=>{t?.id&&(d(!0),Kd.getByTicket(t.id).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1)))},[t?.id]);const u=t.assignees??[];return e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:a("tabs.assignmentCurrentAssignees")}),s&&r&&e.jsx("button",{onClick:r,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:a("tabs.assignmentAssign")})]}),u.length===0?e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoAssignees")}):e.jsx("div",{className:"space-y-2",children:u.map(m=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-[var(--bg-secondary)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] flex items-center justify-center text-xs font-medium",children:(m.fullName||m.email||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName||m.email}),m.assignedViaGroupName&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)]",children:a("tabs.assignmentViaGroup",{group:m.assignedViaGroupName})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.isPrimary&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:a("tabs.assignmentPrimary")}),m.assignedAt&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(m.assignedAt).toLocaleDateString()})]})]},m.userId))})]}),e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)] mb-4",children:a("tabs.assignmentLogs")}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!i&&o.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoLogs")}),!i&&o.length>0&&e.jsx("div",{className:"space-y-2",children:o.map(m=>e.jsxs("div",{className:"flex items-start gap-3 p-2 rounded-md border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("div",{className:`mt-0.5 w-2 h-2 rounded-full flex-shrink-0 ${m.success?"bg-[var(--success-text)]":"bg-[var(--error-text)]"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)]",children:[e.jsx("span",{className:"font-medium",children:m.strategyUsed}),m.reason&&e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[" — ",m.reason]})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:new Date(m.createdAt).toLocaleString()})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${m.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:m.success?a("tabs.assignmentSuccess"):a("tabs.assignmentFailed")})]},m.id))})]})]})})}const uu=12e4;function ur(t){const s=sessionStorage.getItem(t);return s?Date.now()-Number(s)>uu?(sessionStorage.removeItem(t),!1):!0:!1}function mu({ticket:t,t:s}){const[r,a]=n.useState(null),[o,c]=n.useState(!0),i=`ai_routing_${t.id}`,d=`ai_summary_${t.id}`,[u,m]=n.useState(()=>ur(i)),[p,x]=n.useState(()=>ur(d));n.useEffect(()=>{let h=!1;return(async()=>{try{const{cachedAiApi:v}=await Promise.resolve().then(()=>lr),S=await v.getCached(t.id);h||(a(S),S.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),S.summary&&(sessionStorage.removeItem(d),x(!1)))}catch{}finally{h||c(!1)}})(),()=>{h=!0}},[t.id,i,d]),n.useEffect(()=>{if(!u&&!p)return;let h=!1;const v=setInterval(async()=>{try{const{cachedAiApi:S}=await Promise.resolve().then(()=>lr),N=await S.getCached(t.id);if(h)return;a(N),u&&N.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),p&&N.summary&&(sessionStorage.removeItem(d),x(!1))}catch{}},3e3);return()=>{h=!0,clearInterval(v)}},[u,p,t.id,i,d]);const f=n.useCallback(()=>{sessionStorage.setItem(i,Date.now().toString()),m(!0)},[i]),b=n.useCallback(()=>{sessionStorage.removeItem(i),m(!1)},[i]),g=n.useCallback(()=>{sessionStorage.setItem(d,Date.now().toString()),x(!0)},[d]),y=n.useCallback(()=>{sessionStorage.removeItem(d),x(!1)},[d]);return o?e.jsx("div",{className:"h-full overflow-y-auto p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[(t.aiClassification||r?.classification)&&e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3 text-[var(--text-primary)]",children:s("aiClassification.title")}),e.jsx(Oa,{classification:t.aiClassification||r?.classification})]}),e.jsx(Ud,{ticketId:t.id,cachedClassification:r?.classification,cachedRouting:r?.routingSuggestion,cachedGeneratedAt:r?.routingSuggestionGeneratedAt,processing:u,onProcessingStart:f,onProcessingEnd:b}),e.jsx(qd,{ticketId:t.id,cachedSummary:r?.summary,cachedGeneratedAt:r?.summaryGeneratedAt,processing:p,onProcessingStart:g,onProcessingEnd:y})]})})}function pu({mode:t}){const{id:s}=w.useParams(),r=w.useNavigate(),{t:a}=ne.useTranslation("support"),{user:o,hasPermission:c}=Pe(),[i,d]=w.useSearchParams(),{isGlpi:u}=ks(),m=t==="support",p=ru(m,o),[x,f]=n.useState(()=>nu(i,Vd));n.useEffect(()=>{au(x,i,d)},[x,i,d]);const{ticket:b,setTicket:g,loading:y,setLoading:h,saving:j,setSaving:v,uploading:S,setUploading:N,error:I,setError:P,activities:k,setActivities:A,isEditing:R,setIsEditing:$,editForm:U,setEditForm:C,showAssignModal:D,setShowAssignModal:Y,showResolveModal:T,setShowResolveModal:B,showEscalateModal:Z,setShowEscalateModal:H,resolution:J,setResolution:fe,escalationLevel:z,setEscalationLevel:Q,escalationReason:M,setEscalationReason:re,users:F,setUsers:K,selectedUserIds:V,setSelectedUserIds:ae,selectedGroupIds:ue,setSelectedGroupIds:G,loadingUsers:ce,setLoadingUsers:de,userSearchQuery:he,setUserSearchQuery:pe,groupSearchQuery:ye,setGroupSearchQuery:Ue,groups:qe,setGroups:Ve,loadingGroups:q,setLoadingGroups:W,assignModalTab:ee,setAssignModalTab:te,satisfaction:se,setSatisfaction:me,showRatingForm:ie,setShowRatingForm:ve,ratingValue:be,setRatingValue:Ie,ratingComment:Me,setRatingComment:Le,submittingRating:Be,setSubmittingRating:et}=su(),We=n.useCallback(async()=>{if(s)try{const X=m?await je.tickets.getActivities(s,50):await Fe.getActivities(s,50);A(X)}catch(X){console.error("Failed to load activities",X)}},[s,m]),Ct=n.useCallback(async()=>{if(!(!s||m))try{const X=await Fe.getSatisfaction(s);me(X)}catch(X){console.error("Failed to load satisfaction",X)}},[s,m]),ke=n.useCallback(async()=>{if(s)try{if(h(!0),P(null),m){const X=await je.tickets.getById(s);if(!X){g(null);return}g(dr(X,t)),C({title:X.title,priority:X.priority})}else{const X=await Fe.getById(s);if(!X){g(null);return}g(dr(X,t)),Ct()}We()}catch(X){P(a("error.loadFailed","Impossible de charger le ticket")),console.error(X)}finally{h(!1)}},[s,m,t,We,Ct,a]),L=n.useCallback(X=>{if(X.ticketId===s){if(!m&&X.isInternal)return;g(xe=>!xe||xe.comments.some(De=>De.id===X.id)?xe:{...xe,comments:[...xe.comments,{id:X.id,userName:X.userName,content:X.content,isInternal:X.isInternal,isEdited:X.isEdited,createdAt:X.createdAt}]})}},[s,m]),le=n.useCallback(X=>{X.ticketId===s&&ke()},[s,ke]),{isConnected:we}=oa({ticketId:s,onCommentAdded:L,onTicketUpdated:le});n.useEffect(()=>{ke()},[ke]),n.useEffect(()=>{(async()=>{if(!(!D||F.length>0||!m))try{de(!0);const xe=await E.get("/api/support/tickets/assignable-users"),De=Array.isArray(xe)?xe:[];K(De.map(Re=>({id:Re.id,email:Re.email,fullName:`${Re.firstName} ${Re.lastName}`}))),(b?.assignees?.length??0)>0&&b?.assignees&&ae(b.assignees.map(Re=>Re.userId))}catch(xe){console.error("Failed to load users",xe)}finally{de(!1)}})()},[D,F.length,m,b?.assignees]),n.useEffect(()=>{(async()=>{if(!(!D||!m))try{W(!0);const xe=await E.get("/api/support/tickets/assignable-groups"),De=Array.isArray(xe)?xe:[];Ve(De.map(Re=>({id:Re.id,name:Re.name,memberCount:Re.memberCount})))}catch(xe){console.error("Failed to load groups",xe)}finally{W(!1)}})()},[D,m]);const Ae=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.update(s,{title:U.title,priority:U.priority,description:b?.description||""}),await ke(),$(!1)}catch{P(a("error.updateFailed","Impossible de mettre à jour le ticket"))}finally{v(!1)}},$e=async X=>{if(!(!s||!m))try{v(!0),await je.tickets.updateStatus(s,X),await ke()}catch{P(a("error.statusFailed","Impossible de changer le statut"))}finally{v(!1)}},ht=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.assign(s,V.length>0?V[0]:null,V.length>0?V:void 0,ue.length>0?ue:void 0),await ke(),Y(!1),ae([]),G([]),te("users")}catch{P(a("error.assignFailed","Impossible d'assigner le ticket"))}finally{v(!1)}},rt=async()=>{if(!(!s||!J.trim()||!m))try{v(!0),await je.tickets.proposeSolution(s,J),await ke(),B(!1),fe("")}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},_a=async X=>{if(s)try{v(!0),m&&await je.tickets.proposeSolution(s,X),await ke()}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Ua=async()=>{if(s)try{v(!0),m?await je.tickets.approveSolution(s):await Fe.approveSolution(s),await ke()}catch{P(a("error.approveFailed","Impossible d'approuver la solution"))}finally{v(!1)}},qa=async X=>{if(s)try{v(!0),m?await je.tickets.rejectSolution(s,X):await Fe.rejectSolution(s,X),await ke()}catch{P(a("error.rejectFailed","Impossible de rejeter la solution"))}finally{v(!1)}},As=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.close(s),await ke()}catch{P(a("error.closeFailed","Impossible de fermer le ticket"))}finally{v(!1)}},Ps=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.reopen(s),await ke()}catch{P(a("error.reopenFailed","Impossible de réouvrir le ticket"))}finally{v(!1)}},Ba=async()=>{if(!(!s||!m||!z))try{v(!0),await ma.escalateTicket(s,z,M||void 0),await ke(),H(!1),Q("Supervisor"),re("")}catch{P(a("error.escalateFailed","Failed to escalate ticket"))}finally{v(!1)}},za=async(X,xe)=>{!s||!X.trim()||(m?await je.tickets.addComment(s,{content:X,isInternal:xe}):await Fe.addComment(s,X),await ke())},Ga=async()=>{if(!(!s||be===0||m))try{et(!0);const X=await Fe.submitSatisfaction(s,{rating:be,comment:Me.trim()||void 0});me(X),ve(!1),Ie(0),Le("")}catch(X){const xe=X instanceof Error?X.message:a("error.ratingFailed","Failed to submit rating");P(xe)}finally{et(!1)}},Ka=async X=>{if(s)try{const xe=m?await je.tickets.downloadAttachment(s,X.id):await Fe.downloadAttachment(s,X.id),De=window.URL.createObjectURL(xe),Re=document.createElement("a");Re.href=De,Re.setAttribute("download",X.fileName),document.body.appendChild(Re),Re.click(),Re.remove(),window.URL.revokeObjectURL(De)}catch{P(a("error.downloadFailed","Impossible de télécharger le fichier"))}},Ha=async X=>{if(!(!s||!m))try{N(!0),await je.tickets.uploadAttachment(s,X),await ke()}catch(xe){throw P(a("error.uploadFailed","Failed to upload file")),xe}finally{N(!1)}},Va=X=>s?m?je.tickets.getAttachmentUrl(s,X.id):`/api/support/my-tickets/${s}/attachments/${X.id}`:"",Wa=n.useMemo(()=>{if(!he.trim())return F;const X=he.toLowerCase();return F.filter(xe=>xe.fullName.toLowerCase().includes(X)||xe.email.toLowerCase().includes(X))},[F,he]),Xa=n.useCallback(X=>{ae(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]),Ya=n.useCallback(X=>{G(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]);if(y)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})});if(!b)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:a("error.notFound","Ticket non trouvé")}),e.jsx("button",{onClick:()=>r(-1),className:"btn btn-secondary",children:a("common.goBack","Retour")})]});const Ja=b.status==="Closed"||b.status==="Rejected",tt=u||!!b.isExternallyManaged,Ts=!tt&&c("support.tickets.assign");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(ou,{ticket:b,isSupport:m,isEditing:R,saving:j,editForm:U,error:I,onEditToggle:$,onSave:Ae,onEditFormChange:C,onErrorClear:()=>P(null),t:a}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(iu,{ticket:b,isSupport:m,satisfaction:se,showRatingForm:ie,ratingValue:be,ratingComment:Me,submittingRating:Be,onShowRatingForm:()=>ve(!0),onRatingChange:Ie,onCommentChange:Le,onCancelRating:()=>{ve(!1),Ie(0),Le("")},onSubmitRating:Ga,t:a}),e.jsx(Od,{currentStatus:b.status,createdAt:b.createdAt,resolvedAt:b.resolvedAt,closedAt:b.closedAt,activities:k.map(X=>({action:X.action,newValue:X.newValue,createdAt:X.createdAt})),isSupport:m,saving:j,assignees:b.assignees,onAssign:Ts?()=>Y(!0):void 0,onStatusChange:tt?void 0:$e,onResolve:tt?void 0:()=>B(!0),onCloseTicket:tt?void 0:As,onReopen:tt?void 0:Ps,onEscalate:tt?void 0:()=>H(!0)})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx(lu,{activeTab:x,commentCount:b.comments.length,isSupport:m,assigneeCount:b.assignees?.length??0,onTabChange:f,t:a}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(cu,{activeTab:x,ticket:b,activities:k,isSupport:m,isClosed:Ja,isReadOnly:tt,isConnected:we,currentUserName:p,saving:j,uploading:S,onAddComment:za,onDownloadAttachment:Ka,onUploadAttachment:Ha,onStatusChange:$e,onAssign:Ts?()=>Y(!0):void 0,onResolve:()=>B(!0),onClose:As,onReopen:Ps,onEscalate:()=>H(!0),getAttachmentUrl:Va,onProposeSolution:_a,onApproveSolution:Ua,onRejectSolution:qa,t:a})})]}),e.jsx(Yd,{show:m&&T,resolution:J,saving:j,onResolutionChange:fe,onClose:()=>B(!1),onResolve:rt,t:a}),e.jsx(Jd,{show:m&&D,filteredUsers:Wa,selectedUserIds:V,selectedGroupIds:ue,groups:qe,userSearchQuery:he,groupSearchQuery:ye,loadingUsers:ce,loadingGroups:q,saving:j,activeTab:ee,onUserSearchChange:pe,onGroupSearchChange:Ue,onSelectUser:Xa,onSelectGroup:Ya,onTabChange:te,onClose:()=>{Y(!1),ae([]),G([]),te("users"),pe(""),Ue("")},onAssign:ht,t:a}),e.jsx(Zd,{show:m&&Z,escalationLevel:z,escalationReason:M,saving:j,onLevelChange:Q,onReasonChange:re,onClose:()=>H(!1),onEscalate:Ba,t:a})]})}const mr="support_tickets_view_mode",xu={Open:["InProgress","OnHold","Rejected"],InProgress:["OnHold","Resolved","Rejected"],OnHold:["InProgress","Resolved","Open"],Resolved:["Closed","Open"],Closed:["Open"],Rejected:["Open"]};function pr(t,s){return t===s?!1:xu[t]?.includes(s)??!1}const ts={Low:"var(--info-bg)",Medium:"var(--warning-bg)",High:"var(--error-bg)",Critical:"var(--error-text)"};function hu({mode:t,showDrafts:s=!1,basePath:r,title:a,subtitle:o,createPath:c}){const{t:i}=ne.useTranslation(["support","admin","common"]),d=w.useNavigate(),{currentTenant:u,userTenants:m,hasMultipleTenants:p,isGlobalView:x}=Ee(),{isGlpi:f}=ks(),[b,g]=n.useState([]),[y,h]=n.useState(null),[j,v]=n.useState(!0),[S,N]=n.useState(1),[I,P]=n.useState(1),[k,A]=n.useState(0),[R,$]=n.useState(""),[U,C]=n.useState(""),[D,Y]=n.useState(""),[T,B]=n.useState(""),[Z,H]=n.useState(""),[J,fe]=n.useState(()=>localStorage.getItem(mr)||"table"),[z,Q]=n.useState(!1),[M,re]=n.useState([]),[F,K]=n.useState(!0),[V,ae]=n.useState(null),[ue,G]=n.useState(null),[ce,de]=n.useState(null),he=(t==="admin"||t==="assigned")&&(p||x),pe=n.useCallback(async()=>{try{v(!0);const L={page:S,pageSize:20,search:R||void 0,status:U||void 0,type:D||void 0,priority:T||void 0,tenantId:Z||void 0};let le;t==="admin"?le=await je.tickets.getAll(L):t==="assigned"?le=await je.tickets.getMyTickets(L):le=await Fe.getAll(L),g(le?.items??[]),P(le?.totalPages??1),A(le?.totalCount??0)}catch(L){console.error("Failed to load tickets:",L),g([]),P(1),A(0)}finally{v(!1)}},[t,S,R,U,D,T,Z]),ye=n.useCallback(async()=>{try{let L;t==="admin"?L=await je.tickets.getStats(Z||void 0):t==="assigned"?L=await je.tickets.getMyAssignedStats():L=await Fe.getStats(),h(L)}catch(L){console.error("Failed to load stats:",L)}},[t,Z]);n.useEffect(()=>{pe()},[pe]),n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{if(s){const L=Ge.getAllDrafts();re(L)}},[s]),n.useEffect(()=>{localStorage.setItem(mr,J)},[J]);const Ue=L=>{Ge.deleteDraft(L),re(Ge.getAllDrafts())},qe=L=>{d(`${c}?draft=${L.id}`)},Ve=L=>{const we=new Date().getTime()-L.getTime(),Ae=Math.floor(we/6e4),$e=Math.floor(we/36e5),ht=Math.floor(we/864e5);return Ae<1?i("common:time.justNow","Just now"):Ae<60?i("common:time.minutesAgo",{count:Ae}):$e<24?i("common:time.hoursAgo",{count:$e}):i("common:time.daysAgo",{count:ht})},q=L=>{L.preventDefault(),N(1),pe()},W=L=>{f||ae(L)},ee=()=>{ae(null),G(null)},te=(L,le)=>{L.preventDefault(),G(le)},se=()=>{G(null)},me=L=>V?pr(V.status,L):!1,ie=async(L,le)=>{if(L.preventDefault(),de(null),!V||V.status===le){ae(null),G(null);return}if(!pr(V.status,le)){de(i("list.invalidTransition",{from:i(`tickets.statuses.${V.status}`),to:i(`tickets.statuses.${le}`)})),ae(null),G(null),setTimeout(()=>de(null),4e3);return}try{g(we=>we.map(Ae=>Ae.id===V.id?{...Ae,status:le}:Ae)),(t==="admin"||t==="assigned")&&await je.tickets.updateStatus(V.id,le),ye(),pe()}catch(we){console.error("Failed to update ticket status:",we);const Ae=we?.response?.data?.message||we?.response?.data?.detail||"";de(Ae||i("list.statusUpdateFailed")),setTimeout(()=>de(null),4e3),pe()}finally{ae(null),G(null)}},ve=async L=>{if(confirm(i("list.confirmDelete",{number:L.ticketNumber})))try{await je.tickets.delete(L.id),pe(),ye()}catch(le){console.error("Failed to delete ticket:",le)}},be=L=>`${r}/${L}`,Ie=L=>{if(!he)return null;const le="tenantId"in L?L.tenantId??null:null,we="tenantName"in L?L.tenantName??null:null,Ae=ys(le,u?.id??null);return Ae==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):Ae==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:we}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:we})},Me=()=>{if(!y)return null;const L=y,le=y,we=t==="admin"||t==="assigned",Ae=we?[{label:i("list.stats.total"),value:L.total,color:"blue"},{label:i("list.stats.open"),value:L.open,color:"yellow"},{label:i("list.stats.inProgress"),value:L.inProgress,color:"blue"},{label:i("list.stats.onHold"),value:L.onHold,color:"yellow"},{label:i("list.stats.resolved"),value:L.resolved,color:"green"},{label:i("list.stats.closed"),value:L.closed,color:"neutral"},{label:i("list.stats.critical"),value:L.critical,color:"red"},{label:i("list.stats.highPriority"),value:L.highPriority,color:"yellow"}]:[{label:i("list.stats.total"),value:le.total,color:"blue"},{label:i("list.stats.open"),value:le.open,color:"yellow"},{label:i("list.stats.inProgress"),value:le.inProgress,color:"blue"},{label:i("list.stats.resolved"),value:le.resolved,color:"green"},{label:i("list.stats.closed"),value:le.closed,color:"neutral"}],$e={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)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-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)]"},ht=we?"lg:grid-cols-8":"lg:grid-cols-5";return e.jsx("div",{className:`grid grid-cols-2 md:grid-cols-4 ${ht} gap-4 mb-6`,children:Ae.map(rt=>e.jsxs("div",{className:`card p-4 text-center border ${$e[rt.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:rt.value}),e.jsx("div",{className:"text-sm opacity-80",children:rt.label})]},rt.label))})},Le=()=>e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.number")}),he&&e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.tenant","Workspace")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.title")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.type")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.status")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.priority")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.assignee")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.comments")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.created")}),e.jsx("th",{className:"text-right p-4 font-medium",children:i("list.table.actions")})]})}),e.jsx("tbody",{children:b.map(L=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] hover:bg-[var(--bg-hover)] cursor-pointer",onClick:()=>d(be(L.id)),children:[e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"font-mono text-sm",children:L.ticketNumber})}),he&&e.jsx("td",{className:"p-4",children:Ie(L)}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"GLPI"})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})})}),e.jsx("td",{className:"p-4",children:e.jsx(Mt,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"assignedToName"in L&&L.assignedToName||"-"}),"assigneeCount"in L&&L.assigneeCount>1&&e.jsxs("span",{className:"ml-1 text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:["+",L.assigneeCount-1]})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:L.commentCount})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:new Date(L.createdAt).toLocaleDateString()})}),e.jsx("td",{className:"p-4 text-right",onClick:le=>le.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>d(be(L.id)),className:"btn btn-ghost p-2",title:i("list.actions.view"),children:e.jsx(l.Eye,{className:"w-4 h-4"})}),L.externalUrl&&e.jsx("a",{href:L.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-ghost p-2 text-[var(--info-text)]",title:"Open in GLPI",onClick:le=>le.stopPropagation(),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),t==="admin"&&!f&&e.jsx("button",{onClick:()=>ve(L),disabled:L.isExternallyManaged,className:"btn btn-ghost p-2 text-[var(--error-text)] disabled:opacity-50 disabled:cursor-not-allowed",title:L.isExternallyManaged?"Cannot delete externally managed tickets":i("list.actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]})})]},L.id))})]}),b.length===0&&!j&&e.jsxs("div",{className:"p-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),Be=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[b.map(L=>e.jsxs("button",{type:"button",className:"card p-4 hover:shadow-lg cursor-pointer transition-shadow text-left w-full",onClick:()=>d(be(L.id)),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:L.ticketNumber}),Ie(L)]}),e.jsx(Mt,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-medium line-clamp-2 flex-1",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] whitespace-nowrap",children:"GLPI"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)] bg-[var(--bg-secondary)]",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:new Date(L.createdAt).toLocaleDateString()}),e.jsx("span",{children:i("list.comments_other",{count:L.commentCount})})]})]},L.id)),b.length===0&&!j&&e.jsxs("div",{className:"col-span-full card p-12 text-center",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),et=L=>e.jsxs(wa,{onClick:()=>d(be(L.id)),isDragging:V?.id===L.id,onDragStart:()=>W(L),onDragEnd:ee,children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx("span",{children:L.ticketNumber}),Ie(L)]}),e.jsx("div",{className:"font-medium mb-2 line-clamp-2",children:L.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:i("list.comments_other",{count:L.commentCount})})]})]},L.id),We=()=>{const L=[{status:"Open",label:i("tickets.statuses.Open"),color:"warning"},{status:"InProgress",label:i("tickets.statuses.InProgress"),color:"default"},{status:"OnHold",label:i("tickets.statuses.OnHold"),color:"warning"},{status:"Resolved",label:i("tickets.statuses.Resolved"),color:"success"},{status:"Closed",label:i("tickets.statuses.Closed"),color:"default"}];return e.jsxs("div",{className:"space-y-3",children:[ce&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:ce}),e.jsx("button",{onClick:()=>de(null),className:"ml-auto text-[var(--error-text)] hover:opacity-70",children:"×"})]}),e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:L.map(le=>{const we=b.filter($e=>$e.status===le.status),Ae=V!=null&&!me(le.status)&&V.status!==le.status;return e.jsx(Na,{title:le.label,count:we.length,color:le.color,isDragOver:ue===le.status,isDropDisabled:Ae,onDragOver:$e=>te($e,le.status),onDragLeave:se,onDrop:$e=>ie($e,le.status),children:we.map(et)},le.status)})})]})},Ct=()=>!s||M.length===0?null:e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileEdit,{className:"w-5 h-5 text-[var(--warning-text)]"}),e.jsx("h2",{className:"font-semibold",children:i("common:drafts.title","Drafts")}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] rounded-full",children:M.length})]}),e.jsx("button",{onClick:()=>K(!F),className:"btn btn-ghost text-sm",children:F?i("common:actions.hide","Hide"):i("common:actions.show","Show")})]}),F&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:M.map(L=>e.jsx("button",{type:"button",className:"p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--warning-border)] hover:border-[var(--warning-text)] transition-colors cursor-pointer text-left w-full",onClick:()=>qe(L),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:L.title||i("common:drafts.untitled","Untitled draft")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-[var(--text-secondary)] flex-wrap",children:[L.tenantName&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded truncate max-w-[120px]",children:L.tenantName}),L.type&&e.jsx("span",{className:"px-1.5 py-0.5 bg-[var(--bg-tertiary)] rounded",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),Ve(L.updatedAt)]})]})]}),e.jsx("button",{onClick:le=>{le.stopPropagation(),Ue(L.id)},className:"p-1 hover:bg-[var(--error-bg)] rounded text-[var(--text-secondary)] hover:text-[var(--error-text)]",title:i("common:actions.delete","Delete"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})},L.id))})]}),ke=()=>t==="admin"||t==="assigned"?he?"md:grid-cols-4":"md:grid-cols-3":"md:grid-cols-2";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(l.Headphones,{className:"w-6 h-6"}),a]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o})]}),!f&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary flex items-center gap-2",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),i("list.newTicket")]})]}),Me(),Ct(),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("form",{onSubmit:q,className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",placeholder:i("list.searchPlaceholder"),value:R,onChange:L=>$(L.target.value),className:"input w-full pl-10"})]}),e.jsx("button",{type:"submit",className:"btn btn-secondary",children:i("list.search")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(!z),className:`btn ${z?"btn-primary":"btn-secondary"} flex items-center gap-2`,children:[e.jsx(l.Filter,{className:"w-4 h-4"}),i("list.filters")]}),e.jsx(ja,{viewMode:J,onChange:fe})]})]}),z&&e.jsxs("div",{className:`card p-4 grid grid-cols-1 ${ke()} gap-4`,children:[he&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.tenant","Workspace")}),e.jsxs("select",{value:Z,onChange:L=>{H(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTenants","All Workspaces")}),m.filter(L=>L.status==="Active").map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.status")}),e.jsxs("select",{value:U,onChange:L=>{C(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allStatuses")}),e.jsx("option",{value:"Open",children:i("tickets.statuses.Open")}),e.jsx("option",{value:"InProgress",children:i("tickets.statuses.InProgress")}),e.jsx("option",{value:"OnHold",children:i("tickets.statuses.OnHold")}),e.jsx("option",{value:"Resolved",children:i("tickets.statuses.Resolved")}),e.jsx("option",{value:"Closed",children:i("tickets.statuses.Closed")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.type")}),e.jsxs("select",{value:D,onChange:L=>{Y(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTypes")}),e.jsx("option",{value:"Bug",children:i("tickets.types.Bug")}),e.jsx("option",{value:"FeatureRequest",children:i("tickets.types.FeatureRequest")}),e.jsx("option",{value:"ApplicationRequest",children:i("tickets.types.ApplicationRequest")}),e.jsx("option",{value:"Support",children:i("tickets.types.Support")}),e.jsx("option",{value:"Question",children:i("tickets.types.Question")})]})]}),(t==="admin"||t==="assigned")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.priority")}),e.jsxs("select",{value:T,onChange:L=>{B(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allPriorities")}),e.jsx("option",{value:"Low",children:i("tickets.priorities.Low")}),e.jsx("option",{value:"Medium",children:i("tickets.priorities.Medium")}),e.jsx("option",{value:"High",children:i("tickets.priorities.High")}),e.jsx("option",{value:"Critical",children:i("tickets.priorities.Critical")})]})]})]}),j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})}):e.jsxs(e.Fragment,{children:[J==="table"&&Le(),J==="cards"&&Be(),J==="kanban"&&We()]}),!j&&I>1&&e.jsx(Sa,{page:S,totalPages:I,totalCount:k,onPageChange:N})]})}exports.ActivityTimeline=Uc;exports.AdminSidebar=Oi;exports.AppHeader=jt;exports.AppLayout=ba;exports.AppSwitcher=ca;exports.AuthLayout=ui;exports.AuthProvider=Cr;exports.Avatar=Si;exports.Breadcrumb=fi;exports.CreateTicketButton=ha;exports.DataTable=yi;exports.DataView=ji;exports.DocPanelProvider=ea;exports.DocsLayout=va;exports.DynamicRouter=Mc;exports.EntityCard=ws;exports.ErrorFallback=zr;exports.ExtendablePage=uo;exports.ExtensionProvider=Jr;exports.FavoritesBar=_c;exports.FavoritesModal=Ra;exports.FavoritesProvider=Er;exports.FeatureGate=Ki;exports.FeatureRouteGuard=Ss;exports.Fill=Wr;exports.Footer=Ns;exports.GlobalErrorBoundary=Gr;exports.Header=js;exports.KanbanBoard=Pi;exports.KanbanCard=wa;exports.KanbanColumn=Na;exports.LanguageSwitcher=vs;exports.LicenseActivationDialog=Ca;exports.LicenseContentBanner=fa;exports.LicenseGuard=Aa;exports.LicenseProvider=Pr;exports.LicenseStatusBadge=Hi;exports.ModuleSidebar=ga;exports.NetworkError=ps;exports.NotificationBell=pa;exports.PAGE_KEYS=_;exports.PageHeader=Ti;exports.PageRegistry=O;exports.Pagination=Sa;exports.PermissionMatrix=Ri;exports.ProtectedRoute=ka;exports.ProviderCard=ki;exports.PublicLayout=ya;exports.RoleBadge=Ci;exports.RouteErrorBoundary=Gi;exports.SessionProvider=Br;exports.SessionWarningModal=qr;exports.SidebarProvider=$r;exports.SignalRProvider=Fr;exports.SlaBadge=sd;exports.Slot=Vr;exports.SlotFillProvider=Hr;exports.SmartStackProvider=po;exports.StatusBadge=Mt;exports.TemplateCard=Ai;exports.ThemeCustomizer=Li;exports.ThemeProvider=yr;exports.ThemeSwitcher=Kt;exports.TicketConversation=Ia;exports.TicketDetailView=pu;exports.TicketSidebar=La;exports.TicketsListView=hu;exports.Tooltip=xa;exports.UnderDevelopment=$i;exports.UnlockReason=cn;exports.UserSidebar=Fi;exports.ViewToggle=ja;exports.WILDCARD_PERMISSION=Nr;exports.adminApi=Ne;exports.api=E;exports.apiClient=Se;exports.authApi=Dt;exports.availabilityApi=Gd;exports.browserInfoService=ta;exports.changeLanguage=hs;exports.createAdminApi=br;exports.createSlotFill=ro;exports.dashboardApi=Go;exports.detectDeviceType=Pa;exports.errorContextService=It;exports.generateUUID=xs;exports.getClientIpAddress=Ta;exports.getTenantBadgeVariant=ys;exports.hasAllLicenseFeatures=kr;exports.hasFullAccess=$t;exports.hasPermission=wr;exports.hasRouteAccess=Sr;exports.logService=Te;exports.matchesWildcard=Ut;exports.myTicketsApi=Fe;exports.notificationsApi=st;exports.parseUserAgent=dc;exports.rulesApi=Bd;exports.skillsApi=zd;exports.slaApi=ma;exports.supportApi=je;exports.templatesApi=Et;exports.tenantAnalyticsApi=cs;exports.ticketDraftService=Ge;exports.useActivePage=co;exports.useAuth=Pe;exports.useClientContext=go;exports.useCollapsibleState=fo;exports.useDocPanel=Gt;exports.useEntityPermissions=ia;exports.useExtensions=St;exports.useFavorites=Ke;exports.useFeatureConfig=_t;exports.useFormFieldExtensions=no;exports.useHasExtension=oo;exports.useLicense=He;exports.useNavigation=Ce;exports.usePageOverride=zt;exports.usePageTracking=aa;exports.usePermissionMatrix=wo;exports.usePermissionSync=So;exports.useRouteConfig=To;exports.useSessionMonitor=Ur;exports.useSidebar=qt;exports.useSignalR=na;exports.useSignalRContext=_r;exports.useSlotFill=Kr;exports.useSlotHasContent=so;exports.useTableColumnExtensions=ao;exports.useTenant=Ee;exports.useTenantUrl=Ze;exports.useTheme=wt;exports.useTicketSignalR=oa;exports.useTicketingProvider=ks;exports.useUserPermissions=Io;exports.userApi=Ft;exports.withPageOverride=lo;exports.workloadApi=Hd;
48
+ //# sourceMappingURL=index-cAikSVW0.js.map