var/cache/dev/twig/e0/e06bb2e72faf9c8f24ce6a2426586a44.php line 42

Open in your IDE?
  1. <?php
  2. use Twig\Environment;
  3. use Twig\Error\LoaderError;
  4. use Twig\Error\RuntimeError;
  5. use Twig\Extension\CoreExtension;
  6. use Twig\Extension\SandboxExtension;
  7. use Twig\Markup;
  8. use Twig\Sandbox\SecurityError;
  9. use Twig\Sandbox\SecurityNotAllowedTagError;
  10. use Twig\Sandbox\SecurityNotAllowedFilterError;
  11. use Twig\Sandbox\SecurityNotAllowedFunctionError;
  12. use Twig\Source;
  13. use Twig\Template;
  14. use Twig\TemplateWrapper;
  15. /* base.html.twig */
  16. class __TwigTemplate_972cc0e8d0e71087e1039a29c600432e extends Template
  17. {
  18. private Source $source;
  19. /**
  20. * @var array<string, Template>
  21. */
  22. private array $macros = [];
  23. public function __construct(Environment $env)
  24. {
  25. parent::__construct($env);
  26. $this->source = $this->getSourceContext();
  27. $this->parent = false;
  28. $this->blocks = [
  29. 'title' => [$this, 'block_title'],
  30. 'stylesheets' => [$this, 'block_stylesheets'],
  31. 'body' => [$this, 'block_body'],
  32. 'javascripts' => [$this, 'block_javascripts'],
  33. ];
  34. }
  35. protected function doDisplay(array $context, array $blocks = []): iterable
  36. {
  37. $macros = $this->macros;
  38. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  39. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "base.html.twig"));
  40. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  41. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "base.html.twig"));
  42. // line 1
  43. yield "<!DOCTYPE html>
  44. <html lang=\"fr\">
  45. <head>
  46. <meta charset=\"UTF-8\">
  47. <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
  48. <meta name=\"description\" content=\"Journal Officiel de l'Union des Comores - Portail officiel de publication des textes juridiques et administratifs\">
  49. <meta name=\"author\" content=\"Union des Comores\">
  50. <meta name=\"theme-color\" content=\"#006633\">
  51. <title>";
  52. // line 9
  53. yield from $this->unwrap()->yieldBlock('title', $context, $blocks);
  54. yield "</title>
  55. <link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap\" rel=\"stylesheet\">
  56. <script src=\"https://cdn.tailwindcss.com\"></script>
  57. <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\">
  58. <style>
  59. * { font-family: 'Inter', sans-serif; }
  60. body { background: linear-gradient(135deg, #f5f7fa 0%, #eef2f7 100%); }
  61. ::-webkit-scrollbar { width: 10px; height: 10px; }
  62. ::-webkit-scrollbar-track { background: #f1f1f1; }
  63. ::-webkit-scrollbar-thumb { background: #006633; border-radius: 5px; }
  64. ::-webkit-scrollbar-thumb:hover { background: #004d26; }
  65. @keyframes fadeInUp {
  66. from { opacity: 0; transform: translateY(30px); }
  67. to { opacity: 1; transform: translateY(0); }
  68. }
  69. .animate-fadeInUp { animation: fadeInUp 0.6s ease-out; }
  70. .card-hover { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
  71. .card-hover:hover {
  72. transform: translateY(-4px);
  73. box-shadow: 0 20px 25px -5px rgba(0,0,0,.1),
  74. 0 10px 10px -5px rgba(0,0,0,.02);
  75. }
  76. .gradient-text {
  77. background: linear-gradient(135deg, #006633 0%, #008844 100%);
  78. -webkit-background-clip: text;
  79. -webkit-text-fill-color: transparent;
  80. background-clip: text;
  81. }
  82. .chatbot-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 1000; }
  83. .chatbot-toggle {
  84. width: 64px; height: 64px;
  85. background: linear-gradient(135deg, #006633, #008844);
  86. border-radius: 50%;
  87. display: flex; align-items: center; justify-content: center;
  88. cursor: pointer;
  89. box-shadow: 0 10px 25px -5px rgba(0,0,0,.2);
  90. transition: all 0.3s ease;
  91. }
  92. .chatbot-toggle:hover {
  93. transform: scale(1.05);
  94. box-shadow: 0 20px 25px -5px rgba(0,0,0,.3);
  95. }
  96. .chatbot-window {
  97. position: absolute; bottom: 80px; right: 0;
  98. width: 400px; height: 560px;
  99. background: white; border-radius: 1rem;
  100. box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
  101. display: none; flex-direction: column; overflow: hidden;
  102. }
  103. .chatbot-window.open { display: flex; }
  104. @media (max-width: 640px) {
  105. .chatbot-window { width: calc(100vw - 2rem); right: 0; bottom: 80px; }
  106. }
  107. .loading-spinner {
  108. border: 3px solid rgba(0,102,51,.2);
  109. border-radius: 50%;
  110. border-top: 3px solid #006633;
  111. width: 24px; height: 24px;
  112. animation: spin 1s linear infinite;
  113. }
  114. @keyframes spin {
  115. 0% { transform: rotate(0deg); }
  116. 100% { transform: rotate(360deg); }
  117. }
  118. /* Barre de progression traduction */
  119. @keyframes tlProgress {
  120. 0% { width: 0%; }
  121. 50% { width: 70%; }
  122. 100% { width: 100%; }
  123. }
  124. </style>
  125. ";
  126. // line 92
  127. yield from $this->unwrap()->yieldBlock('stylesheets', $context, $blocks);
  128. // line 93
  129. yield "</head>
  130. <body>
  131. ";
  132. // line 96
  133. yield from $this->load("components/_header.html.twig", 96)->unwrap()->yield($context);
  134. // line 97
  135. yield "
  136. <main class=\"min-h-screen\">
  137. ";
  138. // line 99
  139. yield from $this->unwrap()->yieldBlock('body', $context, $blocks);
  140. // line 100
  141. yield " </main>
  142. ";
  143. // line 102
  144. yield from $this->load("components/_footer.html.twig", 102)->unwrap()->yield($context);
  145. // line 103
  146. yield " ";
  147. yield from $this->load("components/_chatbot.html.twig", 103)->unwrap()->yield($context);
  148. // line 104
  149. yield "
  150. <!-- Alpine.js -->
  151. <script defer src=\"https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js\"></script>
  152. <script>
  153. window.App = { chatbot: null };
  154. document.addEventListener('alpine:init', () => {
  155. Alpine.data('chatbot', () => ({
  156. isOpen: false,
  157. messages: [],
  158. currentMessage: '',
  159. isLoading: false,
  160. init() {
  161. this.addMessage(
  162. \"Bonjour et bienvenue sur le Journal Officiel de l'Union des Comores. \" +
  163. \"Je suis Ibunas.IA, votre assistant juridique. Comment puis-je vous aider ?\",
  164. 'bot'
  165. );
  166. },
  167. toggle() {
  168. this.isOpen = !this.isOpen;
  169. if (this.isOpen) setTimeout(() => this.scrollToBottom(), 100);
  170. },
  171. async send() {
  172. if (!this.currentMessage.trim() || this.isLoading) return;
  173. const message = this.currentMessage;
  174. this.addMessage(message, 'user');
  175. this.currentMessage = '';
  176. this.isLoading = true;
  177. this.scrollToBottom();
  178. try {
  179. const response = await fetch('";
  180. // line 140
  181. yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("app_chatbot_send");
  182. yield "', {
  183. method: 'POST',
  184. headers: {
  185. 'Content-Type': 'application/json',
  186. 'X-Requested-With': 'XMLHttpRequest'
  187. },
  188. body: JSON.stringify({ message })
  189. });
  190. const data = await response.json();
  191. this.addMessage(data.response, 'bot');
  192. } catch (e) {
  193. this.addMessage('Désolé, une erreur technique est survenue.', 'bot');
  194. } finally {
  195. this.isLoading = false;
  196. this.scrollToBottom();
  197. }
  198. },
  199. addMessage(text, sender) {
  200. this.messages.push({
  201. id: Date.now(), text, sender, timestamp: new Date()
  202. });
  203. },
  204. scrollToBottom() {
  205. const c = document.getElementById('chatbot-messages');
  206. if (c) c.scrollTop = c.scrollHeight;
  207. }
  208. }));
  209. });
  210. </script>
  211. <!-- ── Moteur de traduction LibreTranslate ── -->
  212. <script>
  213. const Translator = {
  214. cache: {},
  215. loading: false,
  216. getNodes() {
  217. return [...document.querySelectorAll(
  218. 'h1, h2, h3, h4, p, a, span, button, label, td, th, li'
  219. )].filter(el =>
  220. [...el.childNodes].some(
  221. n => n.nodeType === 3 && n.textContent.trim().length > 2
  222. ) &&
  223. !el.closest('script, style, [data-no-translate]')
  224. );
  225. },
  226. // MyMemory — gratuit, CORS autorisé, pas de clé requise
  227. async translateText(text) {
  228. const url = 'https://api.mymemory.translated.net/get?'
  229. + new URLSearchParams({
  230. q: text,
  231. langpair: 'fr|en'
  232. });
  233. const res = await fetch(url, { method: 'GET' });
  234. const data = await res.json();
  235. if (data.responseStatus === 200) {
  236. return data.responseData.translatedText;
  237. }
  238. throw new Error('MyMemory error: ' + data.responseStatus);
  239. },
  240. async translate(lang) {
  241. if (this.loading) return;
  242. this.loading = true;
  243. this.showBar();
  244. const nodes = this.getNodes();
  245. const texts = nodes.map(el => el.innerText.trim());
  246. // Retourne le cache si déjà traduit
  247. if (this.cache[lang]) {
  248. this.apply(nodes, this.cache[lang]);
  249. this.hideBar();
  250. this.loading = false;
  251. return;
  252. }
  253. try {
  254. // MyMemory a une limite de 500 chars par requête
  255. // On traduit par petits groupes
  256. const translations = [];
  257. const chunkSize = 10; // 10 textes par lot
  258. for (let i = 0; i < texts.length; i += chunkSize) {
  259. const chunk = texts.slice(i, i + chunkSize);
  260. const sep = ' [|||] ';
  261. const combined = chunk.join(sep);
  262. // MyMemory limite à 500 chars — on tronque si nécessaire
  263. const toTranslate = combined.length > 500
  264. ? combined.substring(0, 500)
  265. : combined;
  266. const result = await this.translateText(toTranslate);
  267. const parts = result.split(sep).map(t => t.trim());
  268. // Complète si la réponse a moins d'éléments que l'envoi
  269. while (parts.length < chunk.length) {
  270. parts.push(chunk[parts.length]);
  271. }
  272. translations.push(...parts);
  273. // Pause entre les lots pour éviter le rate limit
  274. if (i + chunkSize < texts.length) {
  275. await new Promise(r => setTimeout(r, 300));
  276. }
  277. }
  278. this.cache[lang] = translations;
  279. this.apply(nodes, translations);
  280. } catch (e) {
  281. console.error('Erreur traduction:', e);
  282. this.showToast('⚠ Traduction indisponible');
  283. } finally {
  284. this.hideBar();
  285. this.loading = false;
  286. }
  287. },
  288. apply(nodes, translations) {
  289. nodes.forEach((el, i) => {
  290. if (!translations[i]) return;
  291. [...el.childNodes].forEach(n => {
  292. if (n.nodeType === 3 && n.textContent.trim().length > 2) {
  293. n.textContent = translations[i];
  294. }
  295. });
  296. });
  297. },
  298. showBar() {
  299. let bar = document.getElementById('tl-bar');
  300. if (!bar) {
  301. bar = document.createElement('div');
  302. bar.id = 'tl-bar';
  303. bar.innerHTML = `
  304. <div style=\"position:fixed;top:0;left:0;right:0;height:3px;
  305. background:#e5e7eb;z-index:9999;pointer-events:none\">
  306. <div id=\"tl-prog\"
  307. style=\"height:100%;width:0%;background:#006633;
  308. transition:width 1.5s ease;
  309. border-radius:0 2px 2px 0\">
  310. </div>
  311. </div>`;
  312. document.body.appendChild(bar);
  313. }
  314. bar.style.display = 'block';
  315. setTimeout(() => {
  316. const p = document.getElementById('tl-prog');
  317. if (p) p.style.width = '80%';
  318. }, 50);
  319. },
  320. hideBar() {
  321. const p = document.getElementById('tl-prog');
  322. if (p) {
  323. p.style.width = '100%';
  324. setTimeout(() => {
  325. const bar = document.getElementById('tl-bar');
  326. if (bar) bar.style.display = 'none';
  327. p.style.width = '0%';
  328. }, 400);
  329. }
  330. },
  331. showToast(msg) {
  332. const t = document.createElement('div');
  333. t.textContent = msg;
  334. t.style.cssText = `
  335. position: fixed; bottom: 1.5rem; left: 50%;
  336. transform: translateX(-50%);
  337. background: #fee2e2; color: #991b1b;
  338. border: 1px solid #fca5a5;
  339. padding: .6rem 1.2rem; border-radius: .75rem;
  340. font-size: .8rem; font-weight: 600; z-index: 9999;`;
  341. document.body.appendChild(t);
  342. setTimeout(() => t.remove(), 3000);
  343. }
  344. };
  345. // ── Fonctions globales du sélecteur de langue ──
  346. function toggleLangMenu() {
  347. const menu = document.getElementById('lang-menu');
  348. const chevron = document.getElementById('lang-chevron');
  349. const isOpen = !menu.classList.contains('hidden');
  350. menu.classList.toggle('hidden', isOpen);
  351. chevron.style.transform = isOpen ? 'rotate(0deg)' : 'rotate(180deg)';
  352. }
  353. function switchLanguage(lang) {
  354. // Ferme le dropdown
  355. document.getElementById('lang-menu')?.classList.add('hidden');
  356. const chevron = document.getElementById('lang-chevron');
  357. if (chevron) chevron.style.transform = 'rotate(0deg)';
  358. // Met à jour le bouton
  359. const flag = document.getElementById('lang-flag');
  360. const label = document.getElementById('lang-label');
  361. if (flag) flag.src = lang === 'en'
  362. ? 'https://flagcdn.com/w20/gb.png'
  363. : 'https://flagcdn.com/w20/fr.png';
  364. if (label) label.textContent = lang === 'en' ? 'English' : 'Français';
  365. // Coches actives / inactives
  366. const optFr = document.getElementById('lang-opt-fr');
  367. const optEn = document.getElementById('lang-opt-en');
  368. const chkFr = document.querySelector('.lang-check-fr');
  369. const chkEn = document.querySelector('.lang-check-en');
  370. if (lang === 'en') {
  371. optEn?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  372. optEn?.classList.remove('text-gray-700');
  373. optFr?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  374. optFr?.classList.add('text-gray-700');
  375. chkEn?.classList.remove('hidden');
  376. chkFr?.classList.add('hidden');
  377. } else {
  378. optFr?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  379. optFr?.classList.remove('text-gray-700');
  380. optEn?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  381. optEn?.classList.add('text-gray-700');
  382. chkFr?.classList.remove('hidden');
  383. chkEn?.classList.add('hidden');
  384. }
  385. // Sauvegarde le choix
  386. localStorage.setItem('jo_lang', lang);
  387. // Lance la traduction ou recharge pour le français
  388. if (lang === 'en') {
  389. Translator.translate('en');
  390. } else {
  391. window.location.reload();
  392. }
  393. }
  394. // Ferme le dropdown si clic en dehors
  395. document.addEventListener('click', function (e) {
  396. const switcher = document.getElementById('lang-switcher');
  397. if (switcher && !switcher.contains(e.target)) {
  398. document.getElementById('lang-menu')?.classList.add('hidden');
  399. const c = document.getElementById('lang-chevron');
  400. if (c) c.style.transform = 'rotate(0deg)';
  401. }
  402. });
  403. // Restaure la langue sauvegardée au chargement
  404. document.addEventListener('DOMContentLoaded', function () {
  405. if (localStorage.getItem('jo_lang') === 'en') {
  406. const flag = document.getElementById('lang-flag');
  407. const label = document.getElementById('lang-label');
  408. if (flag) flag.src = 'https://flagcdn.com/w20/gb.png';
  409. if (label) label.textContent = 'English';
  410. const optFr = document.getElementById('lang-opt-fr');
  411. const optEn = document.getElementById('lang-opt-en');
  412. const chkFr = document.querySelector('.lang-check-fr');
  413. const chkEn = document.querySelector('.lang-check-en');
  414. optEn?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  415. optEn?.classList.remove('text-gray-700');
  416. optFr?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  417. optFr?.classList.add('text-gray-700');
  418. chkEn?.classList.remove('hidden');
  419. chkFr?.classList.add('hidden');
  420. Translator.translate('en');
  421. }
  422. });
  423. </script>
  424. ";
  425. // line 417
  426. yield from $this->unwrap()->yieldBlock('javascripts', $context, $blocks);
  427. // line 418
  428. yield "</body>
  429. </html>";
  430. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  431. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  432. yield from [];
  433. }
  434. // line 9
  435. /**
  436. * @return iterable<null|scalar|\Stringable>
  437. */
  438. public function block_title(array $context, array $blocks = []): iterable
  439. {
  440. $macros = $this->macros;
  441. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  442. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "title"));
  443. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  444. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "title"));
  445. yield "Journal Officiel - Union des Comores";
  446. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  447. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  448. yield from [];
  449. }
  450. // line 92
  451. /**
  452. * @return iterable<null|scalar|\Stringable>
  453. */
  454. public function block_stylesheets(array $context, array $blocks = []): iterable
  455. {
  456. $macros = $this->macros;
  457. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  458. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "stylesheets"));
  459. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  460. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "stylesheets"));
  461. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  462. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  463. yield from [];
  464. }
  465. // line 99
  466. /**
  467. * @return iterable<null|scalar|\Stringable>
  468. */
  469. public function block_body(array $context, array $blocks = []): iterable
  470. {
  471. $macros = $this->macros;
  472. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  473. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "body"));
  474. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  475. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "body"));
  476. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  477. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  478. yield from [];
  479. }
  480. // line 417
  481. /**
  482. * @return iterable<null|scalar|\Stringable>
  483. */
  484. public function block_javascripts(array $context, array $blocks = []): iterable
  485. {
  486. $macros = $this->macros;
  487. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  488. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts"));
  489. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  490. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts"));
  491. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  492. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  493. yield from [];
  494. }
  495. /**
  496. * @codeCoverageIgnore
  497. */
  498. public function getTemplateName(): string
  499. {
  500. return "base.html.twig";
  501. }
  502. /**
  503. * @codeCoverageIgnore
  504. */
  505. public function isTraitable(): bool
  506. {
  507. return false;
  508. }
  509. /**
  510. * @codeCoverageIgnore
  511. */
  512. public function getDebugInfo(): array
  513. {
  514. return array ( 571 => 417, 549 => 99, 527 => 92, 504 => 9, 492 => 418, 490 => 417, 210 => 140, 172 => 104, 169 => 103, 167 => 102, 163 => 100, 161 => 99, 157 => 97, 155 => 96, 150 => 93, 148 => 92, 62 => 9, 52 => 1,);
  515. }
  516. public function getSourceContext(): Source
  517. {
  518. return new Source("<!DOCTYPE html>
  519. <html lang=\"fr\">
  520. <head>
  521. <meta charset=\"UTF-8\">
  522. <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
  523. <meta name=\"description\" content=\"Journal Officiel de l'Union des Comores - Portail officiel de publication des textes juridiques et administratifs\">
  524. <meta name=\"author\" content=\"Union des Comores\">
  525. <meta name=\"theme-color\" content=\"#006633\">
  526. <title>{% block title %}Journal Officiel - Union des Comores{% endblock %}</title>
  527. <link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap\" rel=\"stylesheet\">
  528. <script src=\"https://cdn.tailwindcss.com\"></script>
  529. <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\">
  530. <style>
  531. * { font-family: 'Inter', sans-serif; }
  532. body { background: linear-gradient(135deg, #f5f7fa 0%, #eef2f7 100%); }
  533. ::-webkit-scrollbar { width: 10px; height: 10px; }
  534. ::-webkit-scrollbar-track { background: #f1f1f1; }
  535. ::-webkit-scrollbar-thumb { background: #006633; border-radius: 5px; }
  536. ::-webkit-scrollbar-thumb:hover { background: #004d26; }
  537. @keyframes fadeInUp {
  538. from { opacity: 0; transform: translateY(30px); }
  539. to { opacity: 1; transform: translateY(0); }
  540. }
  541. .animate-fadeInUp { animation: fadeInUp 0.6s ease-out; }
  542. .card-hover { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
  543. .card-hover:hover {
  544. transform: translateY(-4px);
  545. box-shadow: 0 20px 25px -5px rgba(0,0,0,.1),
  546. 0 10px 10px -5px rgba(0,0,0,.02);
  547. }
  548. .gradient-text {
  549. background: linear-gradient(135deg, #006633 0%, #008844 100%);
  550. -webkit-background-clip: text;
  551. -webkit-text-fill-color: transparent;
  552. background-clip: text;
  553. }
  554. .chatbot-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 1000; }
  555. .chatbot-toggle {
  556. width: 64px; height: 64px;
  557. background: linear-gradient(135deg, #006633, #008844);
  558. border-radius: 50%;
  559. display: flex; align-items: center; justify-content: center;
  560. cursor: pointer;
  561. box-shadow: 0 10px 25px -5px rgba(0,0,0,.2);
  562. transition: all 0.3s ease;
  563. }
  564. .chatbot-toggle:hover {
  565. transform: scale(1.05);
  566. box-shadow: 0 20px 25px -5px rgba(0,0,0,.3);
  567. }
  568. .chatbot-window {
  569. position: absolute; bottom: 80px; right: 0;
  570. width: 400px; height: 560px;
  571. background: white; border-radius: 1rem;
  572. box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
  573. display: none; flex-direction: column; overflow: hidden;
  574. }
  575. .chatbot-window.open { display: flex; }
  576. @media (max-width: 640px) {
  577. .chatbot-window { width: calc(100vw - 2rem); right: 0; bottom: 80px; }
  578. }
  579. .loading-spinner {
  580. border: 3px solid rgba(0,102,51,.2);
  581. border-radius: 50%;
  582. border-top: 3px solid #006633;
  583. width: 24px; height: 24px;
  584. animation: spin 1s linear infinite;
  585. }
  586. @keyframes spin {
  587. 0% { transform: rotate(0deg); }
  588. 100% { transform: rotate(360deg); }
  589. }
  590. /* Barre de progression traduction */
  591. @keyframes tlProgress {
  592. 0% { width: 0%; }
  593. 50% { width: 70%; }
  594. 100% { width: 100%; }
  595. }
  596. </style>
  597. {% block stylesheets %}{% endblock %}
  598. </head>
  599. <body>
  600. {% include 'components/_header.html.twig' %}
  601. <main class=\"min-h-screen\">
  602. {% block body %}{% endblock %}
  603. </main>
  604. {% include 'components/_footer.html.twig' %}
  605. {% include 'components/_chatbot.html.twig' %}
  606. <!-- Alpine.js -->
  607. <script defer src=\"https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js\"></script>
  608. <script>
  609. window.App = { chatbot: null };
  610. document.addEventListener('alpine:init', () => {
  611. Alpine.data('chatbot', () => ({
  612. isOpen: false,
  613. messages: [],
  614. currentMessage: '',
  615. isLoading: false,
  616. init() {
  617. this.addMessage(
  618. \"Bonjour et bienvenue sur le Journal Officiel de l'Union des Comores. \" +
  619. \"Je suis Ibunas.IA, votre assistant juridique. Comment puis-je vous aider ?\",
  620. 'bot'
  621. );
  622. },
  623. toggle() {
  624. this.isOpen = !this.isOpen;
  625. if (this.isOpen) setTimeout(() => this.scrollToBottom(), 100);
  626. },
  627. async send() {
  628. if (!this.currentMessage.trim() || this.isLoading) return;
  629. const message = this.currentMessage;
  630. this.addMessage(message, 'user');
  631. this.currentMessage = '';
  632. this.isLoading = true;
  633. this.scrollToBottom();
  634. try {
  635. const response = await fetch('{{ path('app_chatbot_send') }}', {
  636. method: 'POST',
  637. headers: {
  638. 'Content-Type': 'application/json',
  639. 'X-Requested-With': 'XMLHttpRequest'
  640. },
  641. body: JSON.stringify({ message })
  642. });
  643. const data = await response.json();
  644. this.addMessage(data.response, 'bot');
  645. } catch (e) {
  646. this.addMessage('Désolé, une erreur technique est survenue.', 'bot');
  647. } finally {
  648. this.isLoading = false;
  649. this.scrollToBottom();
  650. }
  651. },
  652. addMessage(text, sender) {
  653. this.messages.push({
  654. id: Date.now(), text, sender, timestamp: new Date()
  655. });
  656. },
  657. scrollToBottom() {
  658. const c = document.getElementById('chatbot-messages');
  659. if (c) c.scrollTop = c.scrollHeight;
  660. }
  661. }));
  662. });
  663. </script>
  664. <!-- ── Moteur de traduction LibreTranslate ── -->
  665. <script>
  666. const Translator = {
  667. cache: {},
  668. loading: false,
  669. getNodes() {
  670. return [...document.querySelectorAll(
  671. 'h1, h2, h3, h4, p, a, span, button, label, td, th, li'
  672. )].filter(el =>
  673. [...el.childNodes].some(
  674. n => n.nodeType === 3 && n.textContent.trim().length > 2
  675. ) &&
  676. !el.closest('script, style, [data-no-translate]')
  677. );
  678. },
  679. // MyMemory — gratuit, CORS autorisé, pas de clé requise
  680. async translateText(text) {
  681. const url = 'https://api.mymemory.translated.net/get?'
  682. + new URLSearchParams({
  683. q: text,
  684. langpair: 'fr|en'
  685. });
  686. const res = await fetch(url, { method: 'GET' });
  687. const data = await res.json();
  688. if (data.responseStatus === 200) {
  689. return data.responseData.translatedText;
  690. }
  691. throw new Error('MyMemory error: ' + data.responseStatus);
  692. },
  693. async translate(lang) {
  694. if (this.loading) return;
  695. this.loading = true;
  696. this.showBar();
  697. const nodes = this.getNodes();
  698. const texts = nodes.map(el => el.innerText.trim());
  699. // Retourne le cache si déjà traduit
  700. if (this.cache[lang]) {
  701. this.apply(nodes, this.cache[lang]);
  702. this.hideBar();
  703. this.loading = false;
  704. return;
  705. }
  706. try {
  707. // MyMemory a une limite de 500 chars par requête
  708. // On traduit par petits groupes
  709. const translations = [];
  710. const chunkSize = 10; // 10 textes par lot
  711. for (let i = 0; i < texts.length; i += chunkSize) {
  712. const chunk = texts.slice(i, i + chunkSize);
  713. const sep = ' [|||] ';
  714. const combined = chunk.join(sep);
  715. // MyMemory limite à 500 chars — on tronque si nécessaire
  716. const toTranslate = combined.length > 500
  717. ? combined.substring(0, 500)
  718. : combined;
  719. const result = await this.translateText(toTranslate);
  720. const parts = result.split(sep).map(t => t.trim());
  721. // Complète si la réponse a moins d'éléments que l'envoi
  722. while (parts.length < chunk.length) {
  723. parts.push(chunk[parts.length]);
  724. }
  725. translations.push(...parts);
  726. // Pause entre les lots pour éviter le rate limit
  727. if (i + chunkSize < texts.length) {
  728. await new Promise(r => setTimeout(r, 300));
  729. }
  730. }
  731. this.cache[lang] = translations;
  732. this.apply(nodes, translations);
  733. } catch (e) {
  734. console.error('Erreur traduction:', e);
  735. this.showToast('⚠ Traduction indisponible');
  736. } finally {
  737. this.hideBar();
  738. this.loading = false;
  739. }
  740. },
  741. apply(nodes, translations) {
  742. nodes.forEach((el, i) => {
  743. if (!translations[i]) return;
  744. [...el.childNodes].forEach(n => {
  745. if (n.nodeType === 3 && n.textContent.trim().length > 2) {
  746. n.textContent = translations[i];
  747. }
  748. });
  749. });
  750. },
  751. showBar() {
  752. let bar = document.getElementById('tl-bar');
  753. if (!bar) {
  754. bar = document.createElement('div');
  755. bar.id = 'tl-bar';
  756. bar.innerHTML = `
  757. <div style=\"position:fixed;top:0;left:0;right:0;height:3px;
  758. background:#e5e7eb;z-index:9999;pointer-events:none\">
  759. <div id=\"tl-prog\"
  760. style=\"height:100%;width:0%;background:#006633;
  761. transition:width 1.5s ease;
  762. border-radius:0 2px 2px 0\">
  763. </div>
  764. </div>`;
  765. document.body.appendChild(bar);
  766. }
  767. bar.style.display = 'block';
  768. setTimeout(() => {
  769. const p = document.getElementById('tl-prog');
  770. if (p) p.style.width = '80%';
  771. }, 50);
  772. },
  773. hideBar() {
  774. const p = document.getElementById('tl-prog');
  775. if (p) {
  776. p.style.width = '100%';
  777. setTimeout(() => {
  778. const bar = document.getElementById('tl-bar');
  779. if (bar) bar.style.display = 'none';
  780. p.style.width = '0%';
  781. }, 400);
  782. }
  783. },
  784. showToast(msg) {
  785. const t = document.createElement('div');
  786. t.textContent = msg;
  787. t.style.cssText = `
  788. position: fixed; bottom: 1.5rem; left: 50%;
  789. transform: translateX(-50%);
  790. background: #fee2e2; color: #991b1b;
  791. border: 1px solid #fca5a5;
  792. padding: .6rem 1.2rem; border-radius: .75rem;
  793. font-size: .8rem; font-weight: 600; z-index: 9999;`;
  794. document.body.appendChild(t);
  795. setTimeout(() => t.remove(), 3000);
  796. }
  797. };
  798. // ── Fonctions globales du sélecteur de langue ──
  799. function toggleLangMenu() {
  800. const menu = document.getElementById('lang-menu');
  801. const chevron = document.getElementById('lang-chevron');
  802. const isOpen = !menu.classList.contains('hidden');
  803. menu.classList.toggle('hidden', isOpen);
  804. chevron.style.transform = isOpen ? 'rotate(0deg)' : 'rotate(180deg)';
  805. }
  806. function switchLanguage(lang) {
  807. // Ferme le dropdown
  808. document.getElementById('lang-menu')?.classList.add('hidden');
  809. const chevron = document.getElementById('lang-chevron');
  810. if (chevron) chevron.style.transform = 'rotate(0deg)';
  811. // Met à jour le bouton
  812. const flag = document.getElementById('lang-flag');
  813. const label = document.getElementById('lang-label');
  814. if (flag) flag.src = lang === 'en'
  815. ? 'https://flagcdn.com/w20/gb.png'
  816. : 'https://flagcdn.com/w20/fr.png';
  817. if (label) label.textContent = lang === 'en' ? 'English' : 'Français';
  818. // Coches actives / inactives
  819. const optFr = document.getElementById('lang-opt-fr');
  820. const optEn = document.getElementById('lang-opt-en');
  821. const chkFr = document.querySelector('.lang-check-fr');
  822. const chkEn = document.querySelector('.lang-check-en');
  823. if (lang === 'en') {
  824. optEn?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  825. optEn?.classList.remove('text-gray-700');
  826. optFr?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  827. optFr?.classList.add('text-gray-700');
  828. chkEn?.classList.remove('hidden');
  829. chkFr?.classList.add('hidden');
  830. } else {
  831. optFr?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  832. optFr?.classList.remove('text-gray-700');
  833. optEn?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  834. optEn?.classList.add('text-gray-700');
  835. chkFr?.classList.remove('hidden');
  836. chkEn?.classList.add('hidden');
  837. }
  838. // Sauvegarde le choix
  839. localStorage.setItem('jo_lang', lang);
  840. // Lance la traduction ou recharge pour le français
  841. if (lang === 'en') {
  842. Translator.translate('en');
  843. } else {
  844. window.location.reload();
  845. }
  846. }
  847. // Ferme le dropdown si clic en dehors
  848. document.addEventListener('click', function (e) {
  849. const switcher = document.getElementById('lang-switcher');
  850. if (switcher && !switcher.contains(e.target)) {
  851. document.getElementById('lang-menu')?.classList.add('hidden');
  852. const c = document.getElementById('lang-chevron');
  853. if (c) c.style.transform = 'rotate(0deg)';
  854. }
  855. });
  856. // Restaure la langue sauvegardée au chargement
  857. document.addEventListener('DOMContentLoaded', function () {
  858. if (localStorage.getItem('jo_lang') === 'en') {
  859. const flag = document.getElementById('lang-flag');
  860. const label = document.getElementById('lang-label');
  861. if (flag) flag.src = 'https://flagcdn.com/w20/gb.png';
  862. if (label) label.textContent = 'English';
  863. const optFr = document.getElementById('lang-opt-fr');
  864. const optEn = document.getElementById('lang-opt-en');
  865. const chkFr = document.querySelector('.lang-check-fr');
  866. const chkEn = document.querySelector('.lang-check-en');
  867. optEn?.classList.add('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  868. optEn?.classList.remove('text-gray-700');
  869. optFr?.classList.remove('text-[#006633]', 'font-semibold', 'bg-emerald-50');
  870. optFr?.classList.add('text-gray-700');
  871. chkEn?.classList.remove('hidden');
  872. chkFr?.classList.add('hidden');
  873. Translator.translate('en');
  874. }
  875. });
  876. </script>
  877. {% block javascripts %}{% endblock %}
  878. </body>
  879. </html>", "base.html.twig", "/htdocs/jo.technopole-km.com/templates/base.html.twig");
  880. }
  881. }