@atlashub/smartstack 3.21.0 → 3.24.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.
- package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js → AgentSkillsPage-BWQSCYl-.js} +2 -2
- package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js.map → AgentSkillsPage-BWQSCYl-.js.map} +1 -1
- package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js → AgentSkillsPage-IQcMnBaD.js} +2 -2
- package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js.map → AgentSkillsPage-IQcMnBaD.js.map} +1 -1
- package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js → AgentWorkloadPage-DqrjkvWL.js} +2 -2
- package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js.map → AgentWorkloadPage-DqrjkvWL.js.map} +1 -1
- package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js → AgentWorkloadPage-w-HiyFYP.js} +2 -2
- package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js.map → AgentWorkloadPage-w-HiyFYP.js.map} +1 -1
- package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js → ApiCatalogDetailPage-D3L8Yf4G.js} +3 -3
- package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js.map → ApiCatalogDetailPage-D3L8Yf4G.js.map} +1 -1
- package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js → ApiCatalogDetailPage-MPT3Kz6H.js} +2 -2
- package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js.map → ApiCatalogDetailPage-MPT3Kz6H.js.map} +1 -1
- package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js → ApiCatalogPage-D4Hg3uiS.js} +2 -2
- package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js.map → ApiCatalogPage-D4Hg3uiS.js.map} +1 -1
- package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js → ApiCatalogPage-DRg5Cz0r.js} +2 -2
- package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js.map → ApiCatalogPage-DRg5Cz0r.js.map} +1 -1
- package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js → ApplicationDetailPage-Caizuyn2.js} +2 -2
- package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js.map → ApplicationDetailPage-Caizuyn2.js.map} +1 -1
- package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js → ApplicationDetailPage-CuCW6aMB.js} +4 -4
- package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js.map → ApplicationDetailPage-CuCW6aMB.js.map} +1 -1
- package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js → ApplicationsDashboardPage-B2MW8-Kc.js} +2 -2
- package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js.map → ApplicationsDashboardPage-B2MW8-Kc.js.map} +1 -1
- package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js → ApplicationsDashboardPage-BDIjFIYZ.js} +3 -3
- package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js.map → ApplicationsDashboardPage-BDIjFIYZ.js.map} +1 -1
- package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js → ApplicationsGridPage-DV-FihKj.js} +2 -2
- package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js.map → ApplicationsGridPage-DV-FihKj.js.map} +1 -1
- package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js → ApplicationsGridPage-DXsTfXPI.js} +2 -2
- package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js.map → ApplicationsGridPage-DXsTfXPI.js.map} +1 -1
- package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js → ApplicationsListPage--CGkyBuJ.js} +2 -2
- package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js.map → ApplicationsListPage--CGkyBuJ.js.map} +1 -1
- package/dist/chunks/{ApplicationsListPage-C91v2rZt.js → ApplicationsListPage-JUX823bh.js} +2 -2
- package/dist/chunks/{ApplicationsListPage-C91v2rZt.js.map → ApplicationsListPage-JUX823bh.js.map} +1 -1
- package/dist/chunks/{ApplicationsPage-BCbgotIx.js → ApplicationsPage-6zgFye6w.js} +2 -2
- package/dist/chunks/{ApplicationsPage-BCbgotIx.js.map → ApplicationsPage-6zgFye6w.js.map} +1 -1
- package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js → ApplicationsPage-CQPuuiO6.js} +4 -4
- package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js.map → ApplicationsPage-CQPuuiO6.js.map} +1 -1
- package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js → AssignmentRulesPage-CFffeEbo.js} +2 -2
- package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js.map → AssignmentRulesPage-CFffeEbo.js.map} +1 -1
- package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js → AssignmentRulesPage-D78UeUId.js} +2 -2
- package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js.map → AssignmentRulesPage-D78UeUId.js.map} +1 -1
- package/dist/chunks/{AssignmentsPage-DmfBYQAD.js → AssignmentsPage-Cww2ifZF.js} +2 -2
- package/dist/chunks/{AssignmentsPage-DmfBYQAD.js.map → AssignmentsPage-Cww2ifZF.js.map} +1 -1
- package/dist/chunks/{AssignmentsPage-sRCCBmRc.js → AssignmentsPage-DE_QS2LO.js} +2 -2
- package/dist/chunks/{AssignmentsPage-sRCCBmRc.js.map → AssignmentsPage-DE_QS2LO.js.map} +1 -1
- package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js → AuthCallbackPage-CA2nO6DG.js} +2 -2
- package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js.map → AuthCallbackPage-CA2nO6DG.js.map} +1 -1
- package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js → AuthCallbackPage-CDUAoX-N.js} +2 -2
- package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js.map → AuthCallbackPage-CDUAoX-N.js.map} +1 -1
- package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js → ConfirmEmailPage-BqsILAYH.js} +2 -2
- package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js.map → ConfirmEmailPage-BqsILAYH.js.map} +1 -1
- package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js → ConfirmEmailPage-INeHCuMB.js} +2 -2
- package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js.map → ConfirmEmailPage-INeHCuMB.js.map} +1 -1
- package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js → CreateSupportTicketPage-BWeuV2aU.js} +2 -2
- package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js.map → CreateSupportTicketPage-BWeuV2aU.js.map} +1 -1
- package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js → CreateSupportTicketPage-OBwF4v7b.js} +2 -2
- package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js.map → CreateSupportTicketPage-OBwF4v7b.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CUZ80NGV.js → DashboardPage-CKHqWrdS.js} +3 -3
- package/dist/chunks/{DashboardPage-CUZ80NGV.js.map → DashboardPage-CKHqWrdS.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CaNOAstg.js → DashboardPage-COmc9b__.js} +3 -3
- package/dist/chunks/{DashboardPage-CaNOAstg.js.map → DashboardPage-COmc9b__.js.map} +1 -1
- package/dist/chunks/{DashboardPage-B48_rQFi.js → DashboardPage-CfKZHiSj.js} +2 -2
- package/dist/chunks/{DashboardPage-B48_rQFi.js.map → DashboardPage-CfKZHiSj.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CUZV1J9t.js → DashboardPage-CwEZZ3jx.js} +2 -2
- package/dist/chunks/{DashboardPage-CUZV1J9t.js.map → DashboardPage-CwEZZ3jx.js.map} +1 -1
- package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js → EscalationConfigPage--7lgZ0kJ.js} +2 -2
- package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js.map → EscalationConfigPage--7lgZ0kJ.js.map} +1 -1
- package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js → EscalationConfigPage-DPyiBcqV.js} +2 -2
- package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js.map → EscalationConfigPage-DPyiBcqV.js.map} +1 -1
- package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js → ForceChangePasswordPage-BE-6umub.js} +2 -2
- package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js.map → ForceChangePasswordPage-BE-6umub.js.map} +1 -1
- package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js → ForceChangePasswordPage-CnsYoWmV.js} +2 -2
- package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js.map → ForceChangePasswordPage-CnsYoWmV.js.map} +1 -1
- package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js → ForgotPasswordPage-CSq4DnFF.js} +2 -2
- package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js.map → ForgotPasswordPage-CSq4DnFF.js.map} +1 -1
- package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js → ForgotPasswordPage-DZLVolAC.js} +2 -2
- package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js.map → ForgotPasswordPage-DZLVolAC.js.map} +1 -1
- package/dist/chunks/{GroupDetailPage-DFBvVO1S.js → GroupDetailPage-Bf9Wb_2j.js} +5 -5
- package/dist/chunks/{GroupDetailPage-DFBvVO1S.js.map → GroupDetailPage-Bf9Wb_2j.js.map} +1 -1
- package/dist/chunks/{GroupDetailPage-B2FkKrGG.js → GroupDetailPage-R-hf3rJ7.js} +2 -2
- package/dist/chunks/{GroupDetailPage-B2FkKrGG.js.map → GroupDetailPage-R-hf3rJ7.js.map} +1 -1
- package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js → MyAccessRequestsPage-BIisvWM6.js} +2 -2
- package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js.map → MyAccessRequestsPage-BIisvWM6.js.map} +1 -1
- package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js → MyAccessRequestsPage-BLSV7Tbx.js} +2 -2
- package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js.map → MyAccessRequestsPage-BLSV7Tbx.js.map} +1 -1
- package/dist/chunks/{MyTenantsPage-BEcYYdGR.js → MyTenantsPage-D-7k9CP1.js} +3 -3
- package/dist/chunks/{MyTenantsPage-BEcYYdGR.js.map → MyTenantsPage-D-7k9CP1.js.map} +1 -1
- package/dist/chunks/{MyTenantsPage-D9f85zjF.js → MyTenantsPage-DqGW6aDt.js} +2 -2
- package/dist/chunks/{MyTenantsPage-D9f85zjF.js.map → MyTenantsPage-DqGW6aDt.js.map} +1 -1
- package/dist/chunks/{MyTicketsPage-DJR8h6y1.js → MyTicketsPage--DgDsnZA.js} +2 -2
- package/dist/chunks/{MyTicketsPage-DJR8h6y1.js.map → MyTicketsPage--DgDsnZA.js.map} +1 -1
- package/dist/chunks/{MyTicketsPage-DiOUExKJ.js → MyTicketsPage-CqJ3Aqob.js} +2 -2
- package/dist/chunks/{MyTicketsPage-DiOUExKJ.js.map → MyTicketsPage-CqJ3Aqob.js.map} +1 -1
- package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js → NavigationAppsPage-Bebis_RT.js} +2 -2
- package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js.map → NavigationAppsPage-Bebis_RT.js.map} +1 -1
- package/dist/chunks/{NavigationAppsPage-If7tmCFY.js → NavigationAppsPage-THNPOAjv.js} +2 -2
- package/dist/chunks/{NavigationAppsPage-If7tmCFY.js.map → NavigationAppsPage-THNPOAjv.js.map} +1 -1
- package/dist/chunks/{NotificationsPage-C29Lln5o.js → NotificationsPage-CAbNW_Cn.js} +2 -2
- package/dist/chunks/{NotificationsPage-C29Lln5o.js.map → NotificationsPage-CAbNW_Cn.js.map} +1 -1
- package/dist/chunks/{NotificationsPage-BiaLRb0s.js → NotificationsPage-DxwizUhL.js} +2 -2
- package/dist/chunks/{NotificationsPage-BiaLRb0s.js.map → NotificationsPage-DxwizUhL.js.map} +1 -1
- package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js → OnboardingWizardPage-C6HlbJ3K.js} +2 -2
- package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js.map → OnboardingWizardPage-C6HlbJ3K.js.map} +1 -1
- package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js → OnboardingWizardPage-CyC2zONO.js} +2 -2
- package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js.map → OnboardingWizardPage-CyC2zONO.js.map} +1 -1
- package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js → PermissionDetailPage-BDHiNgky.js} +2 -2
- package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js.map → PermissionDetailPage-BDHiNgky.js.map} +1 -1
- package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js → PermissionDetailPage-C5K17ydY.js} +2 -2
- package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js.map → PermissionDetailPage-C5K17ydY.js.map} +1 -1
- package/dist/chunks/{PermissionsPage-l0PnY-EE.js → PermissionsPage-COI5LJPo.js} +2 -2
- package/dist/chunks/{PermissionsPage-l0PnY-EE.js.map → PermissionsPage-COI5LJPo.js.map} +1 -1
- package/dist/chunks/{PermissionsPage-DLy9U3P3.js → PermissionsPage-CkOwH2_d.js} +2 -2
- package/dist/chunks/{PermissionsPage-DLy9U3P3.js.map → PermissionsPage-CkOwH2_d.js.map} +1 -1
- package/dist/chunks/{PortalDashboardPage-DFBx38-x.js → PortalDashboardPage-CoEC4CmC.js} +2 -2
- package/dist/chunks/{PortalDashboardPage-DFBx38-x.js.map → PortalDashboardPage-CoEC4CmC.js.map} +1 -1
- package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js → PortalDashboardPage-DrYymEf-.js} +2 -2
- package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js.map → PortalDashboardPage-DrYymEf-.js.map} +1 -1
- package/dist/chunks/{PreferencesPage-BBu8yZQB.js → PreferencesPage-CJRaU3ba.js} +2 -2
- package/dist/chunks/{PreferencesPage-BBu8yZQB.js.map → PreferencesPage-CJRaU3ba.js.map} +1 -1
- package/dist/chunks/{PreferencesPage-B81MsNV1.js → PreferencesPage-Cqr9mAab.js} +2 -2
- package/dist/chunks/{PreferencesPage-B81MsNV1.js.map → PreferencesPage-Cqr9mAab.js.map} +1 -1
- package/dist/chunks/{ProfilePage-DDrl10zj.js → ProfilePage-BZVpg6-l.js} +2 -2
- package/dist/chunks/{ProfilePage-DDrl10zj.js.map → ProfilePage-BZVpg6-l.js.map} +1 -1
- package/dist/chunks/{ProfilePage-DPoXwdnc.js → ProfilePage-Cu_FITeL.js} +2 -2
- package/dist/chunks/{ProfilePage-DPoXwdnc.js.map → ProfilePage-Cu_FITeL.js.map} +1 -1
- package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js → ReferencesManagementPage-DUlVk9Ps.js} +3 -3
- package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js.map → ReferencesManagementPage-DUlVk9Ps.js.map} +1 -1
- package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js → ReferencesManagementPage-ZCuYtqd7.js} +2 -2
- package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js.map → ReferencesManagementPage-ZCuYtqd7.js.map} +1 -1
- package/dist/chunks/{RegisterPage-CiQib3-6.js → RegisterPage-C4xmVwh9.js} +2 -2
- package/dist/chunks/{RegisterPage-CiQib3-6.js.map → RegisterPage-C4xmVwh9.js.map} +1 -1
- package/dist/chunks/{RegisterPage-bXCcJD88.js → RegisterPage-DGyzoIHT.js} +2 -2
- package/dist/chunks/{RegisterPage-bXCcJD88.js.map → RegisterPage-DGyzoIHT.js.map} +1 -1
- package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js → ResetPasswordPage-DqDD6VPR.js} +2 -2
- package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js.map → ResetPasswordPage-DqDD6VPR.js.map} +1 -1
- package/dist/chunks/{ResetPasswordPage-CubPG3yv.js → ResetPasswordPage-Glu-aeqv.js} +2 -2
- package/dist/chunks/{ResetPasswordPage-CubPG3yv.js.map → ResetPasswordPage-Glu-aeqv.js.map} +1 -1
- package/dist/chunks/{ResolutionModal-Bg7XZmR1.js → ResolutionModal-CxjANAOP.js} +2 -2
- package/dist/chunks/{ResolutionModal-Bg7XZmR1.js.map → ResolutionModal-CxjANAOP.js.map} +1 -1
- package/dist/chunks/{ResolutionModal-DqRk_T0n.js → ResolutionModal-Duat18qV.js} +2 -2
- package/dist/chunks/{ResolutionModal-DqRk_T0n.js.map → ResolutionModal-Duat18qV.js.map} +1 -1
- package/dist/chunks/{RoleDetailPage-Blau6_4c.js → RoleDetailPage-BQffUSnt.js} +3 -3
- package/dist/chunks/{RoleDetailPage-Blau6_4c.js.map → RoleDetailPage-BQffUSnt.js.map} +1 -1
- package/dist/chunks/{RoleDetailPage-CiRVxxIP.js → RoleDetailPage-JTm5lD1_.js} +2 -2
- package/dist/chunks/{RoleDetailPage-CiRVxxIP.js.map → RoleDetailPage-JTm5lD1_.js.map} +1 -1
- package/dist/chunks/{RolesPage-Pm-RN3lP.js → RolesPage-B9rRzciI.js} +2 -2
- package/dist/chunks/{RolesPage-Pm-RN3lP.js.map → RolesPage-B9rRzciI.js.map} +1 -1
- package/dist/chunks/{RolesPage-Cb8joqdJ.js → RolesPage-BN8_zMOC.js} +2 -2
- package/dist/chunks/{RolesPage-Cb8joqdJ.js.map → RolesPage-BN8_zMOC.js.map} +1 -1
- package/dist/chunks/{SlaConfigPage-B86McKM6.js → SlaConfigPage-B7kZNig4.js} +2 -2
- package/dist/chunks/{SlaConfigPage-B86McKM6.js.map → SlaConfigPage-B7kZNig4.js.map} +1 -1
- package/dist/chunks/{SlaConfigPage-BY7gvYU6.js → SlaConfigPage-okvZfA_K.js} +2 -2
- package/dist/chunks/{SlaConfigPage-BY7gvYU6.js.map → SlaConfigPage-okvZfA_K.js.map} +1 -1
- package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js → SupportPermissionsPage-DGAPqJbl.js} +2 -2
- package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js.map → SupportPermissionsPage-DGAPqJbl.js.map} +1 -1
- package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js → SupportPermissionsPage-Dg_wLOme.js} +2 -2
- package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js.map → SupportPermissionsPage-Dg_wLOme.js.map} +1 -1
- package/dist/chunks/{TemplatesPage-BDguJ401.js → TemplatesPage-DT9fhlAU.js} +2 -2
- package/dist/chunks/{TemplatesPage-BDguJ401.js.map → TemplatesPage-DT9fhlAU.js.map} +1 -1
- package/dist/chunks/{TemplatesPage-DdnGgioU.js → TemplatesPage-DiEk538p.js} +2 -2
- package/dist/chunks/{TemplatesPage-DdnGgioU.js.map → TemplatesPage-DiEk538p.js.map} +1 -1
- package/dist/chunks/{TenantCard-ffwWsgFQ.js → TenantCard-BbSYk9_Z.js} +2 -2
- package/dist/chunks/{TenantCard-ffwWsgFQ.js.map → TenantCard-BbSYk9_Z.js.map} +1 -1
- package/dist/chunks/{TenantCard-CUjb6og9.js → TenantCard-CEkiKxcZ.js} +2 -2
- package/dist/chunks/{TenantCard-CUjb6og9.js.map → TenantCard-CEkiKxcZ.js.map} +1 -1
- package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js → TenantScopeSelector-BWfYxvEa.js} +2 -2
- package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js.map → TenantScopeSelector-BWfYxvEa.js.map} +1 -1
- package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js → TenantScopeSelector-D-BKgQPV.js} +2 -2
- package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js.map → TenantScopeSelector-D-BKgQPV.js.map} +1 -1
- package/dist/chunks/{TicketDetailPage-GOh9GX7E.js → TicketDetailPage-C1mNS9Up.js} +2 -2
- package/dist/chunks/{TicketDetailPage-GOh9GX7E.js.map → TicketDetailPage-C1mNS9Up.js.map} +1 -1
- package/dist/chunks/{TicketDetailPage-Du8WMyqf.js → TicketDetailPage-ieVDRh42.js} +2 -2
- package/dist/chunks/{TicketDetailPage-Du8WMyqf.js.map → TicketDetailPage-ieVDRh42.js.map} +1 -1
- package/dist/chunks/{TicketsPage-Bqd6moQy.js → TicketsPage-CnuWsnIW.js} +2 -2
- package/dist/chunks/{TicketsPage-Bqd6moQy.js.map → TicketsPage-CnuWsnIW.js.map} +1 -1
- package/dist/chunks/{TicketsPage-WdU4Bb7M.js → TicketsPage-jjyY15_D.js} +2 -2
- package/dist/chunks/{TicketsPage-WdU4Bb7M.js.map → TicketsPage-jjyY15_D.js.map} +1 -1
- package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js → UserCreateTicketPage-B8Tvf-ag.js} +2 -2
- package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js.map → UserCreateTicketPage-B8Tvf-ag.js.map} +1 -1
- package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js → UserCreateTicketPage-DnOsDlfO.js} +2 -2
- package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js.map → UserCreateTicketPage-DnOsDlfO.js.map} +1 -1
- package/dist/chunks/{UserDashboardPage-BP5WeXPS.js → UserDashboardPage-BrtkJ-NB.js} +2 -2
- package/dist/chunks/{UserDashboardPage-BP5WeXPS.js.map → UserDashboardPage-BrtkJ-NB.js.map} +1 -1
- package/dist/chunks/{UserDashboardPage-B53C8fUq.js → UserDashboardPage-KLB5CQP5.js} +2 -2
- package/dist/chunks/{UserDashboardPage-B53C8fUq.js.map → UserDashboardPage-KLB5CQP5.js.map} +1 -1
- package/dist/chunks/{UserDetailPage-B110bmGX.js → UserDetailPage-U7smBQoF.js} +5 -5
- package/dist/chunks/{UserDetailPage-B110bmGX.js.map → UserDetailPage-U7smBQoF.js.map} +1 -1
- package/dist/chunks/{UserDetailPage-CV2VCE46.js → UserDetailPage-_J6lcKAU.js} +2 -2
- package/dist/chunks/{UserDetailPage-CV2VCE46.js.map → UserDetailPage-_J6lcKAU.js.map} +1 -1
- package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js → UserTicketDetailPage-CWoYQgH-.js} +2 -2
- package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js.map → UserTicketDetailPage-CWoYQgH-.js.map} +1 -1
- package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js → UserTicketDetailPage-DkufSlvZ.js} +2 -2
- package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js.map → UserTicketDetailPage-DkufSlvZ.js.map} +1 -1
- package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js → UsersGroupsPage-C38s2-Rq.js} +3 -3
- package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js.map → UsersGroupsPage-C38s2-Rq.js.map} +1 -1
- package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js → UsersGroupsPage-Dq3rAteo.js} +2 -2
- package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js.map → UsersGroupsPage-Dq3rAteo.js.map} +1 -1
- package/dist/chunks/{UsersPage-Bg7033pp.js → UsersPage-B5C5KEUR.js} +2 -2
- package/dist/chunks/{UsersPage-Bg7033pp.js.map → UsersPage-B5C5KEUR.js.map} +1 -1
- package/dist/chunks/{UsersPage-TYAfwPY1.js → UsersPage-CXC9Hvq6.js} +2 -2
- package/dist/chunks/{UsersPage-TYAfwPY1.js.map → UsersPage-CXC9Hvq6.js.map} +1 -1
- package/dist/chunks/{accessRequestsApi-DZeDvzwv.js → accessRequestsApi-B-4TJ5_U.js} +2 -2
- package/dist/chunks/{accessRequestsApi-DZeDvzwv.js.map → accessRequestsApi-B-4TJ5_U.js.map} +1 -1
- package/dist/chunks/{accessRequestsApi-ZXFPCid2.js → accessRequestsApi-DZSfThpd.js} +2 -2
- package/dist/chunks/{accessRequestsApi-ZXFPCid2.js.map → accessRequestsApi-DZSfThpd.js.map} +1 -1
- package/dist/chunks/{aiApi-CsH8DXgs.js → aiApi-B20Teu2v.js} +2 -2
- package/dist/chunks/{aiApi-CsH8DXgs.js.map → aiApi-B20Teu2v.js.map} +1 -1
- package/dist/chunks/{aiApi-CVPzFTXa.js → aiApi-DMGz-RPM.js} +2 -2
- package/dist/chunks/{aiApi-CVPzFTXa.js.map → aiApi-DMGz-RPM.js.map} +1 -1
- package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js → applicationAnalyticsApi-Bwa75Fzd.js} +2 -2
- package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js.map → applicationAnalyticsApi-Bwa75Fzd.js.map} +1 -1
- package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js → applicationAnalyticsApi-CLBqRPfN.js} +2 -2
- package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js.map → applicationAnalyticsApi-CLBqRPfN.js.map} +1 -1
- package/dist/chunks/{groupsApi-BgCk2fsp.js → groupsApi-QzXI-5xu.js} +2 -2
- package/dist/chunks/{groupsApi-BgCk2fsp.js.map → groupsApi-QzXI-5xu.js.map} +1 -1
- package/dist/chunks/{groupsApi-BIbG665N.js → groupsApi-hB9kSWEd.js} +2 -2
- package/dist/chunks/{groupsApi-BIbG665N.js.map → groupsApi-hB9kSWEd.js.map} +1 -1
- package/dist/chunks/{index-Cb3LotuT.js → index--NGcBYUu.js} +3 -3
- package/dist/chunks/{index-Cb3LotuT.js.map → index--NGcBYUu.js.map} +1 -1
- package/dist/chunks/{index-C33zcyF4.js → index--aPwOFjF.js} +2 -2
- package/dist/chunks/{index-C33zcyF4.js.map → index--aPwOFjF.js.map} +1 -1
- package/dist/chunks/{index-sMr9qND_.js → index-0VrOtwP0.js} +2 -2
- package/dist/chunks/{index-sMr9qND_.js.map → index-0VrOtwP0.js.map} +1 -1
- package/dist/chunks/{index-DDKetfKq.js → index-37U271aw.js} +2 -2
- package/dist/chunks/{index-DDKetfKq.js.map → index-37U271aw.js.map} +1 -1
- package/dist/chunks/{index-B9fS7ir6.js → index-B7qZTuQ-.js} +2 -2
- package/dist/chunks/{index-B9fS7ir6.js.map → index-B7qZTuQ-.js.map} +1 -1
- package/dist/chunks/{index-CdjBY7L8.js → index-Bedzmqr-.js} +2 -2
- package/dist/chunks/{index-CdjBY7L8.js.map → index-Bedzmqr-.js.map} +1 -1
- package/dist/chunks/{index-CHG_O1fS.js → index-Betxo5g5.js} +2 -2
- package/dist/chunks/{index-CHG_O1fS.js.map → index-Betxo5g5.js.map} +1 -1
- package/dist/chunks/{index-jiGu-H8x.js → index-BmaJz475.js} +2 -2
- package/dist/chunks/{index-jiGu-H8x.js.map → index-BmaJz475.js.map} +1 -1
- package/dist/chunks/{index-C53JoVNk.js → index-Buhqag3v.js} +2 -2
- package/dist/chunks/{index-C53JoVNk.js.map → index-Buhqag3v.js.map} +1 -1
- package/dist/chunks/{index-DO0Rw7hX.js → index-C3VxlfKq.js} +2 -2
- package/dist/chunks/{index-DO0Rw7hX.js.map → index-C3VxlfKq.js.map} +1 -1
- package/dist/chunks/{index-CSQ60fpG.js → index-CgpRo8Oe.js} +2 -2
- package/dist/chunks/{index-CSQ60fpG.js.map → index-CgpRo8Oe.js.map} +1 -1
- package/dist/chunks/{index-B-e-ELsf.js → index-DOY0w8Iu.js} +8 -8
- package/dist/chunks/{index-B-e-ELsf.js.map → index-DOY0w8Iu.js.map} +1 -1
- package/dist/chunks/{index-D2REDIRX.js → index-DwuvIOrQ.js} +2 -2
- package/dist/chunks/{index-D2REDIRX.js.map → index-DwuvIOrQ.js.map} +1 -1
- package/dist/chunks/{index-DCcl7Qof.js → index-DzedSLdI.js} +2 -2
- package/dist/chunks/{index-DCcl7Qof.js.map → index-DzedSLdI.js.map} +1 -1
- package/dist/chunks/{index-2wUhd9Lu.js → index-IgLVXPg8.js} +10 -10
- package/dist/chunks/index-IgLVXPg8.js.map +1 -0
- package/dist/chunks/{index-CwSaRXXg.js → index-lpIzhufD.js} +1916 -1900
- package/dist/chunks/index-lpIzhufD.js.map +1 -0
- package/dist/chunks/{index-Cuwn2q-f.js → index-mLUKwbGl.js} +4 -4
- package/dist/chunks/{index-Cuwn2q-f.js.map → index-mLUKwbGl.js.map} +1 -1
- package/dist/chunks/{index-B0mk2tNY.js → index-tO6MMIFB.js} +2 -2
- package/dist/chunks/{index-B0mk2tNY.js.map → index-tO6MMIFB.js.map} +1 -1
- package/dist/chunks/{tenantIconMap-BpNANQ5s.js → tenantIconMap-BQD9byc8.js} +2 -2
- package/dist/chunks/{tenantIconMap-BpNANQ5s.js.map → tenantIconMap-BQD9byc8.js.map} +1 -1
- package/dist/chunks/{tenantIconMap-DtdUgvJO.js → tenantIconMap-CTMuSt18.js} +2 -2
- package/dist/chunks/{tenantIconMap-DtdUgvJO.js.map → tenantIconMap-CTMuSt18.js.map} +1 -1
- package/dist/chunks/{ticketingApi-Bu4rKwLl.js → ticketingApi-BNIdox5t.js} +2 -2
- package/dist/chunks/{ticketingApi-Bu4rKwLl.js.map → ticketingApi-BNIdox5t.js.map} +1 -1
- package/dist/chunks/{ticketingApi-r4Avm9iS.js → ticketingApi-J0vC_t7r.js} +2 -2
- package/dist/chunks/{ticketingApi-r4Avm9iS.js.map → ticketingApi-J0vC_t7r.js.map} +1 -1
- package/dist/chunks/{useAccessRequests-B9bF4swg.js → useAccessRequests-DCNNLnxk.js} +3 -3
- package/dist/chunks/{useAccessRequests-B9bF4swg.js.map → useAccessRequests-DCNNLnxk.js.map} +1 -1
- package/dist/chunks/{useAccessRequests-JyPUX3Om.js → useAccessRequests-DT7X4FAK.js} +2 -2
- package/dist/chunks/{useAccessRequests-JyPUX3Om.js.map → useAccessRequests-DT7X4FAK.js.map} +1 -1
- package/dist/chunks/{useUserAccessRequests-DjPQenC2.js → useUserAccessRequests-BYbmG4c7.js} +2 -2
- package/dist/chunks/{useUserAccessRequests-DjPQenC2.js.map → useUserAccessRequests-BYbmG4c7.js.map} +1 -1
- package/dist/chunks/{useUserAccessRequests-BB6FHW14.js → useUserAccessRequests-CylKxRN6.js} +2 -2
- package/dist/chunks/{useUserAccessRequests-BB6FHW14.js.map → useUserAccessRequests-CylKxRN6.js.map} +1 -1
- package/dist/hooks/useCollapsibleState.d.ts +5 -2
- package/dist/hooks/useCollapsibleState.d.ts.map +1 -1
- package/dist/i18n/config.d.ts +1 -0
- package/dist/i18n/config.d.ts.map +1 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/smartstack.cjs +1 -1
- package/dist/smartstack.js +1 -1
- package/dist/utils/permissions.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-2wUhd9Lu.js.map +0 -1
- package/dist/chunks/index-CwSaRXXg.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=require("react-router-dom"),O=require("react-i18next"),a=require("lucide-react"),w=require("./index-2wUhd9Lu.js"),ee=require("@tiptap/react"),se=require("@tiptap/starter-kit"),re=require("@tiptap/extension-link"),ie=require("@tiptap/extension-image"),le=require("@tiptap/extension-placeholder"),ne=require("@tiptap/extension-text-align"),oe=require("@tiptap/extension-underline"),ce=require("@tiptap/extension-text-style"),de=require("@tiptap/extension-color"),me=require("@tiptap/extension-highlight"),xe=require("@monaco-editor/react"),B={emailTemplates:{getAll:t=>w.api.get("/api/administration/workflows/email-templates",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/email-templates/${t}`),getByCode:t=>w.api.get(`/api/administration/workflows/email-templates/by-code/${t}`),create:t=>w.api.post("/api/administration/workflows/email-templates",t),update:(t,s)=>w.api.put(`/api/administration/workflows/email-templates/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/email-templates/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/deactivate`),preview:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/preview`,s),testSend:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/test-send`,s),getTranslation:(t,s)=>w.api.get(`/api/administration/workflows/email-templates/${t}/translations/${s}`),createTranslation:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/translations`,s),updateTranslation:(t,s,p)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,p)},workflows:{getAll:t=>w.api.get("/api/administration/workflows/definitions",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/definitions/${t}`),create:t=>w.api.post("/api/administration/workflows/definitions",t),update:(t,s)=>w.api.put(`/api/administration/workflows/definitions/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/definitions/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/deactivate`),addStep:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps`,s),updateStep:(t,s,p)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,p),deleteStep:(t,s)=>w.api.delete(`/api/administration/workflows/definitions/${t}/steps/${s}`),reorderSteps:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps/reorder`,{stepOrder:s})},triggers:{getAll:()=>w.api.get("/api/administration/workflows/definitions/triggers")}};function pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const x=await B.emailTemplates.getAll({search:v||void 0});g(Array.isArray(x)?x:[])}catch(x){console.error("Failed to load templates:",x)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=x=>{x.preventDefault(),A(1),f()},C=async(x,V)=>{if(V?.stopPropagation(),x.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:x.name})))try{await B.emailTemplates.delete(x.id),f()}catch(K){console.error("Failed to delete template:",K)}},_=(F-1)*h,T=r.slice(_,_+h),M=Math.ceil(r.length/h),P={transactional:r.filter(x=>x.category==="transactional"),notification:r.filter(x=>x.category==="notification"),marketing:r.filter(x=>x.category==="marketing"),system:r.filter(x=>x.category==="system")},b=x=>t(`emailTemplates.categories.${x.toLowerCase()}`)||x,S=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.code")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("emailTemplates.columns.category")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("emailTemplates.columns.translations")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]})})}),!u&&T.length>0&&T.map(x=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:V=>V.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("code",{className:"text-sm bg-[var(--bg-secondary)] px-2 py-0.5 rounded text-[var(--text-primary)]",children:x.code})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:x.name}),x.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:b(x.category)})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:x.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:x.isActive?"active":"inactive",label:x.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("emailTemplates.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:V=>{V.stopPropagation(),s(`/administration/workflows/email-templates/${x.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("emailTemplates.edit.title"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!x.isSystem&&e.jsx("button",{onClick:V=>C(x,V),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("emailTemplates.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},x.id))]})]})}),$=()=>u?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):T.length===0?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--color-accent-50)] flex items-center justify-center mb-3",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]}):T.map(x=>e.jsx(w.TemplateCard,{name:x.name,code:x.code,category:b(x.category),isActive:x.isActive,isSystem:x.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:x.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${x.id}/edit`),onDelete:()=>C(x),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},x.id)),W=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:$()}),L=x=>x==="transactional"?"bg-[var(--success-dot)]":x==="notification"?"bg-[var(--warning-dot)]":x==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",o=x=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-accent-500)] flex items-center justify-center shadow-lg",children:e.jsx(a.Mail,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:x.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:x.code})]})]})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${x.isActive?"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 ${x.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),x.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")]}),e.jsxs("div",{className:"flex items-center gap-1 text-[var(--text-tertiary)]",children:[e.jsx(a.Languages,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:x.languages.length})]})]})})]},x.id),E=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsx(e.Fragment,{children:Object.entries(P).map(([x,V])=>e.jsxs("div",{className:"min-w-[280px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${L(x)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(x)}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:V.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[V.map(o),V.length===0&&e.jsxs("div",{className:"border-2 border-dashed border-[var(--color-accent-200)] rounded-lg p-6 text-center",children:[e.jsx(a.Mail,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("emailTemplates.noResults")})]})]})]},x))})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates")}]}),e.jsx(w.PageHeader,{title:t("emailTemplates.title"),subtitle:`${r.length} templates`,icon:e.jsx(a.Mail,{className:"w-6 h-6"}),actions:e.jsxs("button",{onClick:()=>s("/administration/workflows/email-templates/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.create")]})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:d,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:x=>m(x.target.value),placeholder:t("emailTemplates.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&W(),n==="kanban"&&E(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:M,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"templates"})]})}function ue(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async m=>{m.preventDefault(),i(!0),g(null);try{const n=await B.emailTemplates.create({code:u.code,name:u.name,description:u.description||void 0,category:u.category});s(`/administration/email-templates/${n.id}`)}catch(n){const D=n instanceof Error?n.message:"An error occurred while creating the template";g(D)}finally{i(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:t("emailTemplates.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/email-templates/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("emailTemplates.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-violet-500 to-purple-500 flex items-center justify-center shadow-lg shadow-primary-500/20",children:e.jsx(a.Mail,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("emailTemplates.description")})]})]})]}),e.jsxs("form",{onSubmit:v,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.code,onChange:m=>k(n=>({...n,code:m.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., welcome-email",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("emailTemplates.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.name,onChange:m=>k(n=>({...n,name:m.target.value})),placeholder:"e.g., Welcome Email",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:u.description,onChange:m=>k(n=>({...n,description:m.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.category")}),e.jsxs("select",{value:u.category,onChange:m=>k(n=>({...n,category:m.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/email-templates/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:p,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const ve=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],he=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}];function be(){const{t,i18n:s}=O.useTranslation("communications"),{id:p}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,m]=U.useSearchParams(),n=v.get("tab")||"preview",D=y=>m({tab:y}),[F,A]=l.useState(null),[h,f]=l.useState(null),[d,C]=l.useState(!1),[_,T]=l.useState(!1),[M,P]=l.useState(null),[b,S]=l.useState(null),[$,W]=l.useState(!1),[L,o]=l.useState(""),E=l.useCallback(async()=>{if(p)try{k(!0),A(null);const y=await B.emailTemplates.getById(p);g(y)}catch(y){console.error("Failed to load template:",y),A(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[p,t]);l.useEffect(()=>{E()},[E]);const x=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),E()}catch(y){console.error("Failed to activate template:",y),A(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),E()}catch(y){console.error("Failed to deactivate template:",y),A(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},K=async()=>{if(!(!p||!r)){if(r.isSystem){A(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),A(null),await B.emailTemplates.delete(p),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),A(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Y=async y=>{if(p)try{W(!0),P(y);const c=await B.emailTemplates.preview(p,{languageCode:y});S({subject:c.subject,htmlBody:c.htmlBody})}catch(c){console.error("Failed to preview template:",c),A(t("emailTemplates.detail.errors.previewFailed"))}finally{W(!1)}},G=()=>{P(null),S(null)},J=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const c=JSON.parse(r.variablesJson);Array.isArray(c)?y=c.filter(N=>N?.name):typeof c=="object"&&(y=Object.entries(c).filter(([N])=>N&&N!=="undefined").map(([N,I])=>({name:N,description:typeof I=="object"&&I!==null?I.description:void 0,type:typeof I=="object"&&I!==null?I.type:void 0,required:typeof I=="object"&&I!==null?I.required:!1})))}catch{}return{user:ve,email:he,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],c=r.translations.find(N=>N.languageCode===y);o(c?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!L?null:r.translations.find(y=>y.languageCode===L)||null,[r?.translations,L]),q=[{id:"preview",label:t("emailTemplates.detail.tabs.preview"),icon:e.jsx(a.Eye,{className:"w-4 h-4"})},{id:"info",label:t("emailTemplates.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.detail.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],z=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,R=y=>t(`languages.${y}`,{defaultValue:y.toUpperCase()});return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:r?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:r.name}),r.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.detail.system")}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${r.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:r.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})]}),r.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:r.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.edit.title")})]}),e.jsxs("button",{onClick:r.isActive?V:x,disabled:d,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${r.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[d&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!d&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!d&&!r.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:r.isActive?t("emailTemplates.deactivate"):t("emailTemplates.activate")})]}),e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.delete")})]})]})]}),F&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),F]}),h&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),h]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(y=>e.jsxs("button",{onClick:()=>D(y.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${n===y.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[y.icon,e.jsx("span",{className:"hidden sm:inline",children:y.label}),y.id==="translations"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${n===y.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:r.translations.length})]},y.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[n==="preview"&&e.jsxs("div",{className:"space-y-6",children:[r.translations.length>0?e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:[t("emailTemplates.detail.previewLanguage",{defaultValue:"Langue"}),":"]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-tertiary)] rounded-[var(--radius-button)]",children:r.translations.map(y=>e.jsx("button",{onClick:()=>o(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${L===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:R(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),t("emailTemplates.edit.title")]})]}):e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(a.Mail,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"mb-4",children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}),j&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.subject")})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("p",{className:"text-[var(--text-primary)] font-medium",children:j.subject})})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.emailBody",{defaultValue:"Contenu de l'email"})})]}),e.jsxs("button",{onClick:()=>Y(j.languageCode),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Eye,{className:"w-3 h-3"}),t("emailTemplates.detail.fullPreview",{defaultValue:"Plein ecran"})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx("iframe",{srcDoc:j.htmlBody,className:"w-full min-h-[400px] border-0",title:"Email Preview",sandbox:"allow-same-origin"})})]}),j.textBody&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.textVersion",{defaultValue:"Version texte"})})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-[var(--text-secondary)] font-mono",children:j.textBody})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.variables")})]}),e.jsxs("div",{className:"p-4 space-y-4 max-h-[500px] overflow-y-auto",children:[J.custom.length>0&&e.jsx(Q,{title:t("emailTemplates.detail.customVariables"),variables:J.custom,t,defaultExpanded:!0}),e.jsx(Q,{title:t("emailTemplates.detail.userVariables"),variables:J.user,t,defaultExpanded:!1}),e.jsx(Q,{title:t("emailTemplates.detail.emailVariables"),variables:J.email,t,defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Settings,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.quickInfo")})]}),e.jsxs("div",{className:"p-4 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.code")}),e.jsx("code",{className:"px-2 py-0.5 bg-[var(--bg-tertiary)] rounded text-[var(--text-primary)] text-xs",children:r.code})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.category")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:z(r.category)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.columns.translations")}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:[r.translations.length,"/4"]})]})]})]})]})]})]}),n==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:r.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:r.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.category")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:z(r.category)})]}),r.applicationId&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.application")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.applicationId})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.createdAt).toLocaleString()})]}),r.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.updatedAt).toLocaleString()})]})]})]})]})}),n==="translations"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.translationsTitle")," (",r.translations.length,")"]}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addTranslation")]})]}),r.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}):e.jsx("div",{className:"space-y-3",children:r.translations.map(y=>e.jsx(ge,{translation:y,templateId:p,onPreview:()=>Y(y.languageCode),t,getLanguageLabel:R},y.id))})]})]}),_&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("emailTemplates.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("emailTemplates.confirmDelete",{name:r.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:K,disabled:d,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[d?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),M&&b&&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-card)] border border-[var(--border-color)] p-6 max-w-4xl w-full max-h-[90vh] overflow-hidden shadow-xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.preview")," - ",R(M)]}),e.jsxs("button",{onClick:G,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("span",{className:"sr-only",children:"Close"}),"×"]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.subject")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:b.subject})]}),e.jsx("div",{className:"flex-1 overflow-auto border border-[var(--border-color)] rounded-[var(--radius-card)] bg-white",children:e.jsx("iframe",{srcDoc:b.htmlBody,className:"w-full h-full min-h-[400px]",title:"Email Preview"})})]})}),$&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-white"})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]})}function ge({translation:t,templateId:s,onPreview:p,t:i,getLanguageLabel:r}){const g=U.useNavigate(),[u,k]=l.useState(!1);return e.jsxs("div",{className:"rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors overflow-hidden",children:[e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:t.languageCode})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:r(t.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:t.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>k(!u),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[u?e.jsx(a.ChevronUp,{className:"w-4 h-4"}):e.jsx(a.ChevronDown,{className:"w-4 h-4"}),u?i("emailTemplates.detail.collapse",{defaultValue:"Reduire"}):i("emailTemplates.detail.expand",{defaultValue:"Voir le contenu"})]}),e.jsxs("button",{onClick:p,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(a.Eye,{className:"w-4 h-4"}),i("emailTemplates.detail.preview")]}),e.jsxs("button",{onClick:()=>g(`/administration/workflows/email-templates/${s}/edit`),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),i("emailTemplates.edit.title")]})]})]})}),u&&e.jsx("div",{className:"border-t border-[var(--border-color)]",children:e.jsx("div",{className:"bg-white max-h-[300px] overflow-auto",children:e.jsx("iframe",{srcDoc:t.htmlBody,className:"w-full min-h-[200px] border-0",title:`Email Preview - ${t.languageCode}`,sandbox:"allow-same-origin"})})})]})}function Q({title:t,variables:s,t:p,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-3 py-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 space-y-1",children:s.map(u=>e.jsx(fe,{variable:u,t:p},u.name))})]})}function fe({variable:t,t:s}){const[p,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)};return e.jsxs("div",{className:"group flex items-center justify-between p-2 rounded hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono text-[var(--color-accent-600)]",children:r}),t.required&&e.jsx("span",{className:"text-xs text-[var(--error-text)]",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:t.description})]}),e.jsx("button",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-[var(--bg-hover)] transition-all",title:s("emailTemplates.detail.copyVariable",{defaultValue:"Copier"}),children:p?e.jsx(a.Check,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(a.Copy,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})}function ye({content:t,onChange:s,placeholder:p,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,m]=l.useState(""),[n,D]=l.useState(!1),[F,A]=l.useState(""),[h,f]=l.useState(!1),d=ee.useEditor({extensions:[se.configure({heading:{levels:[1,2,3]}}),re.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ie.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),le.configure({placeholder:p||"Commencez a ecrire votre email..."}),ne.configure({types:["heading","paragraph"]}),oe,ce.TextStyle,de.Color,me.configure({multicolor:!0})],content:t,onUpdate:({editor:L})=>{const o=L.getHTML();s(o),k(o)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&d&&u!==d.getHTML()&&d.commands.setContent(u)},[r,d,u]),l.useEffect(()=>{d&&k(d.getHTML())},[d?.getHTML()]);const C=l.useCallback(L=>{const o=L||"";k(o),s(o)},[s]),_=l.useCallback(()=>{d&&d.commands.setContent(u),g("visual")},[d,u]),T=l.useCallback(()=>{d&&k(d.getHTML()),g("code")},[d]),M=l.useCallback(()=>{v&&d&&(d.chain().focus().extendMarkRange("link").setLink({href:v}).run(),m(""),D(!1))},[d,v]),P=l.useCallback(()=>{d&&(d.chain().focus().unsetLink().run(),D(!1))},[d]),b=l.useCallback(()=>{F&&d&&(d.chain().focus().setImage({src:F}).run(),A(""),f(!1))},[d,F]),S=l.useCallback(L=>{if(d){const o=`{{ ${L} }}`;d.chain().focus().insertContent(`<span class="variable-tag" data-variable="${L}">${o}</span>`).run()}},[d]);if(l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),!d)return e.jsx("div",{className:"flex items-center justify-center h-64 bg-[var(--bg-secondary)] rounded-lg",children:e.jsx("div",{className:"animate-pulse text-[var(--text-tertiary)]",children:"Chargement de l'editeur..."})});const $=({onClick:L,isActive:o=!1,disabled:E=!1,title:x,children:V})=>e.jsx("button",{type:"button",onClick:L,disabled:E,title:x,className:`p-1.5 rounded transition-colors ${o?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"hover:bg-[var(--bg-hover)] text-[var(--text-secondary)]"} ${E?"opacity-50 cursor-not-allowed":""}`,children:V}),W=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});return e.jsxs("div",{className:`border border-[var(--border-color)] rounded-lg overflow-hidden bg-[var(--bg-primary)] ${i||""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]",children:[e.jsxs("div",{className:"flex items-center gap-1 mr-2",children:[e.jsxs("button",{type:"button",onClick:_,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="visual"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Eye,{className:"w-3 h-3"}),"Visuel"]}),e.jsxs("button",{type:"button",onClick:T,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="code"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Code,{className:"w-3 h-3"}),"Code"]})]}),r==="visual"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().undo().run(),disabled:!d.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().redo().run(),disabled:!d.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),isActive:d.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),isActive:d.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:3}).run(),isActive:d.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBold().run(),isActive:d.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleItalic().run(),isActive:d.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleUnderline().run(),isActive:d.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleStrike().run(),isActive:d.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("left").run(),isActive:d.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("center").run(),isActive:d.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("right").run(),isActive:d.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBulletList().run(),isActive:d.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleOrderedList().run(),isActive:d.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBlockquote().run(),isActive:d.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>D(!n),isActive:d.isActive("link")||n,title:"Lien",children:e.jsx(a.Link,{className:"w-4 h-4"})}),n&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:v,onChange:L=>m(L.target.value),placeholder:"https://...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:L=>L.key==="Enter"&&M()}),e.jsx("button",{type:"button",onClick:M,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),d.isActive("link")&&e.jsx("button",{type:"button",onClick:P,className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>f(!h),isActive:h,title:"Image",children:e.jsx(a.Image,{className:"w-4 h-4"})}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:F,onChange:L=>A(L.target.value),placeholder:"URL de l'image...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:L=>L.key==="Enter"&&b()}),e.jsx("button",{type:"button",onClick:b,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>f(!1),className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsx($,{onClick:()=>{d.chain().focus().insertContent('<img src="{{ company_logo_url }}" alt="Logo" style="max-width: 200px; height: auto;" />').run()},title:"Inserer le logo",children:e.jsx("span",{className:"text-xs font-medium",children:"Logo"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{onClick:()=>{},title:"Couleur du texte",children:e.jsx(a.Palette,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#000000","#374151","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"].map(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().setColor(L).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{onClick:()=>{},title:"Surligner",children:e.jsx(a.Highlighter,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#fef08a","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8"].map(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().toggleHighlight({color:L}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ee.EditorContent,{editor:d,className:"[&_.ProseMirror]:min-h-[400px] [&_.ProseMirror]:p-4 [&_.ProseMirror]:focus:outline-none [&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:text-[var(--text-tertiary)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left [&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0 [&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"}):e.jsx(xe,{height:"400px",language:"html",theme:"vs-dark",value:u,onChange:C,options:{minimap:{enabled:!1},fontSize:13,wordWrap:"on",formatOnPaste:!0,automaticLayout:!0,scrollBeyondLastLine:!1,lineNumbers:"on",tabSize:2,folding:!0,renderWhitespace:"selection"}})})]})}const je=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],we=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}],te=["fr","en","de","it"],Ne={userName:"Jean Dupont",firstName:"Jean",lastName:"Dupont",displayName:"Jean Dupont",email:"jean.dupont@example.com",user_email:"jean.dupont@example.com",userEmail:"jean.dupont@example.com",phoneNumber:"+41 21 123 45 67",phone:"+41 21 123 45 67",mobilePhone:"+41 79 123 45 67",mobile:"+41 79 123 45 67",city:"Lausanne",country:"Suisse",streetAddress:"Rue du Lac 15",address:"Rue du Lac 15, 1003 Lausanne",postalCode:"1003",zipCode:"1003",company:"SmartStack SA",companyName:"SmartStack SA",company_name:"SmartStack SA",organization:"SmartStack SA",department:"Informatique",jobTitle:"Developpeur Senior",job_title:"Developpeur Senior",position:"Developpeur Senior",office:"Lausanne HQ",employeeId:"EMP-001234",employee_id:"EMP-001234",managerName:"Marie Martin",manager:"Marie Martin",manager_name:"Marie Martin",company_logo_url:"https://example.com/logo.png",logo_url:"https://example.com/logo.png",logoUrl:"https://example.com/logo.png",appName:"SmartStack",app_name:"SmartStack",applicationName:"SmartStack",siteName:"SmartStack",site_name:"SmartStack",resetUrl:"https://app.smartstack.ch/reset-password?token=abc123",reset_url:"https://app.smartstack.ch/reset-password?token=abc123",resetLink:"https://app.smartstack.ch/reset-password?token=abc123",reset_link:"https://app.smartstack.ch/reset-password?token=abc123",confirmUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirm_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmationUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmation_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmLink:"https://app.smartstack.ch/confirm-email?token=xyz789",activationUrl:"https://app.smartstack.ch/activate?token=xyz789",activation_url:"https://app.smartstack.ch/activate?token=xyz789",activationLink:"https://app.smartstack.ch/activate?token=xyz789",loginUrl:"https://app.smartstack.ch/login",login_url:"https://app.smartstack.ch/login",loginLink:"https://app.smartstack.ch/login",dashboardUrl:"https://app.smartstack.ch/dashboard",dashboard_url:"https://app.smartstack.ch/dashboard",profileUrl:"https://app.smartstack.ch/profile",profile_url:"https://app.smartstack.ch/profile",unsubscribeUrl:"https://app.smartstack.ch/unsubscribe?token=abc",unsubscribe_url:"https://app.smartstack.ch/unsubscribe?token=abc",adminName:"Admin Systeme",admin_name:"Admin Systeme",adminEmail:"admin@smartstack.ch",admin_email:"admin@smartstack.ch",supportEmail:"support@atlashub.ch",support_email:"support@atlashub.ch",supportPhone:"+41 21 123 00 00",support_phone:"+41 21 123 00 00",expiresIn:"24 heures",expires_in:"24 heures",expirationTime:"24 heures",expiration_time:"24 heures",expiryDate:"16 janvier 2026",expiry_date:"16 janvier 2026",currentDate:new Date().toLocaleDateString("fr-CH"),current_date:new Date().toLocaleDateString("fr-CH"),date:new Date().toLocaleDateString("fr-CH"),today:new Date().toLocaleDateString("fr-CH"),currentYear:new Date().getFullYear().toString(),current_year:new Date().getFullYear().toString(),year:new Date().getFullYear().toString(),currentTime:new Date().toLocaleTimeString("fr-CH"),current_time:new Date().toLocaleTimeString("fr-CH"),time:new Date().toLocaleTimeString("fr-CH"),temporaryPassword:"TempPass123!",temporary_password:"TempPass123!",tempPassword:"TempPass123!",temp_password:"TempPass123!",newPassword:"NewPass456!",new_password:"NewPass456!",password:"********",token:"abc123xyz789",verificationCode:"123456",verification_code:"123456",code:"123456",otp:"123456",ticketId:"TKT-2026-00123",ticket_id:"TKT-2026-00123",ticketNumber:"TKT-2026-00123",ticket_number:"TKT-2026-00123",ticketSubject:"Question technique",ticket_subject:"Question technique",ticketStatus:"En cours",ticket_status:"En cours",orderId:"ORD-2026-00456",order_id:"ORD-2026-00456",orderNumber:"ORD-2026-00456",order_number:"ORD-2026-00456",invoiceId:"INV-2026-00789",invoice_id:"INV-2026-00789",invoiceNumber:"INV-2026-00789",invoice_number:"INV-2026-00789",amount:"CHF 150.00",total:"CHF 150.00",price:"CHF 150.00",reason:"Mise a jour de securite",message:"Votre demande a ete traitee avec succes.",description:"Description de l'element",title:"Titre de l'element",name:"Nom de l'element",value:"Valeur exemple",count:"5",number:"42",id:"12345"};function ke(t){const s=t.toLowerCase();return s.includes("url")||s.includes("link")?"https://app.smartstack.ch/example":s.includes("email")||s.includes("mail")?"exemple@smartstack.ch":s.includes("phone")||s.includes("tel")||s.includes("mobile")?"+41 21 123 45 67":s.includes("date")||s.includes("time")||s.includes("at")?new Date().toLocaleDateString("fr-CH"):s.includes("year")?new Date().getFullYear().toString():s.includes("name")||s.includes("nom")?"Jean Dupont":s.includes("password")||s.includes("pwd")||s.includes("pass")?"MotDePasse123!":s.includes("code")||s.includes("token")||s.includes("otp")?"123456":s.includes("id")||s.includes("number")||s.includes("num")?"12345":s.includes("amount")||s.includes("price")||s.includes("total")||s.includes("cost")?"CHF 100.00":s.includes("count")||s.includes("qty")||s.includes("quantity")?"5":`[${t.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase()}]`}function Z(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(p,i)=>Ne[i]||ke(i)),s=s.replace(/\{%\s*if\s+\w+\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/gi,"$1"),s=s.replace(/\{%\s*else\s*%\}[\s\S]*?(?=\{%|\$)/gi,""),s=s.replace(/\{%[^%]*%\}/g,""),s}function Te(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=U.useSearchParams(),D=m.get("tab")||"info",F=c=>n({tab:c}),[A,h]=l.useState(null),[f,d]=l.useState(null),[C,_]=l.useState({name:"",description:"",category:""}),[T,M]=l.useState(null),[P,b]=l.useState(!1),[S,$]=l.useState(!1),[W,L]=l.useState(!0),[o,E]=l.useState(!1),x=l.useMemo(()=>{let c=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?c=N.filter(I=>I?.name):typeof N=="object"&&(c=Object.entries(N).filter(([I])=>I&&I!=="undefined").map(([I,H])=>({name:I,description:typeof H=="object"&&H!==null?H.description:void 0,type:typeof H=="object"&&H!==null?H.type:void 0,required:typeof H=="object"&&H!==null?H.required:!1})))}catch{}return{user:je,email:we,custom:c}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const c=await B.emailTemplates.getById(s);r(c),_({name:c.name,description:c.description||"",category:c.category})}catch(c){console.error("Failed to load template:",c),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const K=async c=>{if(c.preventDefault(),!(!s||!i))try{v(!0),h(null),await B.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),d(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Y=()=>{const c=i?.translations.map(I=>I.languageCode)||[],N=te.filter(I=>!c.includes(I));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}M({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},G=c=>{M({languageCode:c.languageCode,subject:c.subject,htmlBody:c.htmlBody,textBody:c.textBody||""}),b(!1)},J=async()=>{if(!(!s||!T))try{$(!0),h(null),P?(await B.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationAdded"))):(await B.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationUpdated"))),M(null),V()}catch(c){console.error("Failed to save translation:",c),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{$(!1)}},j=async c=>{if(s&&!(!c||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{$(!0),h(null),h("Delete translation API not implemented yet")}catch(N){console.error("Failed to delete translation:",N),h(t("emailTemplates.edit.errors.translationDeleteFailed"))}finally{$(!1)}},q=[{id:"info",label:t("emailTemplates.edit.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.edit.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],z=c=>t(`languages.${c}`,{defaultValue:c.toUpperCase()});if(g)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(!i)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>p("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]});const R=i.translations.map(c=>c.languageCode),y=te.filter(c=>!R.includes(c));return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>p(`/administration/workflows/email-templates/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.edit.title")}),i.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.edit.systemTemplate")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),A&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),A]}),f&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),f]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(c=>e.jsxs("button",{onClick:()=>F(c.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${D===c.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[c.icon,e.jsx("span",{className:"hidden sm:inline",children:c.label})]},c.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[D==="info"&&e.jsxs("form",{onSubmit:K,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:C.name,onChange:c=>_(N=>({...N,name:c.target.value})),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:C.description,onChange:c=>_(N=>({...N,description:c.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.category")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsxs("select",{required:!0,value:C.category,onChange:c=>_(N=>({...N,category:c.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:()=>p(`/administration/workflows/email-templates/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),D==="translations"&&!T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.edit.tabs.translations")," (",i.translations.length,"/4)"]}),y.length>0&&e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.edit.addTranslation")]})]}),i.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")})]}):e.jsx("div",{className:"space-y-3",children:i.translations.map(c=>e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:c.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:z(c.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:c.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>G(c),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Settings,{className:"w-4 h-4"}),t("emailTemplates.edit.editTranslation")]}),e.jsx("button",{onClick:()=>j(c.languageCode),disabled:S,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})},c.id))})]}),D==="translations"&&T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t(P?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>L(!W),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${W?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Columns,{className:"w-4 h-4"}),t("emailTemplates.edit.showPreview")]}),e.jsx("button",{onClick:()=>M(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${W?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[P&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.language")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("select",{value:T.languageCode,onChange:c=>M(N=>N?{...N,languageCode:c.target.value}:null),className:"input w-full max-w-xs",children:y.map(c=>e.jsx("option",{value:c,children:z(c)},c))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.subject")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:T.subject,onChange:c=>M(N=>N?{...N,subject:c.target.value}:null),placeholder:t("emailTemplates.edit.subjectPlaceholder"),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.htmlBody")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx(ye,{content:T.htmlBody,onChange:c=>M(N=>N?{...N,htmlBody:c}:null),placeholder:t("emailTemplates.edit.htmlBodyPlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.edit.textBody")}),e.jsx("textarea",{value:T.textBody,onChange:c=>M(N=>N?{...N,textBody:c.target.value}:null),rows:4,placeholder:t("emailTemplates.edit.textBodyPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.textBodyHelp")})]})]}),W&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.availableVariables")})]}),e.jsxs("div",{className:"p-3 space-y-3 max-h-[300px] overflow-auto",children:[x.custom.length>0&&e.jsx(X,{title:t("emailTemplates.detail.customVariables"),variables:x.custom,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(X,{title:t("emailTemplates.detail.userVariables"),variables:x.user,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(X,{title:t("emailTemplates.detail.emailVariables"),variables:x.email,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Eye,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.livePreview")})]}),e.jsx("button",{onClick:()=>E(!0),className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",title:t("emailTemplates.edit.fullscreen"),children:e.jsx(a.Maximize2,{className:"w-4 h-4 text-[var(--text-tertiary)]"})})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]/50",children:[e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:t("emailTemplates.edit.subject")}),e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:T.subject?Z(T.subject):e.jsx("span",{className:"text-[var(--text-tertiary)] italic",children:t("emailTemplates.edit.subjectPlaceholder")})})]}),e.jsx("div",{className:"flex-1 bg-white min-h-[300px]",children:T.htmlBody?e.jsx("iframe",{srcDoc:`<!DOCTYPE html>
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=require("react-router-dom"),O=require("react-i18next"),a=require("lucide-react"),w=require("./index-IgLVXPg8.js"),ee=require("@tiptap/react"),se=require("@tiptap/starter-kit"),re=require("@tiptap/extension-link"),ie=require("@tiptap/extension-image"),le=require("@tiptap/extension-placeholder"),ne=require("@tiptap/extension-text-align"),oe=require("@tiptap/extension-underline"),ce=require("@tiptap/extension-text-style"),de=require("@tiptap/extension-color"),me=require("@tiptap/extension-highlight"),xe=require("@monaco-editor/react"),B={emailTemplates:{getAll:t=>w.api.get("/api/administration/workflows/email-templates",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/email-templates/${t}`),getByCode:t=>w.api.get(`/api/administration/workflows/email-templates/by-code/${t}`),create:t=>w.api.post("/api/administration/workflows/email-templates",t),update:(t,s)=>w.api.put(`/api/administration/workflows/email-templates/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/email-templates/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/deactivate`),preview:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/preview`,s),testSend:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/test-send`,s),getTranslation:(t,s)=>w.api.get(`/api/administration/workflows/email-templates/${t}/translations/${s}`),createTranslation:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/translations`,s),updateTranslation:(t,s,p)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,p)},workflows:{getAll:t=>w.api.get("/api/administration/workflows/definitions",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/definitions/${t}`),create:t=>w.api.post("/api/administration/workflows/definitions",t),update:(t,s)=>w.api.put(`/api/administration/workflows/definitions/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/definitions/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/deactivate`),addStep:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps`,s),updateStep:(t,s,p)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,p),deleteStep:(t,s)=>w.api.delete(`/api/administration/workflows/definitions/${t}/steps/${s}`),reorderSteps:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps/reorder`,{stepOrder:s})},triggers:{getAll:()=>w.api.get("/api/administration/workflows/definitions/triggers")}};function pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const x=await B.emailTemplates.getAll({search:v||void 0});g(Array.isArray(x)?x:[])}catch(x){console.error("Failed to load templates:",x)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=x=>{x.preventDefault(),A(1),f()},C=async(x,V)=>{if(V?.stopPropagation(),x.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:x.name})))try{await B.emailTemplates.delete(x.id),f()}catch(K){console.error("Failed to delete template:",K)}},_=(F-1)*h,T=r.slice(_,_+h),M=Math.ceil(r.length/h),P={transactional:r.filter(x=>x.category==="transactional"),notification:r.filter(x=>x.category==="notification"),marketing:r.filter(x=>x.category==="marketing"),system:r.filter(x=>x.category==="system")},b=x=>t(`emailTemplates.categories.${x.toLowerCase()}`)||x,S=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.code")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("emailTemplates.columns.category")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("emailTemplates.columns.translations")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]})})}),!u&&T.length>0&&T.map(x=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:V=>V.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("code",{className:"text-sm bg-[var(--bg-secondary)] px-2 py-0.5 rounded text-[var(--text-primary)]",children:x.code})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:x.name}),x.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:b(x.category)})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:x.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:x.isActive?"active":"inactive",label:x.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("emailTemplates.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:V=>{V.stopPropagation(),s(`/administration/workflows/email-templates/${x.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("emailTemplates.edit.title"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!x.isSystem&&e.jsx("button",{onClick:V=>C(x,V),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("emailTemplates.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},x.id))]})]})}),$=()=>u?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):T.length===0?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--color-accent-50)] flex items-center justify-center mb-3",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]}):T.map(x=>e.jsx(w.TemplateCard,{name:x.name,code:x.code,category:b(x.category),isActive:x.isActive,isSystem:x.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:x.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${x.id}/edit`),onDelete:()=>C(x),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},x.id)),W=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:$()}),L=x=>x==="transactional"?"bg-[var(--success-dot)]":x==="notification"?"bg-[var(--warning-dot)]":x==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",o=x=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-accent-500)] flex items-center justify-center shadow-lg",children:e.jsx(a.Mail,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:x.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:x.code})]})]})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${x.isActive?"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 ${x.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),x.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")]}),e.jsxs("div",{className:"flex items-center gap-1 text-[var(--text-tertiary)]",children:[e.jsx(a.Languages,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:x.languages.length})]})]})})]},x.id),E=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsx(e.Fragment,{children:Object.entries(P).map(([x,V])=>e.jsxs("div",{className:"min-w-[280px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${L(x)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(x)}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:V.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[V.map(o),V.length===0&&e.jsxs("div",{className:"border-2 border-dashed border-[var(--color-accent-200)] rounded-lg p-6 text-center",children:[e.jsx(a.Mail,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("emailTemplates.noResults")})]})]})]},x))})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates")}]}),e.jsx(w.PageHeader,{title:t("emailTemplates.title"),subtitle:`${r.length} templates`,icon:e.jsx(a.Mail,{className:"w-6 h-6"}),actions:e.jsxs("button",{onClick:()=>s("/administration/workflows/email-templates/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.create")]})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:d,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:x=>m(x.target.value),placeholder:t("emailTemplates.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&W(),n==="kanban"&&E(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:M,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"templates"})]})}function ue(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async m=>{m.preventDefault(),i(!0),g(null);try{const n=await B.emailTemplates.create({code:u.code,name:u.name,description:u.description||void 0,category:u.category});s(`/administration/email-templates/${n.id}`)}catch(n){const D=n instanceof Error?n.message:"An error occurred while creating the template";g(D)}finally{i(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:t("emailTemplates.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/email-templates/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("emailTemplates.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-violet-500 to-purple-500 flex items-center justify-center shadow-lg shadow-primary-500/20",children:e.jsx(a.Mail,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("emailTemplates.description")})]})]})]}),e.jsxs("form",{onSubmit:v,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.code,onChange:m=>k(n=>({...n,code:m.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., welcome-email",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("emailTemplates.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.name,onChange:m=>k(n=>({...n,name:m.target.value})),placeholder:"e.g., Welcome Email",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:u.description,onChange:m=>k(n=>({...n,description:m.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.category")}),e.jsxs("select",{value:u.category,onChange:m=>k(n=>({...n,category:m.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/email-templates/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:p,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const ve=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],he=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}];function be(){const{t,i18n:s}=O.useTranslation("communications"),{id:p}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,m]=U.useSearchParams(),n=v.get("tab")||"preview",D=y=>m({tab:y}),[F,A]=l.useState(null),[h,f]=l.useState(null),[d,C]=l.useState(!1),[_,T]=l.useState(!1),[M,P]=l.useState(null),[b,S]=l.useState(null),[$,W]=l.useState(!1),[L,o]=l.useState(""),E=l.useCallback(async()=>{if(p)try{k(!0),A(null);const y=await B.emailTemplates.getById(p);g(y)}catch(y){console.error("Failed to load template:",y),A(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[p,t]);l.useEffect(()=>{E()},[E]);const x=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),E()}catch(y){console.error("Failed to activate template:",y),A(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),E()}catch(y){console.error("Failed to deactivate template:",y),A(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},K=async()=>{if(!(!p||!r)){if(r.isSystem){A(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),A(null),await B.emailTemplates.delete(p),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),A(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Y=async y=>{if(p)try{W(!0),P(y);const c=await B.emailTemplates.preview(p,{languageCode:y});S({subject:c.subject,htmlBody:c.htmlBody})}catch(c){console.error("Failed to preview template:",c),A(t("emailTemplates.detail.errors.previewFailed"))}finally{W(!1)}},G=()=>{P(null),S(null)},J=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const c=JSON.parse(r.variablesJson);Array.isArray(c)?y=c.filter(N=>N?.name):typeof c=="object"&&(y=Object.entries(c).filter(([N])=>N&&N!=="undefined").map(([N,I])=>({name:N,description:typeof I=="object"&&I!==null?I.description:void 0,type:typeof I=="object"&&I!==null?I.type:void 0,required:typeof I=="object"&&I!==null?I.required:!1})))}catch{}return{user:ve,email:he,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],c=r.translations.find(N=>N.languageCode===y);o(c?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!L?null:r.translations.find(y=>y.languageCode===L)||null,[r?.translations,L]),q=[{id:"preview",label:t("emailTemplates.detail.tabs.preview"),icon:e.jsx(a.Eye,{className:"w-4 h-4"})},{id:"info",label:t("emailTemplates.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.detail.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],z=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,R=y=>t(`languages.${y}`,{defaultValue:y.toUpperCase()});return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:r?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:r.name}),r.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.detail.system")}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${r.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:r.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})]}),r.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:r.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.edit.title")})]}),e.jsxs("button",{onClick:r.isActive?V:x,disabled:d,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${r.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[d&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!d&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!d&&!r.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:r.isActive?t("emailTemplates.deactivate"):t("emailTemplates.activate")})]}),e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.delete")})]})]})]}),F&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),F]}),h&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),h]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(y=>e.jsxs("button",{onClick:()=>D(y.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${n===y.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[y.icon,e.jsx("span",{className:"hidden sm:inline",children:y.label}),y.id==="translations"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${n===y.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:r.translations.length})]},y.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[n==="preview"&&e.jsxs("div",{className:"space-y-6",children:[r.translations.length>0?e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:[t("emailTemplates.detail.previewLanguage",{defaultValue:"Langue"}),":"]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-tertiary)] rounded-[var(--radius-button)]",children:r.translations.map(y=>e.jsx("button",{onClick:()=>o(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${L===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:R(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),t("emailTemplates.edit.title")]})]}):e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(a.Mail,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"mb-4",children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}),j&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.subject")})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("p",{className:"text-[var(--text-primary)] font-medium",children:j.subject})})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.emailBody",{defaultValue:"Contenu de l'email"})})]}),e.jsxs("button",{onClick:()=>Y(j.languageCode),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Eye,{className:"w-3 h-3"}),t("emailTemplates.detail.fullPreview",{defaultValue:"Plein ecran"})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx("iframe",{srcDoc:j.htmlBody,className:"w-full min-h-[400px] border-0",title:"Email Preview",sandbox:"allow-same-origin"})})]}),j.textBody&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.textVersion",{defaultValue:"Version texte"})})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-[var(--text-secondary)] font-mono",children:j.textBody})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.variables")})]}),e.jsxs("div",{className:"p-4 space-y-4 max-h-[500px] overflow-y-auto",children:[J.custom.length>0&&e.jsx(Q,{title:t("emailTemplates.detail.customVariables"),variables:J.custom,t,defaultExpanded:!0}),e.jsx(Q,{title:t("emailTemplates.detail.userVariables"),variables:J.user,t,defaultExpanded:!1}),e.jsx(Q,{title:t("emailTemplates.detail.emailVariables"),variables:J.email,t,defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Settings,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.quickInfo")})]}),e.jsxs("div",{className:"p-4 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.code")}),e.jsx("code",{className:"px-2 py-0.5 bg-[var(--bg-tertiary)] rounded text-[var(--text-primary)] text-xs",children:r.code})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.category")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:z(r.category)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.columns.translations")}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:[r.translations.length,"/4"]})]})]})]})]})]})]}),n==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:r.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:r.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.category")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:z(r.category)})]}),r.applicationId&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.application")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.applicationId})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.createdAt).toLocaleString()})]}),r.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.updatedAt).toLocaleString()})]})]})]})]})}),n==="translations"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.translationsTitle")," (",r.translations.length,")"]}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addTranslation")]})]}),r.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${p}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}):e.jsx("div",{className:"space-y-3",children:r.translations.map(y=>e.jsx(ge,{translation:y,templateId:p,onPreview:()=>Y(y.languageCode),t,getLanguageLabel:R},y.id))})]})]}),_&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("emailTemplates.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("emailTemplates.confirmDelete",{name:r.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:K,disabled:d,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[d?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),M&&b&&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-card)] border border-[var(--border-color)] p-6 max-w-4xl w-full max-h-[90vh] overflow-hidden shadow-xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.preview")," - ",R(M)]}),e.jsxs("button",{onClick:G,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("span",{className:"sr-only",children:"Close"}),"×"]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.subject")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:b.subject})]}),e.jsx("div",{className:"flex-1 overflow-auto border border-[var(--border-color)] rounded-[var(--radius-card)] bg-white",children:e.jsx("iframe",{srcDoc:b.htmlBody,className:"w-full h-full min-h-[400px]",title:"Email Preview"})})]})}),$&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-white"})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]})}function ge({translation:t,templateId:s,onPreview:p,t:i,getLanguageLabel:r}){const g=U.useNavigate(),[u,k]=l.useState(!1);return e.jsxs("div",{className:"rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors overflow-hidden",children:[e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:t.languageCode})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:r(t.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:t.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>k(!u),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[u?e.jsx(a.ChevronUp,{className:"w-4 h-4"}):e.jsx(a.ChevronDown,{className:"w-4 h-4"}),u?i("emailTemplates.detail.collapse",{defaultValue:"Reduire"}):i("emailTemplates.detail.expand",{defaultValue:"Voir le contenu"})]}),e.jsxs("button",{onClick:p,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(a.Eye,{className:"w-4 h-4"}),i("emailTemplates.detail.preview")]}),e.jsxs("button",{onClick:()=>g(`/administration/workflows/email-templates/${s}/edit`),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),i("emailTemplates.edit.title")]})]})]})}),u&&e.jsx("div",{className:"border-t border-[var(--border-color)]",children:e.jsx("div",{className:"bg-white max-h-[300px] overflow-auto",children:e.jsx("iframe",{srcDoc:t.htmlBody,className:"w-full min-h-[200px] border-0",title:`Email Preview - ${t.languageCode}`,sandbox:"allow-same-origin"})})})]})}function Q({title:t,variables:s,t:p,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-3 py-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 space-y-1",children:s.map(u=>e.jsx(fe,{variable:u,t:p},u.name))})]})}function fe({variable:t,t:s}){const[p,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)};return e.jsxs("div",{className:"group flex items-center justify-between p-2 rounded hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono text-[var(--color-accent-600)]",children:r}),t.required&&e.jsx("span",{className:"text-xs text-[var(--error-text)]",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:t.description})]}),e.jsx("button",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-[var(--bg-hover)] transition-all",title:s("emailTemplates.detail.copyVariable",{defaultValue:"Copier"}),children:p?e.jsx(a.Check,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(a.Copy,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})}function ye({content:t,onChange:s,placeholder:p,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,m]=l.useState(""),[n,D]=l.useState(!1),[F,A]=l.useState(""),[h,f]=l.useState(!1),d=ee.useEditor({extensions:[se.configure({heading:{levels:[1,2,3]}}),re.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ie.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),le.configure({placeholder:p||"Commencez a ecrire votre email..."}),ne.configure({types:["heading","paragraph"]}),oe,ce.TextStyle,de.Color,me.configure({multicolor:!0})],content:t,onUpdate:({editor:L})=>{const o=L.getHTML();s(o),k(o)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&d&&u!==d.getHTML()&&d.commands.setContent(u)},[r,d,u]),l.useEffect(()=>{d&&k(d.getHTML())},[d?.getHTML()]);const C=l.useCallback(L=>{const o=L||"";k(o),s(o)},[s]),_=l.useCallback(()=>{d&&d.commands.setContent(u),g("visual")},[d,u]),T=l.useCallback(()=>{d&&k(d.getHTML()),g("code")},[d]),M=l.useCallback(()=>{v&&d&&(d.chain().focus().extendMarkRange("link").setLink({href:v}).run(),m(""),D(!1))},[d,v]),P=l.useCallback(()=>{d&&(d.chain().focus().unsetLink().run(),D(!1))},[d]),b=l.useCallback(()=>{F&&d&&(d.chain().focus().setImage({src:F}).run(),A(""),f(!1))},[d,F]),S=l.useCallback(L=>{if(d){const o=`{{ ${L} }}`;d.chain().focus().insertContent(`<span class="variable-tag" data-variable="${L}">${o}</span>`).run()}},[d]);if(l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),!d)return e.jsx("div",{className:"flex items-center justify-center h-64 bg-[var(--bg-secondary)] rounded-lg",children:e.jsx("div",{className:"animate-pulse text-[var(--text-tertiary)]",children:"Chargement de l'editeur..."})});const $=({onClick:L,isActive:o=!1,disabled:E=!1,title:x,children:V})=>e.jsx("button",{type:"button",onClick:L,disabled:E,title:x,className:`p-1.5 rounded transition-colors ${o?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"hover:bg-[var(--bg-hover)] text-[var(--text-secondary)]"} ${E?"opacity-50 cursor-not-allowed":""}`,children:V}),W=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});return e.jsxs("div",{className:`border border-[var(--border-color)] rounded-lg overflow-hidden bg-[var(--bg-primary)] ${i||""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]",children:[e.jsxs("div",{className:"flex items-center gap-1 mr-2",children:[e.jsxs("button",{type:"button",onClick:_,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="visual"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Eye,{className:"w-3 h-3"}),"Visuel"]}),e.jsxs("button",{type:"button",onClick:T,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="code"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Code,{className:"w-3 h-3"}),"Code"]})]}),r==="visual"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().undo().run(),disabled:!d.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().redo().run(),disabled:!d.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),isActive:d.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),isActive:d.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:3}).run(),isActive:d.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBold().run(),isActive:d.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleItalic().run(),isActive:d.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleUnderline().run(),isActive:d.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleStrike().run(),isActive:d.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("left").run(),isActive:d.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("center").run(),isActive:d.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("right").run(),isActive:d.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBulletList().run(),isActive:d.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleOrderedList().run(),isActive:d.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBlockquote().run(),isActive:d.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>D(!n),isActive:d.isActive("link")||n,title:"Lien",children:e.jsx(a.Link,{className:"w-4 h-4"})}),n&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:v,onChange:L=>m(L.target.value),placeholder:"https://...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:L=>L.key==="Enter"&&M()}),e.jsx("button",{type:"button",onClick:M,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),d.isActive("link")&&e.jsx("button",{type:"button",onClick:P,className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>f(!h),isActive:h,title:"Image",children:e.jsx(a.Image,{className:"w-4 h-4"})}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:F,onChange:L=>A(L.target.value),placeholder:"URL de l'image...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:L=>L.key==="Enter"&&b()}),e.jsx("button",{type:"button",onClick:b,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>f(!1),className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsx($,{onClick:()=>{d.chain().focus().insertContent('<img src="{{ company_logo_url }}" alt="Logo" style="max-width: 200px; height: auto;" />').run()},title:"Inserer le logo",children:e.jsx("span",{className:"text-xs font-medium",children:"Logo"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{onClick:()=>{},title:"Couleur du texte",children:e.jsx(a.Palette,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#000000","#374151","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"].map(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().setColor(L).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{onClick:()=>{},title:"Surligner",children:e.jsx(a.Highlighter,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#fef08a","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8"].map(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().toggleHighlight({color:L}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ee.EditorContent,{editor:d,className:"[&_.ProseMirror]:min-h-[400px] [&_.ProseMirror]:p-4 [&_.ProseMirror]:focus:outline-none [&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:text-[var(--text-tertiary)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left [&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0 [&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"}):e.jsx(xe,{height:"400px",language:"html",theme:"vs-dark",value:u,onChange:C,options:{minimap:{enabled:!1},fontSize:13,wordWrap:"on",formatOnPaste:!0,automaticLayout:!0,scrollBeyondLastLine:!1,lineNumbers:"on",tabSize:2,folding:!0,renderWhitespace:"selection"}})})]})}const je=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],we=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}],te=["fr","en","de","it"],Ne={userName:"Jean Dupont",firstName:"Jean",lastName:"Dupont",displayName:"Jean Dupont",email:"jean.dupont@example.com",user_email:"jean.dupont@example.com",userEmail:"jean.dupont@example.com",phoneNumber:"+41 21 123 45 67",phone:"+41 21 123 45 67",mobilePhone:"+41 79 123 45 67",mobile:"+41 79 123 45 67",city:"Lausanne",country:"Suisse",streetAddress:"Rue du Lac 15",address:"Rue du Lac 15, 1003 Lausanne",postalCode:"1003",zipCode:"1003",company:"SmartStack SA",companyName:"SmartStack SA",company_name:"SmartStack SA",organization:"SmartStack SA",department:"Informatique",jobTitle:"Developpeur Senior",job_title:"Developpeur Senior",position:"Developpeur Senior",office:"Lausanne HQ",employeeId:"EMP-001234",employee_id:"EMP-001234",managerName:"Marie Martin",manager:"Marie Martin",manager_name:"Marie Martin",company_logo_url:"https://example.com/logo.png",logo_url:"https://example.com/logo.png",logoUrl:"https://example.com/logo.png",appName:"SmartStack",app_name:"SmartStack",applicationName:"SmartStack",siteName:"SmartStack",site_name:"SmartStack",resetUrl:"https://app.smartstack.ch/reset-password?token=abc123",reset_url:"https://app.smartstack.ch/reset-password?token=abc123",resetLink:"https://app.smartstack.ch/reset-password?token=abc123",reset_link:"https://app.smartstack.ch/reset-password?token=abc123",confirmUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirm_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmationUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmation_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmLink:"https://app.smartstack.ch/confirm-email?token=xyz789",activationUrl:"https://app.smartstack.ch/activate?token=xyz789",activation_url:"https://app.smartstack.ch/activate?token=xyz789",activationLink:"https://app.smartstack.ch/activate?token=xyz789",loginUrl:"https://app.smartstack.ch/login",login_url:"https://app.smartstack.ch/login",loginLink:"https://app.smartstack.ch/login",dashboardUrl:"https://app.smartstack.ch/dashboard",dashboard_url:"https://app.smartstack.ch/dashboard",profileUrl:"https://app.smartstack.ch/profile",profile_url:"https://app.smartstack.ch/profile",unsubscribeUrl:"https://app.smartstack.ch/unsubscribe?token=abc",unsubscribe_url:"https://app.smartstack.ch/unsubscribe?token=abc",adminName:"Admin Systeme",admin_name:"Admin Systeme",adminEmail:"admin@smartstack.ch",admin_email:"admin@smartstack.ch",supportEmail:"support@atlashub.ch",support_email:"support@atlashub.ch",supportPhone:"+41 21 123 00 00",support_phone:"+41 21 123 00 00",expiresIn:"24 heures",expires_in:"24 heures",expirationTime:"24 heures",expiration_time:"24 heures",expiryDate:"16 janvier 2026",expiry_date:"16 janvier 2026",currentDate:new Date().toLocaleDateString("fr-CH"),current_date:new Date().toLocaleDateString("fr-CH"),date:new Date().toLocaleDateString("fr-CH"),today:new Date().toLocaleDateString("fr-CH"),currentYear:new Date().getFullYear().toString(),current_year:new Date().getFullYear().toString(),year:new Date().getFullYear().toString(),currentTime:new Date().toLocaleTimeString("fr-CH"),current_time:new Date().toLocaleTimeString("fr-CH"),time:new Date().toLocaleTimeString("fr-CH"),temporaryPassword:"TempPass123!",temporary_password:"TempPass123!",tempPassword:"TempPass123!",temp_password:"TempPass123!",newPassword:"NewPass456!",new_password:"NewPass456!",password:"********",token:"abc123xyz789",verificationCode:"123456",verification_code:"123456",code:"123456",otp:"123456",ticketId:"TKT-2026-00123",ticket_id:"TKT-2026-00123",ticketNumber:"TKT-2026-00123",ticket_number:"TKT-2026-00123",ticketSubject:"Question technique",ticket_subject:"Question technique",ticketStatus:"En cours",ticket_status:"En cours",orderId:"ORD-2026-00456",order_id:"ORD-2026-00456",orderNumber:"ORD-2026-00456",order_number:"ORD-2026-00456",invoiceId:"INV-2026-00789",invoice_id:"INV-2026-00789",invoiceNumber:"INV-2026-00789",invoice_number:"INV-2026-00789",amount:"CHF 150.00",total:"CHF 150.00",price:"CHF 150.00",reason:"Mise a jour de securite",message:"Votre demande a ete traitee avec succes.",description:"Description de l'element",title:"Titre de l'element",name:"Nom de l'element",value:"Valeur exemple",count:"5",number:"42",id:"12345"};function ke(t){const s=t.toLowerCase();return s.includes("url")||s.includes("link")?"https://app.smartstack.ch/example":s.includes("email")||s.includes("mail")?"exemple@smartstack.ch":s.includes("phone")||s.includes("tel")||s.includes("mobile")?"+41 21 123 45 67":s.includes("date")||s.includes("time")||s.includes("at")?new Date().toLocaleDateString("fr-CH"):s.includes("year")?new Date().getFullYear().toString():s.includes("name")||s.includes("nom")?"Jean Dupont":s.includes("password")||s.includes("pwd")||s.includes("pass")?"MotDePasse123!":s.includes("code")||s.includes("token")||s.includes("otp")?"123456":s.includes("id")||s.includes("number")||s.includes("num")?"12345":s.includes("amount")||s.includes("price")||s.includes("total")||s.includes("cost")?"CHF 100.00":s.includes("count")||s.includes("qty")||s.includes("quantity")?"5":`[${t.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase()}]`}function Z(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(p,i)=>Ne[i]||ke(i)),s=s.replace(/\{%\s*if\s+\w+\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/gi,"$1"),s=s.replace(/\{%\s*else\s*%\}[\s\S]*?(?=\{%|\$)/gi,""),s=s.replace(/\{%[^%]*%\}/g,""),s}function Te(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=U.useSearchParams(),D=m.get("tab")||"info",F=c=>n({tab:c}),[A,h]=l.useState(null),[f,d]=l.useState(null),[C,_]=l.useState({name:"",description:"",category:""}),[T,M]=l.useState(null),[P,b]=l.useState(!1),[S,$]=l.useState(!1),[W,L]=l.useState(!0),[o,E]=l.useState(!1),x=l.useMemo(()=>{let c=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?c=N.filter(I=>I?.name):typeof N=="object"&&(c=Object.entries(N).filter(([I])=>I&&I!=="undefined").map(([I,H])=>({name:I,description:typeof H=="object"&&H!==null?H.description:void 0,type:typeof H=="object"&&H!==null?H.type:void 0,required:typeof H=="object"&&H!==null?H.required:!1})))}catch{}return{user:je,email:we,custom:c}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const c=await B.emailTemplates.getById(s);r(c),_({name:c.name,description:c.description||"",category:c.category})}catch(c){console.error("Failed to load template:",c),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const K=async c=>{if(c.preventDefault(),!(!s||!i))try{v(!0),h(null),await B.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),d(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Y=()=>{const c=i?.translations.map(I=>I.languageCode)||[],N=te.filter(I=>!c.includes(I));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}M({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},G=c=>{M({languageCode:c.languageCode,subject:c.subject,htmlBody:c.htmlBody,textBody:c.textBody||""}),b(!1)},J=async()=>{if(!(!s||!T))try{$(!0),h(null),P?(await B.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationAdded"))):(await B.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationUpdated"))),M(null),V()}catch(c){console.error("Failed to save translation:",c),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{$(!1)}},j=async c=>{if(s&&!(!c||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{$(!0),h(null),h("Delete translation API not implemented yet")}catch(N){console.error("Failed to delete translation:",N),h(t("emailTemplates.edit.errors.translationDeleteFailed"))}finally{$(!1)}},q=[{id:"info",label:t("emailTemplates.edit.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.edit.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],z=c=>t(`languages.${c}`,{defaultValue:c.toUpperCase()});if(g)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(!i)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>p("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]});const R=i.translations.map(c=>c.languageCode),y=te.filter(c=>!R.includes(c));return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>p(`/administration/workflows/email-templates/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.edit.title")}),i.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.edit.systemTemplate")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),A&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),A]}),f&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),f]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(c=>e.jsxs("button",{onClick:()=>F(c.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${D===c.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[c.icon,e.jsx("span",{className:"hidden sm:inline",children:c.label})]},c.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[D==="info"&&e.jsxs("form",{onSubmit:K,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:C.name,onChange:c=>_(N=>({...N,name:c.target.value})),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:C.description,onChange:c=>_(N=>({...N,description:c.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.category")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsxs("select",{required:!0,value:C.category,onChange:c=>_(N=>({...N,category:c.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:()=>p(`/administration/workflows/email-templates/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),D==="translations"&&!T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.edit.tabs.translations")," (",i.translations.length,"/4)"]}),y.length>0&&e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.edit.addTranslation")]})]}),i.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")})]}):e.jsx("div",{className:"space-y-3",children:i.translations.map(c=>e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:c.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:z(c.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:c.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>G(c),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Settings,{className:"w-4 h-4"}),t("emailTemplates.edit.editTranslation")]}),e.jsx("button",{onClick:()=>j(c.languageCode),disabled:S,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})},c.id))})]}),D==="translations"&&T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t(P?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>L(!W),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${W?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Columns,{className:"w-4 h-4"}),t("emailTemplates.edit.showPreview")]}),e.jsx("button",{onClick:()=>M(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${W?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[P&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.language")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("select",{value:T.languageCode,onChange:c=>M(N=>N?{...N,languageCode:c.target.value}:null),className:"input w-full max-w-xs",children:y.map(c=>e.jsx("option",{value:c,children:z(c)},c))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.subject")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:T.subject,onChange:c=>M(N=>N?{...N,subject:c.target.value}:null),placeholder:t("emailTemplates.edit.subjectPlaceholder"),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.htmlBody")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx(ye,{content:T.htmlBody,onChange:c=>M(N=>N?{...N,htmlBody:c}:null),placeholder:t("emailTemplates.edit.htmlBodyPlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.edit.textBody")}),e.jsx("textarea",{value:T.textBody,onChange:c=>M(N=>N?{...N,textBody:c.target.value}:null),rows:4,placeholder:t("emailTemplates.edit.textBodyPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.textBodyHelp")})]})]}),W&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.availableVariables")})]}),e.jsxs("div",{className:"p-3 space-y-3 max-h-[300px] overflow-auto",children:[x.custom.length>0&&e.jsx(X,{title:t("emailTemplates.detail.customVariables"),variables:x.custom,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(X,{title:t("emailTemplates.detail.userVariables"),variables:x.user,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(X,{title:t("emailTemplates.detail.emailVariables"),variables:x.email,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Eye,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.livePreview")})]}),e.jsx("button",{onClick:()=>E(!0),className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",title:t("emailTemplates.edit.fullscreen"),children:e.jsx(a.Maximize2,{className:"w-4 h-4 text-[var(--text-tertiary)]"})})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]/50",children:[e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:t("emailTemplates.edit.subject")}),e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:T.subject?Z(T.subject):e.jsx("span",{className:"text-[var(--text-tertiary)] italic",children:t("emailTemplates.edit.subjectPlaceholder")})})]}),e.jsx("div",{className:"flex-1 bg-white min-h-[300px]",children:T.htmlBody?e.jsx("iframe",{srcDoc:`<!DOCTYPE html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
@@ -101,4 +101,4 @@
|
|
|
101
101
|
</head>
|
|
102
102
|
<body>${Z(T.htmlBody)}</body>
|
|
103
103
|
</html>`,className:"w-full h-full min-h-[500px] border-0",title:"Email Preview Fullscreen",sandbox:"allow-same-origin"})})]})})]})]})}function X({title:t,variables:s,onInsert:p,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-2 py-1.5 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:s.map(u=>e.jsx(Ce,{variable:u,onInsert:p},u.name))})]})}function Ce({variable:t,onInsert:s}){const[p,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{s(t.name),i(!0),setTimeout(()=>i(!1),1e3)};return e.jsxs("button",{onClick:g,className:"group inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] hover:bg-[var(--color-accent-100)] dark:hover:bg-[var(--color-accent-900)] transition-colors text-xs",title:t.description||`Inserer ${r}`,children:[e.jsx("code",{className:"font-mono text-[var(--color-accent-600)]",children:t.name}),p&&e.jsx(a.Check,{className:"w-2.5 h-2.5 text-[var(--success-text)]"})]})}function Se(){const{t}=O.useTranslation("communications");return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.smsTemplates","SMS Templates")}]}),e.jsx(w.PageHeader,{title:t("smsTemplates.title","SMS Templates"),subtitle:t("smsTemplates.subtitle","Manage SMS notification templates"),icon:e.jsx(a.MessageSquare,{className:"w-6 h-6"})}),e.jsx("div",{className:"card",children:e.jsx(w.UnderDevelopment,{title:t("smsTemplates.underDevelopment.title","SMS Templates"),description:t("smsTemplates.underDevelopment.description","SMS notification templates will be available soon. This feature will allow you to create and manage SMS templates for automated notifications."),icon:e.jsx(a.MessageSquare,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"}),showBackButton:!0,backUrl:"/administration/workflows/email-templates"})})]})}function Le(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const o=await B.workflows.getAll({search:v||void 0});g(Array.isArray(o)?o:[])}catch(o){console.error("Failed to load workflows:",o)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=o=>{o.preventDefault(),A(1),f()},C=async(o,E)=>{E.stopPropagation();try{o.isActive?await B.workflows.deactivate(o.id):await B.workflows.activate(o.id),f()}catch(x){console.error("Failed to toggle workflow:",x)}},_=async(o,E)=>{if(E.stopPropagation(),o.isSystem){alert(t("workflows.cannotDeleteSystem"));return}if(confirm(t("workflows.confirmDelete",{name:o.name})))try{await B.workflows.delete(o.id),f()}catch(x){console.error("Failed to delete workflow:",x)}},T=(F-1)*h,M=r.slice(T,T+h),P=Math.ceil(r.length/h),b=r.filter(o=>o.isActive),S=r.filter(o=>!o.isActive),$=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("workflows.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("workflows.columns.trigger")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("workflows.columns.steps")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("workflows.columns.priority")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("workflows.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&M.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Workflow,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workflows.noResults")})]})})}),!u&&M.length>0&&M.map(o=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/${o.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:E=>E.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate max-w-xs",children:o.description}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[o.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"}),i&&o.tenantName&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:o.tenantName})]})]})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Zap,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:o.triggerName})]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[o.stepCount," ",t("workflows.columns.steps").toLowerCase()]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:o.priority})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:o.isActive?"active":"inactive",label:o.isActive?t("workflows.active"):t("workflows.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:E=>E.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${o.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>C(o,E),className:`p-2 rounded-lg transition-all ${o.isActive?"text-[var(--text-tertiary)] hover:text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"text-[var(--text-tertiary)] hover:text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,title:o.isActive?t("workflows.deactivate"):t("workflows.activate"),children:o.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>{E.stopPropagation(),s(`/administration/workflows/${o.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!o.isSystem&&e.jsx("button",{onClick:E=>_(o,E),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("workflows.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},o.id))]})]})}),W=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[u&&e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}),!u&&M.length===0&&e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--bg-secondary)] flex items-center justify-center mb-3",children:e.jsx(a.Workflow,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workflows.noResults")})]}),!u&&M.length>0&&M.map(o=>e.jsxs("button",{onClick:()=>s(`/administration/workflows/${o.id}`),className:"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)] cursor-pointer flex flex-col text-left",type:"button",children:[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:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-lg",children:e.jsx(a.Workflow,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--text-primary)] truncate",children:o.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),o.triggerName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",children:"System"}),i&&o.tenantName&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",children:o.tenantName}),e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${o.isActive?"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:o.isActive?t("workflows.active"):t("workflows.inactive")})]})]})}),e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[o.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mb-3",children:o.description}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-tertiary)] mb-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-[var(--bg-secondary)]",children:[o.stepCount," ",t("workflows.columns.steps").toLowerCase()]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-[var(--bg-secondary)]",children:["P",o.priority]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1 pt-3 border-t border-[var(--border-color)]",onClick:E=>E.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${o.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("workflows.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>C(o,E),className:`p-2 rounded-lg transition-all ${o.isActive?"text-[var(--text-tertiary)] hover:text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"text-[var(--text-tertiary)] hover:text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,title:o.isActive?t("workflows.deactivate"):t("workflows.activate"),children:o.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>{E.stopPropagation(),s(`/administration/workflows/${o.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!o.isSystem&&e.jsx("button",{onClick:E=>_(o,E),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("workflows.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})]},o.id))]}),L=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-[320px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--success-dot)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t("workflows.active")}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:b.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[b.map(o=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${o.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:o.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),o.triggerName]})]})]})}),e.jsxs("div",{className:"p-3 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[o.stepCount," steps"]}),e.jsx("span",{onClick:E=>C(o,E),role:"button",tabIndex:-1,className:"text-xs px-2 py-1 rounded-md bg-[var(--warning-bg)] text-[var(--warning-text)] hover:opacity-80 transition-opacity",children:t("workflows.deactivate")})]})]},o.id)),b.length===0&&e.jsxs("div",{className:"border border-dashed border-[var(--border-color)] rounded-lg p-6 text-center",children:[e.jsx(a.Play,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("workflows.noResults")})]})]})]}),e.jsxs("div",{className:"min-w-[320px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--text-muted)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t("workflows.inactive")}),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.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[S.map(o=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${o.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer opacity-75 text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-gray-400 to-gray-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:o.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),o.triggerName]})]})]})}),e.jsxs("div",{className:"p-3 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[o.stepCount," steps"]}),e.jsx("span",{onClick:E=>C(o,E),role:"button",tabIndex:-1,className:"text-xs px-2 py-1 rounded-md bg-[var(--success-bg)] text-[var(--success-text)] hover:opacity-80 transition-opacity",children:t("workflows.activate")})]})]},o.id)),S.length===0&&e.jsxs("div",{className:"border border-dashed border-[var(--border-color)] rounded-lg p-6 text-center",children:[e.jsx(a.Pause,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("workflows.noResults")})]})]})]})]})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title")}]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.title")}),e.jsxs("p",{className:"text-sm text-[var(--text-tertiary)] mt-1",children:[r.length," workflows"]})]}),e.jsxs("button",{onClick:()=>s("/administration/workflows/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.create")]})]}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:d,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:o=>m(o.target.value),placeholder:t("workflows.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&$(),n==="cards"&&W(),n==="kanban"&&L(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:P,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"workflows"})]})}function Ae(){const{t}=O.useTranslation("communications"),[s,p]=l.useState([]),[i,r]=l.useState(!0),[g,u]=l.useState(null);l.useEffect(()=>{(async()=>{try{r(!0);const n=await B.triggers.getAll();p(Array.isArray(n)?n:[])}catch(n){console.error("Failed to load triggers:",n)}finally{r(!1)}})()},[]);const k=m=>{switch(m){case"UserEvent":return"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20";case"TicketEvent":return"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20";case"SystemEvent":return"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border-[var(--border-color)]";case"Scheduled":return"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20";default:return"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border-[var(--border-color)]"}},v=m=>{if(!m)return[];try{return JSON.parse(m)}catch{return[]}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("triggers.title")}]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("triggers.title")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-1",children:t("triggers.description")})]}),i?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("workflows.loadingTriggers")})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-3",children:[s.map(m=>{const n=v(m.availableVariablesJson);return e.jsxs("button",{type:"button",onClick:()=>u(m),className:`card p-4 cursor-pointer transition-all text-left w-full ${g?.id===m.id?"ring-2 ring-[var(--color-accent-500)] border-[var(--color-accent-500)]":"hover:border-[var(--color-accent-500)]/50"}`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-lg bg-amber-500/10",children:e.jsx(a.Zap,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:m.name}),e.jsx("code",{className:"text-sm text-[var(--text-tertiary)] bg-[var(--bg-secondary)] px-1.5 py-0.5 rounded",children:m.code})]})]}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${k(m.triggerType)}`,children:m.triggerType})]}),e.jsx("div",{className:"mt-3 flex items-center gap-4 text-sm text-[var(--text-tertiary)]",children:e.jsxs("span",{children:[n.length," ",t("triggers.variables")]})})]},m.id)}),s.length===0&&e.jsxs("div",{className:"card p-12 text-center",children:[e.jsx(a.Zap,{className:"w-12 h-12 mx-auto text-[var(--text-muted)] mb-3"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"No triggers available"})]})]}),e.jsx("div",{className:"lg:col-span-1",children:g?e.jsxs("div",{className:"card p-5 sticky top-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5 pb-4 border-b border-[var(--border-color)]",children:[e.jsx("div",{className:"p-2 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(a.Info,{className:"w-5 h-5 text-[var(--accent-text)]"})}),e.jsx("h2",{className:"font-semibold text-[var(--text-primary)]",children:t("triggers.details")})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.name")}),e.jsx("p",{className:"font-medium text-[var(--text-primary)] mt-1",children:g.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.code")}),e.jsx("code",{className:"block bg-[var(--bg-secondary)] px-3 py-2 rounded-lg text-sm text-[var(--text-primary)] mt-1 font-mono",children:g.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.type")}),e.jsx("div",{className:"mt-1",children:e.jsx("span",{className:`inline-flex px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${k(g.triggerType)}`,children:g.triggerType})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.availableVariables")}),e.jsxs("div",{className:"mt-2 space-y-1.5 max-h-48 overflow-y-auto",children:[v(g.availableVariablesJson).map(m=>e.jsxs("code",{className:"flex items-center gap-2 bg-[var(--bg-secondary)] px-3 py-2 rounded-lg text-xs text-[var(--text-primary)] font-mono",children:[e.jsx("span",{className:"text-amber-500",children:"{{"}),e.jsx("span",{children:m}),e.jsx("span",{className:"text-amber-500",children:"}}"})]},m)),v(g.availableVariablesJson).length===0&&e.jsx("p",{className:"text-sm text-[var(--text-muted)] italic",children:"No variables available"})]})]})]})]}):e.jsxs("div",{className:"card p-8 text-center bg-[var(--bg-secondary)]/50",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center mx-auto mb-4",children:e.jsx(a.Info,{className:"w-8 h-8 text-[var(--text-muted)]"})}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("triggers.selectToViewDetails")})]})})]})]})}function Pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState([]),[v,m]=l.useState(!0),[n,D]=l.useState({code:"",name:"",description:"",triggerId:"",priority:0});l.useEffect(()=>{(async()=>{try{m(!0);const f=await B.triggers.getAll();k(f)}catch(f){console.error("Failed to load triggers:",f)}finally{m(!1)}})()},[]);const F=async h=>{h.preventDefault(),i(!0),g(null);try{const f=await B.workflows.create({code:n.code,name:n.name,description:n.description||void 0,triggerId:n.triggerId,priority:n.priority});s(`/administration/workflows/${f.id}`)}catch(f){const d=f instanceof Error?f.message:"An error occurred while creating the workflow";g(d)}finally{i(!1)}},A=u.find(h=>h.id===n.triggerId);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("workflows.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/workflows/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("workflows.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:e.jsx(a.Workflow,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("workflows.description")})]})]})]}),e.jsxs("form",{onSubmit:F,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:n.code,onChange:h=>D(f=>({...f,code:h.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., user-welcome-flow",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("workflows.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:n.name,onChange:h=>D(f=>({...f,name:h.target.value})),placeholder:"e.g., User Welcome Flow",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("workflows.form.description")}),e.jsx("textarea",{value:n.description,onChange:h=>D(f=>({...f,description:h.target.value})),rows:3,placeholder:t("workflows.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.trigger")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),v?e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] py-2",children:[e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),t("workflows.loadingTriggers")]}):e.jsxs("select",{required:!0,value:n.triggerId,onChange:h=>D(f=>({...f,triggerId:h.target.value})),className:"input w-full",children:[e.jsx("option",{value:"",children:t("workflows.form.selectTrigger")}),u.map(h=>e.jsxs("option",{value:h.id,children:[h.name," (",h.code,")"]},h.id))]}),A&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx(a.Zap,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{children:t("workflows.form.triggerSelected")})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)] bg-amber-500/10 text-amber-600 border border-amber-500/20",children:A.triggerType}),e.jsx("code",{className:"text-xs text-[var(--text-tertiary)]",children:A.code})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("workflows.form.priority")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("input",{type:"range",min:0,max:100,value:n.priority,onChange:h=>D(f=>({...f,priority:parseInt(h.target.value)||0})),className:"flex-1 h-2 bg-[var(--bg-secondary)] rounded-lg appearance-none cursor-pointer accent-[var(--color-accent-600)]"}),e.jsx("input",{type:"number",min:0,max:100,value:n.priority,onChange:h=>D(f=>({...f,priority:Math.min(100,Math.max(0,parseInt(h.target.value)||0))})),className:"input w-20 text-center"})]}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("workflows.form.priorityHelp")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/workflows/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:p||!n.triggerId,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const Ee={SendEmail:e.jsx(a.Mail,{className:"w-4 h-4"}),Wait:e.jsx(a.Clock,{className:"w-4 h-4"}),Condition:e.jsx(a.GitBranch,{className:"w-4 h-4"}),Webhook:e.jsx(a.Webhook,{className:"w-4 h-4"})},De={SendEmail:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",Wait:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",Condition:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",Webhook:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"};function $e(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState("info"),[m,n]=l.useState(null),[D,F]=l.useState(null),[A,h]=l.useState(!1),[f,d]=l.useState(!1),C=l.useCallback(async()=>{if(s)try{u(!0),n(null);const b=await B.workflows.getById(s);r(b)}catch(b){console.error("Failed to load workflow:",b),n(t("workflows.detail.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{C()},[C]);const _=async()=>{if(s)try{h(!0),n(null),await B.workflows.activate(s),F(t("workflows.detail.success.activated")),C()}catch(b){console.error("Failed to activate workflow:",b),n(t("workflows.detail.errors.activateFailed"))}finally{h(!1)}},T=async()=>{if(s)try{h(!0),n(null),await B.workflows.deactivate(s),F(t("workflows.detail.success.deactivated")),C()}catch(b){console.error("Failed to deactivate workflow:",b),n(t("workflows.detail.errors.deactivateFailed"))}finally{h(!1)}},M=async()=>{if(!(!s||!i)){if(i.isSystem){n(t("workflows.cannotDeleteSystem"));return}try{h(!0),n(null),await B.workflows.delete(s),p("/administration/workflows/list")}catch(b){console.error("Failed to delete workflow:",b),n(t("workflows.detail.errors.deleteFailed")),d(!1)}finally{h(!1)}}},P=[{id:"info",label:t("workflows.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"steps",label:t("workflows.detail.tabs.steps"),icon:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}];return g?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>p("/administration/workflows/list"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:i.name}),i.isSystem&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:[e.jsx(a.Lock,{className:"w-3 h-3"}),t("workflows.detail.system")]}),i.tenantName&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:i.tenantName}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${i.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:i.isActive?t("workflows.active"):t("workflows.inactive")})]}),i.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:i.description})]}),e.jsx("div",{className:"flex items-center gap-2",children:!i.isSystem&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>p(`/administration/workflows/${s}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("workflows.edit")})]}),e.jsxs("button",{onClick:i.isActive?T:_,disabled:A,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${i.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[A&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!A&&i.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!A&&!i.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:i.isActive?t("workflows.deactivate"):t("workflows.activate")})]}),e.jsxs("button",{onClick:()=>d(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("workflows.delete")})]})]})})]}),m&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),m]}),D&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),D]}),i.isSystem&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)] text-[var(--warning-text)] flex items-center gap-2",children:[e.jsx(a.Lock,{className:"w-5 h-5 flex-shrink-0"}),t("workflows.detail.systemReadOnly")]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:P.map(b=>e.jsxs("button",{onClick:()=>v(b.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${k===b.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[b.icon,e.jsx("span",{className:"hidden sm:inline",children:b.label}),b.id==="steps"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${k===b.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:i.steps.length})]},b.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[k==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:i.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:i.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.trigger")}),e.jsxs("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:[e.jsx("div",{className:"font-medium",children:i.triggerName}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] font-mono",children:i.triggerCode})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.priority")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:i.priority})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(i.createdAt).toLocaleString()})]}),i.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(i.updatedAt).toLocaleString()})]})]})]})]})}),k==="steps"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("workflows.detail.stepsTitle")," (",i.steps.length,")"]}),!i.isSystem&&e.jsxs(U.Link,{to:`/administration/workflows/${s}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.detail.addStep")]})]}),i.steps.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.ListOrdered,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("workflows.detail.noSteps")}),!i.isSystem&&e.jsxs(U.Link,{to:`/administration/workflows/${s}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.detail.addFirstStep")]})]}):e.jsx("div",{className:"space-y-3",children:i.steps.sort((b,S)=>b.stepOrder-S.stepOrder).map((b,S)=>e.jsx(Ie,{step:b,index:S,isLast:S===i.steps.length-1,t},b.id))})]})]}),f&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("workflows.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("workflows.confirmDelete",{name:i.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>d(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:M,disabled:A,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[A?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("workflows.delete")]})]})]})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("workflows.detail.notFound")}),e.jsx("button",{onClick:()=>p("/administration/workflows/list"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("workflows.backToList")})]})}function Ie({step:t,index:s,isLast:p,t:i}){const r=Ee[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),g=De[t.stepType]||"bg-gray-100 text-gray-700",u=()=>{switch(t.stepType){case"SendEmail":return t.emailTemplateName?i("workflows.detail.stepDetails.emailTemplate",{template:t.emailTemplateName}):i("workflows.detail.stepDetails.noTemplate");case"Wait":return i("workflows.detail.stepDetails.waitMinutes",{minutes:t.delayMinutes||0});case"Condition":return i("workflows.detail.stepDetails.condition");case"Webhook":if(t.configurationJson)try{return JSON.parse(t.configurationJson).url||i("workflows.detail.stepDetails.webhookConfigured")}catch{return i("workflows.detail.stepDetails.webhookConfigured")}return i("workflows.detail.stepDetails.noWebhook");default:return""}};return e.jsxs("div",{className:"relative",children:[!p&&e.jsx("div",{className:"absolute left-6 top-14 bottom-0 w-0.5 bg-[var(--border-color)]",style:{height:"calc(100% - 20px)"}}),e.jsxs("div",{className:"flex items-start gap-4 p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)]",children:s+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${g}`,children:[r,i(`workflows.stepTypes.${t.stepType}`)]})}),e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-0.5",children:u()})]})]})]})}const Me={SendEmail:e.jsx(a.Mail,{className:"w-4 h-4"}),Wait:e.jsx(a.Clock,{className:"w-4 h-4"}),Condition:e.jsx(a.GitBranch,{className:"w-4 h-4"}),Webhook:e.jsx(a.Webhook,{className:"w-4 h-4"})},Fe={SendEmail:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",Wait:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",Condition:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",Webhook:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},Be=["SendEmail","Wait","Condition","Webhook"];function _e({workflowId:t,steps:s,onStepsChange:p,readOnly:i=!1}){const{t:r}=O.useTranslation("communications"),[g,u]=l.useState(!1),[k,v]=l.useState(null),[m,n]=l.useState(null),[D,F]=l.useState(!1),[A,h]=l.useState(!1),[f,d]=l.useState(!1),[C,_]=l.useState(null),[T,M]=l.useState([]),[P,b]=l.useState(!1),[S,$]=l.useState({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""}),W=async()=>{if(!(T.length>0))try{b(!0);const j=await B.emailTemplates.getAll({isActive:!0});M(j)}catch(j){console.error("Failed to load email templates:",j)}finally{b(!1)}},L=()=>{$({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""})},o=()=>{L(),W(),F(!0)},E=j=>{_(j),W(),$({name:j.name,stepType:j.stepType,emailTemplateId:j.emailTemplateId||"",delayMinutes:j.delayMinutes||5,configurationJson:j.configurationJson||""}),h(!0)},x=j=>{_(j),d(!0)},V=async j=>{if(j.preventDefault(),!S.name||!S.stepType){v(r("workflows.steps.errors.nameRequired"));return}try{u(!0),v(null);const q={name:S.name,stepType:S.stepType,emailTemplateId:S.stepType==="SendEmail"&&S.emailTemplateId||void 0,delayMinutes:S.stepType==="Wait"?S.delayMinutes:void 0,configurationJson:["Condition","Webhook"].includes(S.stepType)&&S.configurationJson||void 0};await B.workflows.addStep(t,q),n(r("workflows.steps.success.added")),F(!1),L(),p()}catch(q){console.error("Failed to add step:",q),v(r("workflows.steps.errors.addFailed"))}finally{u(!1)}},K=async j=>{if(j.preventDefault(),!C||!S.name||!S.stepType){v(r("workflows.steps.errors.nameRequired"));return}try{u(!0),v(null);const q={name:S.name,stepOrder:C.stepOrder,isActive:C.isActive,emailTemplateId:S.stepType==="SendEmail"&&S.emailTemplateId||void 0,delayMinutes:S.stepType==="Wait"?S.delayMinutes:void 0,configurationJson:["Condition","Webhook"].includes(S.stepType)&&S.configurationJson||void 0};await B.workflows.updateStep(t,C.id,q),n(r("workflows.steps.success.updated")),h(!1),_(null),L(),p()}catch(q){console.error("Failed to update step:",q),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}},Y=async()=>{if(C)try{u(!0),v(null),await B.workflows.deleteStep(t,C.id),n(r("workflows.steps.success.deleted")),d(!1),_(null),p()}catch(j){console.error("Failed to delete step:",j),v(r("workflows.steps.errors.deleteFailed"))}finally{u(!1)}},G=async(j,q)=>{const z=[...s].sort((c,N)=>c.stepOrder-N.stepOrder),R=z.findIndex(c=>c.id===j.id),y=q==="up"?R-1:R+1;if(!(y<0||y>=z.length))try{u(!0),v(null);const c=z[y],N={name:j.name,stepOrder:c.stepOrder,isActive:j.isActive,emailTemplateId:j.emailTemplateId||void 0,delayMinutes:j.delayMinutes||void 0,configurationJson:j.configurationJson||void 0};await B.workflows.updateStep(t,j.id,N);const I={name:c.name,stepOrder:j.stepOrder,isActive:c.isActive,emailTemplateId:c.emailTemplateId||void 0,delayMinutes:c.delayMinutes||void 0,configurationJson:c.configurationJson||void 0};await B.workflows.updateStep(t,c.id,I),p()}catch(c){console.error("Failed to reorder steps:",c),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}};l.useEffect(()=>{if(m){const j=setTimeout(()=>n(null),3e3);return()=>clearTimeout(j)}},[m]),l.useEffect(()=>{if(k){const j=setTimeout(()=>v(null),5e3);return()=>clearTimeout(j)}},[k]);const J=[...s].sort((j,q)=>j.stepOrder-q.stepOrder);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[r("workflows.steps.title")," (",s.length,")"]}),!i&&e.jsxs("button",{onClick:o,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),r("workflows.steps.add")]})]}),k&&e.jsxs("div",{className:"p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2 text-sm",children:[e.jsx(a.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),k]}),m&&e.jsxs("div",{className:"p-3 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2 text-sm",children:[e.jsx(a.CheckCircle,{className:"w-4 h-4 flex-shrink-0"}),m]}),s.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.ListOrdered,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:r("workflows.steps.noSteps")}),!i&&e.jsx("p",{className:"text-sm mt-2",children:r("workflows.steps.addFirstStep")})]}):e.jsx("div",{className:"space-y-2",children:J.map((j,q)=>e.jsx(Ve,{step:j,index:q,isFirst:q===0,isLast:q===J.length-1,onEdit:()=>E(j),onDelete:()=>x(j),onMoveUp:()=>G(j,"up"),onMoveDown:()=>G(j,"down"),readOnly:i,loading:g,t:r},j.id))}),D&&e.jsx(ae,{title:r("workflows.steps.add"),formData:S,setFormData:$,emailTemplates:T,loadingTemplates:P,loading:g,onSubmit:V,onClose:()=>{F(!1),L()},t:r}),A&&C&&e.jsx(ae,{title:r("workflows.steps.edit"),formData:S,setFormData:$,emailTemplates:T,loadingTemplates:P,loading:g,onSubmit:K,onClose:()=>{h(!1),_(null),L()},t:r}),f&&C&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:r("workflows.steps.delete")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:r("workflows.steps.confirmDelete")}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>{d(!1),_(null)},className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:r("common.cancel")}),e.jsxs("button",{onClick:Y,disabled:g,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[g?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),r("workflows.steps.delete")]})]})]})})]})}function Ve({step:t,index:s,isFirst:p,isLast:i,onEdit:r,onDelete:g,onMoveUp:u,onMoveDown:k,readOnly:v,loading:m,t:n}){const D=Me[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),F=Fe[t.stepType]||"bg-gray-100 text-gray-700",A=()=>{switch(t.stepType){case"SendEmail":return t.emailTemplateName||n("workflows.detail.stepDetails.noTemplate");case"Wait":return n("workflows.detail.stepDetails.waitMinutes",{minutes:t.delayMinutes||0});case"Condition":return n("workflows.detail.stepDetails.condition");case"Webhook":if(t.configurationJson)try{return JSON.parse(t.configurationJson).url||n("workflows.detail.stepDetails.webhookConfigured")}catch{return n("workflows.detail.stepDetails.webhookConfigured")}return n("workflows.detail.stepDetails.noWebhook");default:return""}};return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)]",children:s+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-0.5",children:e.jsxs("span",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${F}`,children:[D,n(`workflows.stepTypes.${t.stepType}`)]})}),e.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate",children:t.name}),e.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:A()})]}),!v&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:u,disabled:p||m,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:n("workflows.steps.moveUp"),children:e.jsx(a.ChevronUp,{className:"w-4 h-4"})}),e.jsx("button",{onClick:k,disabled:i||m,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:n("workflows.steps.moveDown"),children:e.jsx(a.ChevronDown,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,disabled:m,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] disabled:opacity-30 transition-colors",title:n("workflows.steps.edit"),children:e.jsx(a.Edit,{className:"w-4 h-4"})}),e.jsx("button",{onClick:g,disabled:m,className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] disabled:opacity-30 transition-colors",title:n("workflows.steps.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})}function ae({title:t,formData:s,setFormData:p,emailTemplates:i,loadingTemplates:r,loading:g,onSubmit:u,onClose:k,t:v}){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-card)] border border-[var(--border-color)] w-full max-w-lg shadow-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t}),e.jsx("button",{onClick:k,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] transition-colors",children:e.jsx(a.X,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:u,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[v("workflows.steps.form.name")," *"]}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:m=>p(n=>({...n,name:m.target.value})),placeholder:v("workflows.steps.form.namePlaceholder"),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[v("workflows.steps.form.type")," *"]}),e.jsxs("select",{required:!0,value:s.stepType,onChange:m=>p(n=>({...n,stepType:m.target.value})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"",children:v("workflows.steps.form.selectType")}),Be.map(m=>e.jsx("option",{value:m,children:v(`workflows.stepTypes.${m}`)},m))]})]}),s.stepType==="SendEmail"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.emailTemplate")}),e.jsxs("select",{value:s.emailTemplateId,onChange:m=>p(n=>({...n,emailTemplateId:m.target.value})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"",children:v("workflows.steps.form.selectTemplate")}),r?e.jsx("option",{disabled:!0,children:"Loading..."}):i.map(m=>e.jsxs("option",{value:m.id,children:[m.name," (",m.code,")"]},m.id))]})]}),s.stepType==="Wait"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.delayMinutes")}),e.jsx("div",{className:"flex gap-2 mb-2",children:[{label:v("workflows.steps.form.delayPresets.5min"),value:5},{label:v("workflows.steps.form.delayPresets.15min"),value:15},{label:v("workflows.steps.form.delayPresets.1hour"),value:60},{label:v("workflows.steps.form.delayPresets.24hours"),value:1440}].map(m=>e.jsx("button",{type:"button",onClick:()=>p(n=>({...n,delayMinutes:m.value})),className:`px-2 py-1 text-xs rounded border transition-colors ${s.delayMinutes===m.value?"bg-[var(--color-accent-100)] border-[var(--color-accent-500)] text-[var(--color-accent-700)]":"border-[var(--border-color)] hover:bg-[var(--bg-hover)]"}`,children:m.label},m.value))}),e.jsx("input",{type:"number",min:1,value:s.delayMinutes,onChange:m=>p(n=>({...n,delayMinutes:parseInt(m.target.value)||1})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),s.stepType==="Condition"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.condition")}),e.jsx("textarea",{value:s.configurationJson,onChange:m=>p(n=>({...n,configurationJson:m.target.value})),rows:4,placeholder:'{"field": "value", "operator": "equals"}',className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:v("workflows.steps.form.conditionHelp")})]}),s.stepType==="Webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.webhookUrl")}),e.jsx("input",{type:"url",value:s.configurationJson?(()=>{try{return JSON.parse(s.configurationJson).url||""}catch{return""}})():"",onChange:m=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.url=m.target.value,p(D=>({...D,configurationJson:JSON.stringify(n)}))},placeholder:v("workflows.steps.form.webhookUrlPlaceholder"),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.webhookMethod")}),e.jsxs("select",{value:s.configurationJson?(()=>{try{return JSON.parse(s.configurationJson).method||"POST"}catch{return"POST"}})():"POST",onChange:m=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.method=m.target.value,p(D=>({...D,configurationJson:JSON.stringify(n)}))},className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"}),e.jsx("option",{value:"PATCH",children:"PATCH"}),e.jsx("option",{value:"GET",children:"GET"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:k,className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:v("common.cancel")}),e.jsxs("button",{type:"submit",disabled:g,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[g&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),v("common.save")]})]})]})]})})}function We(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=l.useState("info"),[D,F]=l.useState(null),[A,h]=l.useState(null),[f,d]=l.useState({name:"",description:"",priority:0}),C=l.useCallback(async()=>{if(s)try{u(!0),F(null);const P=await B.workflows.getById(s);r(P),d({name:P.name,description:P.description||"",priority:P.priority})}catch(P){console.error("Failed to load workflow:",P),F(t("workflows.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{C()},[C]);const _=async P=>{if(P.preventDefault(),!(!s||!i)){if(i.isSystem){F(t("workflows.edit.errors.cannotEditSystem"));return}v(!0),F(null),h(null);try{const b={name:f.name,description:f.description||void 0,triggerId:i.triggerId,priority:f.priority};await B.workflows.update(s,b),h(t("workflows.edit.success.saved")),C()}catch(b){F(b instanceof Error?b.message:t("workflows.edit.errors.saveFailed"))}finally{v(!1)}}},T=()=>{C()},M=[{id:"info",label:t("workflows.edit.tabs.info"),icon:e.jsx(a.Save,{className:"w-4 h-4"})},{id:"steps",label:t("workflows.edit.tabs.steps"),icon:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}];return g?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):i?i.isSystem?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>p(`/administration/workflows/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.edit.title")})]}),e.jsx("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)] text-[var(--warning-text)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(a.Lock,{className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:t("workflows.edit.systemWorkflow")}),e.jsx("p",{className:"text-sm mt-1",children:t("workflows.detail.systemReadOnly")})]})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>p(`/administration/workflows/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:[t("workflows.edit.title"),": ",i.name]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),D&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),D]}),A&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),A]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:M.map(P=>e.jsxs("button",{onClick:()=>n(P.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${m===P.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[P.icon,e.jsx("span",{className:"hidden sm:inline",children:P.label}),P.id==="steps"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${m===P.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:i.steps.length})]},P.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[m==="info"&&e.jsxs("form",{onSubmit:_,className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-secondary)] font-mono text-sm cursor-not-allowed",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("workflows.form.name")," *"]}),e.jsx("input",{type:"text",required:!0,value:f.name,onChange:P=>d(b=>({...b,name:P.target.value})),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.description")}),e.jsx("textarea",{value:f.description,onChange:P=>d(b=>({...b,description:P.target.value})),rows:3,placeholder:t("workflows.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.trigger")}),e.jsxs("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:[e.jsx("div",{className:"font-medium",children:i.triggerName}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] font-mono",children:i.triggerCode})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.edit.triggerReadOnly")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.priority")}),e.jsx("input",{type:"number",min:0,max:100,value:f.priority,onChange:P=>d(b=>({...b,priority:parseInt(P.target.value)||0})),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.form.priorityHelp")})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>p(`/administration/workflows/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),m==="steps"&&s&&e.jsx(_e,{workflowId:s,steps:i.steps,onStepsChange:T})]})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("workflows.detail.notFound")}),e.jsx("button",{onClick:()=>p("/administration/workflows/list"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("workflows.backToList")})]})}function Ue(){const{t}=O.useTranslation("communications");return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("dashboard.title","History")}]}),e.jsx(w.UnderDevelopment,{title:t("dashboard.title"),description:t("dashboard.underDevelopment","Le tableau de bord des workflows sera disponible prochainement. Il affichera les statistiques d'exécution, les graphiques de performance et l'historique des workflows."),icon:e.jsx(a.History,{className:"w-10 h-10 text-amber-600"}),showBackButton:!0,backUrl:"/administration/workflows"})]})}exports.EmailTemplateCreatePage=ue;exports.EmailTemplateDetailPage=be;exports.EmailTemplateEditPage=Te;exports.EmailTemplatesListPage=pe;exports.SmsTemplatesListPage=Se;exports.WorkflowCreatePage=Pe;exports.WorkflowDetailPage=$e;exports.WorkflowEditPage=We;exports.WorkflowHistoryPage=Ue;exports.WorkflowsListPage=Le;exports.WorkflowsTriggersPage=Ae;
|
|
104
|
-
//# sourceMappingURL=index-
|
|
104
|
+
//# sourceMappingURL=index-Buhqag3v.js.map
|