@portnet/ui 5.0.12 → 5.0.14

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.
@@ -0,0 +1,3633 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/esnext.iterator.for-each.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("core-js/modules/es.symbol.description.js");
9
+ require("core-js/modules/es.array.includes.js");
10
+ require("core-js/modules/es.array-buffer.constructor.js");
11
+ require("core-js/modules/es.array-buffer.slice.js");
12
+ require("core-js/modules/es.promise.js");
13
+ require("core-js/modules/es.string.includes.js");
14
+ require("core-js/modules/es.string.trim.js");
15
+ require("core-js/modules/es.typed-array.uint8-array.js");
16
+ require("core-js/modules/es.typed-array.fill.js");
17
+ require("core-js/modules/es.typed-array.set.js");
18
+ require("core-js/modules/es.typed-array.sort.js");
19
+ require("core-js/modules/es.typed-array.to-locale-string.js");
20
+ require("core-js/modules/esnext.iterator.constructor.js");
21
+ require("core-js/modules/esnext.iterator.filter.js");
22
+ require("core-js/modules/esnext.iterator.map.js");
23
+ require("core-js/modules/web.dom-collections.iterator.js");
24
+ require("core-js/modules/web.url.js");
25
+ require("core-js/modules/web.url.to-json.js");
26
+ require("core-js/modules/web.url-search-params.js");
27
+ var _react = require("react");
28
+ var _reactRedux = require("react-redux");
29
+ var _reactQuery = require("react-query");
30
+ var _reactFontawesome = require("@fortawesome/react-fontawesome");
31
+ var _reactToastify = require("react-toastify");
32
+ var _reactstrap = require("reactstrap");
33
+ var _freeRegularSvgIcons = require("@fortawesome/free-regular-svg-icons");
34
+ var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
35
+ var _iconsMaterial = require("@mui/icons-material");
36
+ var _material = require("@mui/material");
37
+ require("../../styles/help-widget.css");
38
+ require("../../styles/ReclamationFormModal.css");
39
+ var _useReclamation = require("../../hooks/useReclamation");
40
+ var _guides = _interopRequireDefault(require("../../assets/guides"));
41
+ var _PuiHelpWidgetContext = require("../common/PuiHelpWidgetContext");
42
+ var _tijariaLogo = _interopRequireDefault(require("../../assets/images/tijariaLogo.ico"));
43
+ var _GuideImage = require("./GuideImage");
44
+ var _jsxRuntime = require("react/jsx-runtime");
45
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
46
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
48
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
49
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
50
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
51
+ const WIDGET_FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif";
52
+ const ContentPanel = _ref => {
53
+ let {
54
+ isOpen,
55
+ onClose,
56
+ contentData,
57
+ title = "Contenu",
58
+ showDownloadButton = false,
59
+ showExternalLinkLabel = false,
60
+ onDownload = null,
61
+ loadingDownload = false,
62
+ projectCode = null,
63
+ externalLinkUrl = null,
64
+ guideBaseUrl
65
+ } = _ref;
66
+ const {
67
+ guideImageService
68
+ } = (0, _PuiHelpWidgetContext.useHelpWidget)();
69
+ const [position, setPosition] = (0, _react.useState)({
70
+ x: window.innerWidth - 380,
71
+ y: 40
72
+ });
73
+ const [isDragging, setIsDragging] = (0, _react.useState)(false);
74
+ const [dragStart, setDragStart] = (0, _react.useState)({
75
+ x: 0,
76
+ y: 0
77
+ });
78
+ const panelRef = (0, _react.useRef)(null);
79
+ const firstFocusableRef = (0, _react.useRef)(null);
80
+ const previousActiveElement = (0, _react.useRef)(null);
81
+ const [currentView, setCurrentView] = (0, _react.useState)("list");
82
+ const [selectedSection, setSelectedSection] = (0, _react.useState)(null);
83
+ const [fullscreenImage, setFullscreenImage] = (0, _react.useState)(null);
84
+ const PANEL_WIDTH = 340;
85
+ const PANEL_MAX_HEIGHT = 550;
86
+ const RESIZE_MARGIN = 40;
87
+ const MIN_VISIBLE_WIDTH = 80;
88
+ (0, _react.useEffect)(() => {
89
+ if (contentData) {
90
+ setCurrentView("list");
91
+ setSelectedSection(null);
92
+ }
93
+ }, [contentData]);
94
+ (0, _react.useEffect)(() => {
95
+ return () => {
96
+ guideImageService.clearImageCache();
97
+ };
98
+ }, []);
99
+ const handleSectionClick = section => {
100
+ setSelectedSection(section);
101
+ setCurrentView("detail");
102
+ };
103
+ const handleBack = () => {
104
+ setCurrentView("list");
105
+ setSelectedSection(null);
106
+ };
107
+ const handleOpenInNewWindow = () => {
108
+ if (!selectedSection || !projectCode || !guideBaseUrl) return;
109
+ const url = "".concat(guideBaseUrl, "/#/guide/").concat(projectCode, "?section=").concat(selectedSection.id);
110
+ window.open(url, "_blank");
111
+ };
112
+ const handleImageClick = imageSrc => {
113
+ setFullscreenImage(imageSrc);
114
+ };
115
+ const handleCloseFullscreen = () => {
116
+ setFullscreenImage(null);
117
+ };
118
+ const handleMouseDown = e => {
119
+ if (e.target.closest(".drag-handle")) {
120
+ setIsDragging(true);
121
+ setDragStart({
122
+ x: e.clientX - position.x,
123
+ y: e.clientY - position.y
124
+ });
125
+ }
126
+ };
127
+ const handleMouseMove = e => {
128
+ if (isDragging) {
129
+ const newX = e.clientX - dragStart.x;
130
+ const newY = e.clientY - dragStart.y;
131
+ const constrainedX = Math.max(0, newX);
132
+ const maxX = window.innerWidth - MIN_VISIBLE_WIDTH;
133
+ const finalX = Math.min(constrainedX, maxX);
134
+ const finalY = Math.max(0, newY);
135
+ setPosition({
136
+ x: finalX,
137
+ y: finalY
138
+ });
139
+ }
140
+ };
141
+ const handleMouseUp = () => {
142
+ setIsDragging(false);
143
+ };
144
+ (0, _react.useEffect)(() => {
145
+ const handleResize = () => {
146
+ setPosition(prev => {
147
+ var _panelRef$current;
148
+ const panelHeight = ((_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.offsetHeight) || PANEL_MAX_HEIGHT;
149
+ let newX = prev.x;
150
+ let newY = prev.y;
151
+ const maxX = window.innerWidth - PANEL_WIDTH - RESIZE_MARGIN;
152
+ const maxY = window.innerHeight - panelHeight - RESIZE_MARGIN;
153
+ if (prev.x + PANEL_WIDTH > window.innerWidth - RESIZE_MARGIN) {
154
+ newX = Math.max(RESIZE_MARGIN, maxX);
155
+ }
156
+ if (prev.x < RESIZE_MARGIN) {
157
+ newX = RESIZE_MARGIN;
158
+ }
159
+ if (prev.y + panelHeight > window.innerHeight - RESIZE_MARGIN) {
160
+ newY = Math.max(RESIZE_MARGIN, maxY);
161
+ }
162
+ if (prev.y < RESIZE_MARGIN) {
163
+ newY = RESIZE_MARGIN;
164
+ }
165
+ return {
166
+ x: newX,
167
+ y: newY
168
+ };
169
+ });
170
+ };
171
+ window.addEventListener("resize", handleResize);
172
+ return () => window.removeEventListener("resize", handleResize);
173
+ }, []);
174
+ (0, _react.useEffect)(() => {
175
+ if (isDragging) {
176
+ document.addEventListener("mousemove", handleMouseMove);
177
+ document.addEventListener("mouseup", handleMouseUp);
178
+ return () => {
179
+ document.removeEventListener("mousemove", handleMouseMove);
180
+ document.removeEventListener("mouseup", handleMouseUp);
181
+ };
182
+ }
183
+ }, [isDragging, dragStart]);
184
+ (0, _react.useEffect)(() => {
185
+ const handleEscape = e => {
186
+ if (e.key === "Escape" && fullscreenImage) {
187
+ handleCloseFullscreen();
188
+ }
189
+ };
190
+ window.addEventListener("keydown", handleEscape);
191
+ return () => window.removeEventListener("keydown", handleEscape);
192
+ }, [fullscreenImage]);
193
+ (0, _react.useEffect)(() => {
194
+ if (isOpen) {
195
+ previousActiveElement.current = document.activeElement;
196
+ setTimeout(() => {
197
+ var _firstFocusableRef$cu;
198
+ (_firstFocusableRef$cu = firstFocusableRef.current) === null || _firstFocusableRef$cu === void 0 || _firstFocusableRef$cu.focus();
199
+ }, 100);
200
+ } else {
201
+ if (previousActiveElement.current) {
202
+ previousActiveElement.current.focus();
203
+ }
204
+ }
205
+ }, [isOpen]);
206
+ (0, _react.useEffect)(() => {
207
+ if (!isOpen) return;
208
+ const handleKeyDown = e => {
209
+ if (e.key === "Escape") {
210
+ if (fullscreenImage) {
211
+ return;
212
+ }
213
+ onClose();
214
+ return;
215
+ }
216
+ if (e.key === "Tab") {
217
+ const panel = panelRef.current;
218
+ if (!panel) return;
219
+ const focusableElements = panel.querySelectorAll('button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])');
220
+ const focusableArray = Array.from(focusableElements);
221
+ const firstElement = focusableArray[0];
222
+ const lastElement = focusableArray[focusableArray.length - 1];
223
+ if (focusableArray.length === 0) return;
224
+ if (e.shiftKey) {
225
+ if (document.activeElement === firstElement) {
226
+ lastElement.focus();
227
+ e.preventDefault();
228
+ }
229
+ } else {
230
+ if (document.activeElement === lastElement) {
231
+ firstElement.focus();
232
+ e.preventDefault();
233
+ }
234
+ }
235
+ }
236
+ };
237
+ document.addEventListener("keydown", handleKeyDown);
238
+ return () => document.removeEventListener("keydown", handleKeyDown);
239
+ }, [isOpen, onClose, fullscreenImage]);
240
+ (0, _react.useEffect)(() => {
241
+ if (isOpen) {
242
+ document.body.style.overflow = "hidden";
243
+ } else {
244
+ document.body.style.overflow = "";
245
+ }
246
+ return () => {
247
+ document.body.style.overflow = "";
248
+ };
249
+ }, [isOpen]);
250
+ (0, _react.useEffect)(() => {
251
+ if (currentView === "detail") {
252
+ setTimeout(() => {
253
+ const panel = panelRef.current;
254
+ if (!panel) return;
255
+ const focusableElements = panel.querySelectorAll('button:not([disabled]), [href]:not([disabled]), [role="button"]:not([disabled])[tabindex="0"]');
256
+ if (focusableElements.length > 0) {
257
+ focusableElements[0].focus();
258
+ }
259
+ }, 100);
260
+ } else if (currentView === "list") {
261
+ setTimeout(() => {
262
+ var _firstFocusableRef$cu2;
263
+ (_firstFocusableRef$cu2 = firstFocusableRef.current) === null || _firstFocusableRef$cu2 === void 0 || _firstFocusableRef$cu2.focus();
264
+ }, 100);
265
+ }
266
+ }, [currentView]);
267
+ if (!isOpen) return null;
268
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
269
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
270
+ ref: panelRef,
271
+ role: "dialog",
272
+ "aria-modal": "true",
273
+ "aria-labelledby": "panel-title",
274
+ style: {
275
+ position: "fixed",
276
+ left: "".concat(position.x, "px"),
277
+ top: "".concat(position.y, "px"),
278
+ width: "360px",
279
+ height: "auto",
280
+ maxHeight: "550px",
281
+ backgroundColor: "white",
282
+ border: "0px solid #dadce0",
283
+ borderRadius: "16px",
284
+ boxShadow: "0px 1px 3px 0px rgba(60, 64, 67, 0.3)",
285
+ zIndex: 10000000,
286
+ display: "flex",
287
+ flexDirection: "column",
288
+ overflow: "hidden",
289
+ fontFamily: "'Google Sans', Roboto, Arial, sans-serif"
290
+ },
291
+ onMouseDown: handleMouseDown,
292
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
293
+ className: "drag-handle",
294
+ style: {
295
+ display: "flex",
296
+ alignItems: "center",
297
+ justifyContent: "center",
298
+ marginTop: "10px",
299
+ padding: "16px 20px",
300
+ cursor: "move",
301
+ userSelect: "none",
302
+ backgroundColor: "white",
303
+ position: "relative"
304
+ },
305
+ children: [currentView === "detail" && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
306
+ onClick: handleBack,
307
+ "aria-label": "Retour \xE0 la liste",
308
+ tabIndex: 0,
309
+ style: {
310
+ background: "none",
311
+ border: "none",
312
+ cursor: "pointer",
313
+ padding: "8px",
314
+ borderRadius: "50%",
315
+ display: "flex",
316
+ alignItems: "center",
317
+ justifyContent: "center",
318
+ transition: "background-color 0.2s",
319
+ position: "absolute",
320
+ left: "12px",
321
+ order: 1
322
+ },
323
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "#f1f3f4",
324
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
325
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
326
+ xmlns: "http://www.w3.org/2000/svg",
327
+ width: "22",
328
+ height: "22",
329
+ viewBox: "0 0 24 24",
330
+ fill: "none",
331
+ stroke: "#5f6368",
332
+ strokeWidth: "2",
333
+ strokeLinecap: "round",
334
+ strokeLinejoin: "round",
335
+ "aria-hidden": "true",
336
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
337
+ d: "M19 12H5M12 19l-7-7 7-7"
338
+ })
339
+ })
340
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
341
+ id: "panel-title",
342
+ style: {
343
+ margin: 0,
344
+ fontSize: "20px",
345
+ fontWeight: "400",
346
+ color: "#202124",
347
+ letterSpacing: "0",
348
+ order: 2
349
+ },
350
+ children: title
351
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
352
+ ref: firstFocusableRef,
353
+ onClick: onClose,
354
+ "aria-label": "Fermer le panneau",
355
+ tabIndex: 0,
356
+ style: {
357
+ background: "none",
358
+ border: "none",
359
+ cursor: "pointer",
360
+ padding: "8px",
361
+ borderRadius: "50%",
362
+ display: "flex",
363
+ alignItems: "center",
364
+ justifyContent: "center",
365
+ transition: "background-color 0.2s",
366
+ position: "absolute",
367
+ right: "12px",
368
+ order: 3
369
+ },
370
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "#f1f3f4",
371
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
372
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
373
+ xmlns: "http://www.w3.org/2000/svg",
374
+ width: "22",
375
+ height: "22",
376
+ viewBox: "0 0 24 24",
377
+ fill: "none",
378
+ stroke: "#5f6368",
379
+ strokeWidth: "2",
380
+ strokeLinecap: "round",
381
+ strokeLinejoin: "round",
382
+ "aria-hidden": "true",
383
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
384
+ x1: "18",
385
+ y1: "6",
386
+ x2: "6",
387
+ y2: "18"
388
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
389
+ x1: "6",
390
+ y1: "6",
391
+ x2: "18",
392
+ y2: "18"
393
+ })]
394
+ })
395
+ })]
396
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
397
+ style: {
398
+ padding: "10px 16px",
399
+ marginBottom: "7px",
400
+ overflowY: "auto",
401
+ flex: 1
402
+ },
403
+ children: currentView === "list" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
404
+ children: !contentData ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
405
+ style: {
406
+ textAlign: "center",
407
+ padding: "20px",
408
+ marginBottom: 9
409
+ },
410
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
411
+ size: 20,
412
+ sx: {
413
+ color: "#1967d2"
414
+ }
415
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
416
+ component: "div",
417
+ sx: {
418
+ fontSize: "14px",
419
+ color: "#202124",
420
+ marginTop: "10px",
421
+ lineHeight: "normal"
422
+ },
423
+ children: "Chargement..."
424
+ })]
425
+ }) : contentData !== null && contentData !== void 0 && contentData.sections && contentData.sections.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
426
+ children: [contentData.name && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
427
+ style: {
428
+ marginBottom: "7px"
429
+ },
430
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
431
+ style: {
432
+ fontSize: "16px",
433
+ color: "#202124",
434
+ lineHeight: "24px",
435
+ margin: 0,
436
+ fontWeight: "400"
437
+ },
438
+ children: contentData.name
439
+ })
440
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
441
+ style: {
442
+ display: "flex",
443
+ flexDirection: "column",
444
+ gap: "4px"
445
+ },
446
+ children: contentData.sections.map(section => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
447
+ onClick: () => handleSectionClick(section),
448
+ onKeyDown: e => {
449
+ if (e.key === "Enter" || e.key === " ") {
450
+ e.preventDefault();
451
+ handleSectionClick(section);
452
+ }
453
+ },
454
+ role: "button",
455
+ tabIndex: 0,
456
+ "aria-label": "Ouvrir ".concat(section.title),
457
+ style: {
458
+ display: "flex",
459
+ alignItems: "center",
460
+ padding: "12px 2.2px",
461
+ cursor: "pointer",
462
+ borderRadius: "8px",
463
+ transition: "background-color 0.2s",
464
+ backgroundColor: "transparent"
465
+ },
466
+ onMouseEnter: e => {
467
+ e.currentTarget.style.backgroundColor = "#f1f3f4";
468
+ },
469
+ onMouseLeave: e => {
470
+ e.currentTarget.style.backgroundColor = "transparent";
471
+ },
472
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
473
+ style: {
474
+ minWidth: "34px",
475
+ height: "34px",
476
+ borderRadius: "50%",
477
+ backgroundColor: "#e8f0fe",
478
+ display: "flex",
479
+ alignItems: "center",
480
+ justifyContent: "center",
481
+ marginRight: "12px",
482
+ flexShrink: 0
483
+ },
484
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
485
+ xmlns: "http://www.w3.org/2000/svg",
486
+ width: "16",
487
+ height: "16",
488
+ viewBox: "0 0 24 24",
489
+ fill: "none",
490
+ stroke: "#1967d2",
491
+ strokeWidth: "2",
492
+ strokeLinecap: "round",
493
+ strokeLinejoin: "round",
494
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
495
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"
496
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
497
+ points: "14 2 14 8 20 8"
498
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
499
+ x1: "16",
500
+ y1: "13",
501
+ x2: "8",
502
+ y2: "13"
503
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
504
+ x1: "16",
505
+ y1: "17",
506
+ x2: "8",
507
+ y2: "17"
508
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
509
+ x1: "10",
510
+ y1: "9",
511
+ x2: "8",
512
+ y2: "9"
513
+ })]
514
+ })
515
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
516
+ style: {
517
+ flex: 1
518
+ },
519
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
520
+ style: {
521
+ fontSize: "16px",
522
+ color: "#202124",
523
+ fontWeight: "400",
524
+ lineHeight: "20px"
525
+ },
526
+ children: section.title
527
+ })
528
+ })]
529
+ }, section.id))
530
+ }), showDownloadButton && onDownload && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
531
+ style: {
532
+ marginTop: "10px"
533
+ },
534
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
535
+ onClick: onDownload,
536
+ onKeyDown: e => {
537
+ if (e.key === "Enter" || e.key === " ") {
538
+ e.preventDefault();
539
+ onDownload();
540
+ }
541
+ },
542
+ role: "button",
543
+ tabIndex: 0,
544
+ "aria-label": "T\xE9l\xE9charger le guide complet",
545
+ style: {
546
+ display: "flex",
547
+ alignItems: "center",
548
+ justifyContent: "center",
549
+ gap: "6px",
550
+ color: "#1967d2",
551
+ fontSize: "14px",
552
+ textDecoration: "none",
553
+ padding: "8px",
554
+ borderRadius: "4px",
555
+ transition: "background-color 0.2s",
556
+ cursor: loadingDownload ? "not-allowed" : "pointer",
557
+ opacity: loadingDownload ? 0.6 : 1
558
+ },
559
+ onMouseEnter: e => !loadingDownload && (e.currentTarget.style.backgroundColor = "#f1f3f4"),
560
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
561
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
562
+ children: "T\xE9l\xE9charger le guide complet"
563
+ }), loadingDownload ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
564
+ size: 16,
565
+ sx: {
566
+ color: "#1967d2"
567
+ }
568
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
569
+ xmlns: "http://www.w3.org/2000/svg",
570
+ width: "16",
571
+ height: "16",
572
+ viewBox: "0 0 24 24",
573
+ fill: "none",
574
+ stroke: "currentColor",
575
+ strokeWidth: "2",
576
+ strokeLinecap: "round",
577
+ strokeLinejoin: "round",
578
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
579
+ d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
580
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
581
+ points: "7 10 12 15 17 10"
582
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
583
+ x1: "12",
584
+ y1: "15",
585
+ x2: "12",
586
+ y2: "3"
587
+ })]
588
+ })]
589
+ })
590
+ }), showExternalLinkLabel && externalLinkUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
591
+ style: {
592
+ marginTop: "10px"
593
+ },
594
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
595
+ onClick: () => window.open(externalLinkUrl, "_blank"),
596
+ onKeyDown: e => {
597
+ if (e.key === "Enter" || e.key === " ") {
598
+ e.preventDefault();
599
+ window.open(externalLinkUrl, "_blank");
600
+ }
601
+ },
602
+ role: "button",
603
+ tabIndex: 0,
604
+ "aria-label": "Voir plus de d\xE9tails (ouvre dans un nouvel onglet)",
605
+ style: {
606
+ display: "flex",
607
+ alignItems: "center",
608
+ justifyContent: "center",
609
+ gap: "6px",
610
+ color: "#1967d2",
611
+ fontSize: "14px",
612
+ textDecoration: "none",
613
+ padding: "8px",
614
+ borderRadius: "4px",
615
+ transition: "background-color 0.2s",
616
+ cursor: "pointer"
617
+ },
618
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "#f1f3f4",
619
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
620
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
621
+ children: "Voir plus de d\xE9tails"
622
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
623
+ xmlns: "http://www.w3.org/2000/svg",
624
+ width: "16",
625
+ height: "16",
626
+ viewBox: "0 0 24 24",
627
+ fill: "none",
628
+ stroke: "currentColor",
629
+ strokeWidth: "2",
630
+ strokeLinecap: "round",
631
+ strokeLinejoin: "round",
632
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
633
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
634
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
635
+ points: "15 3 21 3 21 9"
636
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
637
+ x1: "21",
638
+ y1: "3",
639
+ x2: "10",
640
+ y2: "14"
641
+ })]
642
+ })]
643
+ })
644
+ })]
645
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
646
+ style: {
647
+ textAlign: "center",
648
+ padding: "50px 20px",
649
+ color: "#202124"
650
+ },
651
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
652
+ component: "div",
653
+ sx: {
654
+ fontSize: "14px",
655
+ lineHeight: "normal",
656
+ color: "#202124"
657
+ },
658
+ children: "Aucune section disponible."
659
+ })
660
+ })
661
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
662
+ children: selectedSection && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
663
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
664
+ style: {
665
+ marginBottom: "14px",
666
+ marginTop: "4px"
667
+ },
668
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
669
+ style: {
670
+ fontSize: "28px",
671
+ color: "#202124",
672
+ fontWeight: "400",
673
+ lineHeight: "32px",
674
+ margin: 0
675
+ },
676
+ children: selectedSection.title
677
+ })
678
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
679
+ style: {
680
+ marginBottom: "20px"
681
+ },
682
+ children: selectedSection.paragraphs && selectedSection.paragraphs.map((paragraph, index) => {
683
+ const text = typeof paragraph === "string" ? paragraph : paragraph.text;
684
+ const isQuestion = typeof paragraph === "object" && paragraph.isQuestion;
685
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
686
+ style: {
687
+ fontSize: "16px",
688
+ color: "#202124",
689
+ lineHeight: "22px",
690
+ margin: index === 0 ? 0 : "12px 0 0 0",
691
+ fontWeight: isQuestion ? "600" : "400"
692
+ },
693
+ children: text
694
+ }, index);
695
+ })
696
+ }), selectedSection.images && selectedSection.images.length > 0 && projectCode && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GuideImage.GuideImageGallery, {
697
+ projectCode: projectCode,
698
+ imageOrders: selectedSection.images,
699
+ columns: 1,
700
+ onImageClick: handleImageClick
701
+ }), selectedSection.keywords && selectedSection.keywords.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
702
+ style: {
703
+ marginTop: "20px",
704
+ marginBottom: "20px"
705
+ },
706
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
707
+ style: {
708
+ fontSize: "13px",
709
+ fontWeight: "500",
710
+ color: "#202124",
711
+ margin: "0 0 10px 0",
712
+ letterSpacing: "0.5px"
713
+ },
714
+ children: "Mots-cl\xE9s"
715
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
716
+ style: {
717
+ display: "flex",
718
+ flexWrap: "wrap",
719
+ gap: "6px"
720
+ },
721
+ children: selectedSection.keywords.map((keyword, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
722
+ style: {
723
+ backgroundColor: "#e8f0fe",
724
+ color: "#1967d2",
725
+ padding: "4px 10px",
726
+ borderRadius: "12px",
727
+ fontSize: "12px",
728
+ fontWeight: "500"
729
+ },
730
+ children: keyword
731
+ }, index))
732
+ })]
733
+ }), projectCode && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
734
+ style: {
735
+ marginTop: "24px",
736
+ paddingTop: "16px",
737
+ borderTop: "1px solid #e8eaed"
738
+ },
739
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
740
+ onClick: handleOpenInNewWindow,
741
+ onKeyDown: e => {
742
+ if (e.key === "Enter" || e.key === " ") {
743
+ e.preventDefault();
744
+ handleOpenInNewWindow();
745
+ }
746
+ },
747
+ role: "button",
748
+ tabIndex: 0,
749
+ "aria-label": "Ouvrir dans une nouvelle fen\xEAtre",
750
+ style: {
751
+ display: "flex",
752
+ alignItems: "center",
753
+ justifyContent: "center",
754
+ gap: "6px",
755
+ color: "#1967d2",
756
+ fontSize: "14px",
757
+ padding: "8px",
758
+ borderRadius: "4px",
759
+ cursor: "pointer",
760
+ transition: "background-color 0.2s"
761
+ },
762
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "#f1f3f4",
763
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
764
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
765
+ children: "Ouvrir dans une nouvelle fen\xEAtre"
766
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
767
+ xmlns: "http://www.w3.org/2000/svg",
768
+ width: "16",
769
+ height: "16",
770
+ viewBox: "0 0 24 24",
771
+ fill: "none",
772
+ stroke: "currentColor",
773
+ strokeWidth: "2",
774
+ strokeLinecap: "round",
775
+ strokeLinejoin: "round",
776
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
777
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
778
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
779
+ points: "15 3 21 3 21 9"
780
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
781
+ x1: "10",
782
+ y1: "14",
783
+ x2: "21",
784
+ y2: "3"
785
+ })]
786
+ })]
787
+ })
788
+ })]
789
+ })
790
+ })
791
+ })]
792
+ }), fullscreenImage && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
793
+ onClick: handleCloseFullscreen,
794
+ style: {
795
+ position: "fixed",
796
+ top: 0,
797
+ left: 0,
798
+ width: "100vw",
799
+ height: "100vh",
800
+ backgroundColor: "rgba(0, 0, 0, 0.78)",
801
+ zIndex: 20000000,
802
+ display: "flex",
803
+ alignItems: "center",
804
+ justifyContent: "center",
805
+ cursor: "zoom-out",
806
+ animation: "fadeIn 0.2s ease-in-out"
807
+ },
808
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
809
+ onClick: handleCloseFullscreen,
810
+ style: {
811
+ position: "absolute",
812
+ top: "20px",
813
+ right: "20px",
814
+ background: "rgba(255, 255, 255, 0.1)",
815
+ border: "none",
816
+ borderRadius: "50%",
817
+ width: "48px",
818
+ height: "48px",
819
+ cursor: "pointer",
820
+ display: "flex",
821
+ alignItems: "center",
822
+ justifyContent: "center",
823
+ transition: "background-color 0.2s",
824
+ zIndex: 20000001
825
+ },
826
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.2)",
827
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.1)",
828
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
829
+ xmlns: "http://www.w3.org/2000/svg",
830
+ width: "24",
831
+ height: "24",
832
+ viewBox: "0 0 24 24",
833
+ fill: "none",
834
+ stroke: "white",
835
+ strokeWidth: "2",
836
+ strokeLinecap: "round",
837
+ strokeLinejoin: "round",
838
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
839
+ x1: "18",
840
+ y1: "6",
841
+ x2: "6",
842
+ y2: "18"
843
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
844
+ x1: "6",
845
+ y1: "6",
846
+ x2: "18",
847
+ y2: "18"
848
+ })]
849
+ })
850
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
851
+ src: fullscreenImage,
852
+ alt: "Full screen view",
853
+ onClick: e => e.stopPropagation(),
854
+ style: {
855
+ maxWidth: "90vw",
856
+ maxHeight: "90vh",
857
+ objectFit: "contain",
858
+ cursor: "default",
859
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.5)"
860
+ }
861
+ })]
862
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
863
+ children: "\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n \n /* Focus indicators for ContentPanel */\n [role=\"dialog\"] button:focus-visible,\n [role=\"dialog\"] [role=\"button\"]:focus-visible,\n [role=\"dialog\"] a:focus-visible {\n outline: 3px solid #1967d2 !important;\n outline-offset: 2px !important;\n box-shadow: 0 0 0 4px rgba(25, 103, 210, 0.1) !important;\n }\n \n [role=\"dialog\"] button:focus:not(:focus-visible),\n [role=\"dialog\"] a:focus:not(:focus-visible) {\n outline: none;\n }\n "
864
+ })]
865
+ });
866
+ };
867
+ const BottomContent = _ref2 => {
868
+ let {
869
+ viewingReclamations,
870
+ viewingTijariaHistory,
871
+ activeChat,
872
+ infoMessages,
873
+ incidentMessages,
874
+ setViewingReclamations,
875
+ setViewingTijariaHistory,
876
+ setActiveChat,
877
+ setInfoMessages,
878
+ setIncidentMessages
879
+ } = _ref2;
880
+ const [selectedConversation, setSelectedConversation] = (0, _react.useState)(null);
881
+ if (viewingReclamations) {
882
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ReclamationsList, {
883
+ onClose: () => setViewingReclamations(false)
884
+ });
885
+ }
886
+ if (viewingTijariaHistory) {
887
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TijariaHistory, {
888
+ onClose: () => setViewingTijariaHistory(false),
889
+ setSelectedConversation: setSelectedConversation
890
+ });
891
+ }
892
+ if (activeChat) {
893
+ const messages = activeChat === "info" ? infoMessages : incidentMessages;
894
+ const setMessages = activeChat === "info" ? setInfoMessages : setIncidentMessages;
895
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomChatInterface, {
896
+ type: activeChat,
897
+ onClose: () => setActiveChat(null),
898
+ messages: messages,
899
+ setMessages: setMessages
900
+ });
901
+ }
902
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TijariaChatbot, {
903
+ selectedConversation: selectedConversation
904
+ });
905
+ };
906
+ const CustomChatInterface = _ref3 => {
907
+ let {
908
+ type,
909
+ onClose,
910
+ messages,
911
+ setMessages
912
+ } = _ref3;
913
+ const [inputMessage, setInputMessage] = (0, _react.useState)("");
914
+ const [selectedFile, setSelectedFile] = (0, _react.useState)(null);
915
+ const chatRef = (0, _react.useRef)(null);
916
+ const fileInputRef = (0, _react.useRef)(null);
917
+ const chatConfig = {
918
+ info: {
919
+ title: "Live Support",
920
+ icon: _freeSolidSvgIcons.faHeadset,
921
+ color: "#17a2b8",
922
+ placeholder: "Posez votre question..."
923
+ },
924
+ incident: {
925
+ title: "Signaler un incident",
926
+ icon: _freeSolidSvgIcons.faWarning,
927
+ color: "#E82930",
928
+ placeholder: "Décrivez l'incident..."
929
+ }
930
+ };
931
+ const config = chatConfig[type];
932
+ (0, _react.useEffect)(() => {
933
+ if (chatRef.current) {
934
+ chatRef.current.scrollTop = chatRef.current.scrollHeight;
935
+ }
936
+ }, [messages]);
937
+ const handleSendMessage = () => {
938
+ if (!inputMessage.trim() && !selectedFile) return;
939
+ const newMessage = {
940
+ id: Date.now(),
941
+ sender: "user",
942
+ text: inputMessage,
943
+ file: selectedFile,
944
+ timestamp: new Date()
945
+ };
946
+ setMessages([...messages, newMessage]);
947
+ setInputMessage("");
948
+ setSelectedFile(null);
949
+ setTimeout(() => {
950
+ const responseMessage = {
951
+ id: Date.now() + 1,
952
+ sender: "agent",
953
+ text: type === "info" ? "Merci pour votre question. Notre équipe reviendra vers vous dans les plus brefs délais." : "Votre incident a été enregistré. Nous vous contacterons bientôt pour le suivi.",
954
+ timestamp: new Date()
955
+ };
956
+ setMessages(prev => [...prev, responseMessage]);
957
+ }, 1000);
958
+ };
959
+ const handleFileSelect = e => {
960
+ const file = e.target.files[0];
961
+ if (file) {
962
+ setSelectedFile(file);
963
+ }
964
+ };
965
+ const handleKeyPress = e => {
966
+ if (e.key === "Enter" && !e.shiftKey) {
967
+ e.preventDefault();
968
+ handleSendMessage();
969
+ }
970
+ };
971
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
972
+ style: {
973
+ flex: 1,
974
+ display: "flex",
975
+ flexDirection: "column",
976
+ backgroundColor: "#f5f5f5"
977
+ },
978
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
979
+ style: {
980
+ display: "flex",
981
+ justifyContent: "space-between",
982
+ alignItems: "center",
983
+ padding: "12px 16px",
984
+ backgroundColor: "white",
985
+ borderBottom: "1px solid #e0e0e0"
986
+ },
987
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
988
+ style: {
989
+ display: "flex",
990
+ alignItems: "center",
991
+ gap: "12px",
992
+ paddingTop: 1,
993
+ paddingBottom: 2.5
994
+ }
995
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
996
+ onClick: onClose,
997
+ style: {
998
+ cursor: "pointer",
999
+ color: "#666",
1000
+ padding: "4px",
1001
+ display: "flex",
1002
+ alignItems: "center"
1003
+ },
1004
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1005
+ icon: _freeSolidSvgIcons.faTimes,
1006
+ style: {
1007
+ fontSize: "16px"
1008
+ }
1009
+ })
1010
+ })]
1011
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1012
+ style: {
1013
+ display: "flex",
1014
+ alignItems: "center",
1015
+ gap: "12px",
1016
+ padding: "16px",
1017
+ backgroundColor: "white",
1018
+ borderBottom: "1px solid #e0e0e0"
1019
+ },
1020
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1021
+ style: {
1022
+ width: "40px",
1023
+ height: "40px",
1024
+ borderRadius: "8px",
1025
+ backgroundColor: "#f5f5f5",
1026
+ display: "flex",
1027
+ alignItems: "center",
1028
+ justifyContent: "center"
1029
+ },
1030
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1031
+ icon: config.icon,
1032
+ style: {
1033
+ color: config.color,
1034
+ fontSize: "20px"
1035
+ }
1036
+ })
1037
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1038
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1039
+ style: {
1040
+ fontWeight: "400",
1041
+ color: "#333",
1042
+ fontSize: "16px"
1043
+ },
1044
+ children: config.title
1045
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1046
+ style: {
1047
+ color: "#999",
1048
+ fontSize: "12px"
1049
+ },
1050
+ children: "Support Agent"
1051
+ })]
1052
+ })]
1053
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1054
+ ref: chatRef,
1055
+ style: {
1056
+ flex: 1,
1057
+ overflowY: "auto",
1058
+ padding: "16px",
1059
+ backgroundColor: "#f5f5f5"
1060
+ },
1061
+ children: messages.map(message => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1062
+ style: {
1063
+ display: "flex",
1064
+ flexDirection: "column",
1065
+ alignItems: message.sender === "user" ? "flex-end" : "flex-start",
1066
+ marginBottom: "16px"
1067
+ },
1068
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1069
+ style: {
1070
+ display: "flex",
1071
+ alignItems: "center",
1072
+ gap: "6px",
1073
+ marginBottom: "4px"
1074
+ },
1075
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1076
+ style: {
1077
+ width: "6px",
1078
+ height: "6px",
1079
+ borderRadius: "50%",
1080
+ backgroundColor: message.sender === "user" ? config.color : "#4CAF50"
1081
+ }
1082
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1083
+ style: {
1084
+ color: "#999",
1085
+ fontSize: "11px"
1086
+ },
1087
+ children: [message.sender === "user" ? "Vous" : "Support", " ", message.timestamp.toLocaleTimeString("fr-FR", {
1088
+ hour: "2-digit",
1089
+ minute: "2-digit"
1090
+ })]
1091
+ })]
1092
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1093
+ style: {
1094
+ maxWidth: "75%",
1095
+ padding: "12px 16px",
1096
+ borderRadius: "8px",
1097
+ backgroundColor: message.sender === "user" ? config.color : "white",
1098
+ color: message.sender === "user" ? "white" : "#333",
1099
+ boxShadow: message.sender !== "user" ? "0 1px 3px rgba(0,0,0,0.1)" : "none"
1100
+ },
1101
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1102
+ style: {
1103
+ fontSize: "14px",
1104
+ lineHeight: "1.5",
1105
+ whiteSpace: "pre-wrap",
1106
+ wordBreak: "break-word"
1107
+ },
1108
+ children: message.text
1109
+ }), message.file && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1110
+ style: {
1111
+ marginTop: "8px",
1112
+ padding: "8px",
1113
+ backgroundColor: message.sender === "user" ? "rgba(255,255,255,0.2)" : "#f5f5f5",
1114
+ borderRadius: "4px",
1115
+ fontSize: "12px",
1116
+ display: "flex",
1117
+ alignItems: "center",
1118
+ gap: "6px"
1119
+ },
1120
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1121
+ icon: _freeSolidSvgIcons.faPaperclip
1122
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1123
+ children: message.file.name
1124
+ })]
1125
+ })]
1126
+ }), message.sender === "user" && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1127
+ style: {
1128
+ color: "#999",
1129
+ fontSize: "10px",
1130
+ marginTop: "4px"
1131
+ },
1132
+ children: "Lu"
1133
+ })]
1134
+ }, message.id))
1135
+ }), selectedFile && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1136
+ style: {
1137
+ padding: "8px 16px",
1138
+ backgroundColor: "#fff3cd",
1139
+ borderTop: "1px solid #ffc107",
1140
+ display: "flex",
1141
+ alignItems: "center",
1142
+ justifyContent: "space-between"
1143
+ },
1144
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1145
+ style: {
1146
+ display: "flex",
1147
+ alignItems: "center",
1148
+ gap: "8px",
1149
+ fontSize: "12px"
1150
+ },
1151
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1152
+ icon: _freeSolidSvgIcons.faPaperclip,
1153
+ style: {
1154
+ color: "#856404"
1155
+ }
1156
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1157
+ style: {
1158
+ color: "#856404"
1159
+ },
1160
+ children: selectedFile.name
1161
+ })]
1162
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1163
+ icon: _freeSolidSvgIcons.faTimes,
1164
+ style: {
1165
+ cursor: "pointer",
1166
+ color: "#856404"
1167
+ },
1168
+ onClick: () => setSelectedFile(null)
1169
+ })]
1170
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1171
+ style: {
1172
+ display: "flex",
1173
+ alignItems: "flex-end",
1174
+ gap: "8px",
1175
+ padding: "12px 16px",
1176
+ backgroundColor: "white",
1177
+ borderTop: "1px solid #e0e0e0"
1178
+ },
1179
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Input, {
1180
+ type: "textarea",
1181
+ rows: "1",
1182
+ style: {
1183
+ flex: 1,
1184
+ border: "none",
1185
+ resize: "none",
1186
+ fontSize: "14px",
1187
+ padding: "8px",
1188
+ maxHeight: "100px",
1189
+ overflowY: "auto",
1190
+ outline: "none",
1191
+ boxShadow: "none",
1192
+ fontWeight: "400"
1193
+ },
1194
+ placeholder: config.placeholder,
1195
+ value: inputMessage,
1196
+ onChange: e => setInputMessage(e.target.value),
1197
+ onKeyPress: handleKeyPress
1198
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1199
+ type: "file",
1200
+ ref: fileInputRef,
1201
+ style: {
1202
+ display: "none"
1203
+ },
1204
+ onChange: handleFileSelect
1205
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1206
+ onClick: () => {
1207
+ var _fileInputRef$current;
1208
+ return (_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 ? void 0 : _fileInputRef$current.click();
1209
+ },
1210
+ style: {
1211
+ cursor: "pointer",
1212
+ color: "#999",
1213
+ padding: "8px",
1214
+ display: "flex",
1215
+ alignItems: "center"
1216
+ },
1217
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1218
+ icon: _freeSolidSvgIcons.faPaperclip,
1219
+ style: {
1220
+ fontSize: "18px"
1221
+ }
1222
+ })
1223
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1224
+ onClick: handleSendMessage,
1225
+ style: {
1226
+ cursor: inputMessage.trim() || selectedFile ? "pointer" : "not-allowed",
1227
+ color: inputMessage.trim() || selectedFile ? config.color : "#ccc",
1228
+ padding: "8px",
1229
+ display: "flex",
1230
+ alignItems: "center",
1231
+ transition: "color 0.2s"
1232
+ },
1233
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1234
+ icon: _freeSolidSvgIcons.faPaperPlane,
1235
+ style: {
1236
+ fontSize: "18px"
1237
+ }
1238
+ })
1239
+ })]
1240
+ })]
1241
+ });
1242
+ };
1243
+ const ReclamationFormModal = _ref4 => {
1244
+ let {
1245
+ open,
1246
+ onClose
1247
+ } = _ref4;
1248
+ const [activeStep, setActiveStep] = (0, _react.useState)(0);
1249
+ const [formData, setFormData] = (0, _react.useState)({
1250
+ type: "",
1251
+ service: "",
1252
+ objet: "",
1253
+ sujet: "",
1254
+ files: []
1255
+ });
1256
+ const [submitted, setSubmitted] = (0, _react.useState)(false);
1257
+ const [referenceNumber, setReferenceNumber] = (0, _react.useState)("");
1258
+ const {
1259
+ mutate: createReclamation,
1260
+ isLoading
1261
+ } = (0, _useReclamation.useCreateReclamation)();
1262
+ const {
1263
+ data: listServiceReclamation,
1264
+ isFetching: isFetchingListServiceReclamation
1265
+ } = (0, _useReclamation.useListServiceReclamation)();
1266
+ const [error, setError] = (0, _react.useState)(null);
1267
+ const errorRef = (0, _react.useRef)(null);
1268
+ const CustomPopper = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popper, _objectSpread(_objectSpread({}, props), {}, {
1269
+ placement: "bottom-start",
1270
+ disablePortal: true
1271
+ }));
1272
+ const reclamationTypes = [{
1273
+ codigo: "BESOIN_INFORMATIONS",
1274
+ libelle: "Besoin d'informations"
1275
+ }, {
1276
+ codigo: "RECLAMATION",
1277
+ libelle: "Réclamation"
1278
+ }, {
1279
+ codigo: "SIGNALER_INCIDENT_TECHNIQUE",
1280
+ libelle: "Signaler un incident technique"
1281
+ }];
1282
+ const steps = ["Type de demande", "Service concerné", "Détails"];
1283
+ const ALLOWED_FILE_TYPES = {
1284
+ extensions: ".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.gif",
1285
+ mimeTypes: ["application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "image/jpeg", "image/png", "image/gif"]
1286
+ };
1287
+ (0, _react.useEffect)(() => {
1288
+ if (!open) {
1289
+ setTimeout(() => {
1290
+ setActiveStep(0);
1291
+ setFormData({
1292
+ type: "",
1293
+ service: "",
1294
+ objet: "",
1295
+ sujet: "",
1296
+ files: []
1297
+ });
1298
+ setSubmitted(false);
1299
+ setReferenceNumber("");
1300
+ }, 300);
1301
+ }
1302
+ }, [open]);
1303
+ (0, _react.useEffect)(() => {
1304
+ if (error && errorRef.current) {
1305
+ errorRef.current.scrollIntoView({
1306
+ behavior: "smooth",
1307
+ block: "center"
1308
+ });
1309
+ }
1310
+ }, [error]);
1311
+ const handleNext = () => {
1312
+ setActiveStep(prev => prev + 1);
1313
+ };
1314
+ const handleBack = () => {
1315
+ setActiveStep(prev => prev - 1);
1316
+ };
1317
+ const handleTypeChange = value => {
1318
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1319
+ type: value
1320
+ }));
1321
+ };
1322
+ const handleServiceChange = (event, value) => {
1323
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1324
+ service: value
1325
+ }));
1326
+ };
1327
+ const handleFileSelect = event => {
1328
+ const newFiles = Array.from(event.target.files);
1329
+ const maxSize = 2 * 1024 * 1024;
1330
+ let hasErrors = false;
1331
+ let errorMessages = [];
1332
+ setError(null);
1333
+ const validFiles = newFiles.filter(file => {
1334
+ if (!ALLOWED_FILE_TYPES.mimeTypes.includes(file.type)) {
1335
+ const errorMsg = "".concat(file.name, ": Type de fichier non autoris\xE9.");
1336
+ errorMessages.push(errorMsg);
1337
+ hasErrors = true;
1338
+ return false;
1339
+ }
1340
+ if (file.size > maxSize) {
1341
+ const errorMsg = "".concat(file.name, ": Taille sup\xE9rieure \xE0 2 Mo.");
1342
+ errorMessages.push(errorMsg);
1343
+ hasErrors = true;
1344
+ return false;
1345
+ }
1346
+ return true;
1347
+ });
1348
+ if (hasErrors) {
1349
+ const fullError = errorMessages.join(" ");
1350
+ setError(fullError);
1351
+ _reactToastify.toast.error(fullError);
1352
+ }
1353
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1354
+ files: [...prev.files, ...validFiles]
1355
+ }));
1356
+ };
1357
+ const removeFile = indexToRemove => {
1358
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1359
+ files: prev.files.filter((_, index) => index !== indexToRemove)
1360
+ }));
1361
+ };
1362
+ const handleSubmit = () => {
1363
+ setError(null);
1364
+ createReclamation(formData, {
1365
+ onSuccess: res => {
1366
+ setReferenceNumber(res === null || res === void 0 ? void 0 : res.reference);
1367
+ setSubmitted(true);
1368
+ setError(null);
1369
+ },
1370
+ onError: err => {
1371
+ var _err$response$data$me, _err$response;
1372
+ const errorMessage = (_err$response$data$me = (_err$response = err.response) === null || _err$response === void 0 || (_err$response = _err$response.data) === null || _err$response === void 0 ? void 0 : _err$response.message) !== null && _err$response$data$me !== void 0 ? _err$response$data$me : "Une erreur est survenue, veuillez réessayer plus tard.";
1373
+ setError(errorMessage);
1374
+ _reactToastify.toast.error(errorMessage);
1375
+ }
1376
+ });
1377
+ };
1378
+ const handleClose = () => {
1379
+ setError(null);
1380
+ onClose();
1381
+ };
1382
+ const canProceedStep1 = formData.type !== "";
1383
+ const canProceedStep2 = formData.service !== "";
1384
+ const canSubmit = formData.objet && formData.sujet;
1385
+ const renderStepContent = () => {
1386
+ switch (activeStep) {
1387
+ case 0:
1388
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Fade, {
1389
+ in: true,
1390
+ timeout: 500,
1391
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1392
+ className: "step-content",
1393
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1394
+ variant: "h5",
1395
+ className: "step-title",
1396
+ gutterBottom: true,
1397
+ children: "Quel est le type de votre demande ?"
1398
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1399
+ variant: "body2",
1400
+ color: "text.secondary",
1401
+ sx: {
1402
+ mb: 4
1403
+ },
1404
+ children: "S\xE9lectionnez le type qui correspond le mieux \xE0 votre besoin"
1405
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
1406
+ fullWidth: true,
1407
+ variant: "outlined",
1408
+ className: "type-select",
1409
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
1410
+ id: "type-label",
1411
+ children: "Type de demande"
1412
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
1413
+ labelId: "type-label",
1414
+ value: formData.type,
1415
+ onChange: e => handleTypeChange(e.target.value),
1416
+ label: "Type de demande",
1417
+ children: reclamationTypes.map(type => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
1418
+ value: type.codigo,
1419
+ children: type.libelle
1420
+ }, type.codigo))
1421
+ })]
1422
+ })]
1423
+ })
1424
+ });
1425
+ case 1:
1426
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Fade, {
1427
+ in: true,
1428
+ timeout: 500,
1429
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1430
+ className: "step-content",
1431
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1432
+ variant: "h5",
1433
+ className: "step-title",
1434
+ gutterBottom: true,
1435
+ children: "Quel service est concern\xE9 ?"
1436
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1437
+ variant: "body2",
1438
+ color: "text.secondary",
1439
+ sx: {
1440
+ mb: formData.type === "Besoin d'informations" ? 3 : 4
1441
+ },
1442
+ children: "Recherchez et s\xE9lectionnez le service appropri\xE9"
1443
+ }), formData.type === "Besoin d'informations" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Alert, {
1444
+ severity: "Besoin d'informations",
1445
+ icon: false,
1446
+ sx: {
1447
+ mb: 3,
1448
+ pt: 1,
1449
+ pb: 1,
1450
+ borderRadius: 2,
1451
+ backgroundColor: "#f5f9ff",
1452
+ border: "1px solid #90caf9",
1453
+ display: "flex",
1454
+ flexDirection: "column",
1455
+ maxWidth: 400,
1456
+ mx: "auto"
1457
+ },
1458
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.AlertTitle, {
1459
+ sx: {
1460
+ fontWeight: 600
1461
+ },
1462
+ children: "Besoin d'aide imm\xE9diate ?"
1463
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1464
+ variant: "body2",
1465
+ sx: {
1466
+ mt: 0.5,
1467
+ textAlign: "center"
1468
+ },
1469
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
1470
+ children: "Assistance t\xE9l\xE9phonique: "
1471
+ }), " \uD83D\uDCDE +212 520 47 31 00"]
1472
+ })]
1473
+ }), formData.type === "Besoin d'informations" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1474
+ sx: {
1475
+ mt: 3
1476
+ }
1477
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, {
1478
+ options: listServiceReclamation || [],
1479
+ loading: isFetchingListServiceReclamation,
1480
+ value: formData.service || "",
1481
+ onChange: handleServiceChange,
1482
+ getOptionLabel: option => (option === null || option === void 0 ? void 0 : option.libelle) || "",
1483
+ renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, params), {}, {
1484
+ label: "Rechercher un service",
1485
+ placeholder: "Commencez \xE0 taper...",
1486
+ variant: "outlined",
1487
+ fullWidth: true
1488
+ })),
1489
+ renderOption: (props, option) => /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, props), {}, {
1490
+ className: "service-option",
1491
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1492
+ display: "flex",
1493
+ alignItems: "center",
1494
+ gap: 1,
1495
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1496
+ className: "service-bullet"
1497
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1498
+ children: option === null || option === void 0 ? void 0 : option.libelle
1499
+ })]
1500
+ })
1501
+ })),
1502
+ PopperComponent: CustomPopper // 👈 forces it to stay inside modal
1503
+ ,
1504
+ noOptionsText: "Aucun service trouv\xE9",
1505
+ className: "service-autocomplete"
1506
+ })]
1507
+ })
1508
+ });
1509
+ case 2:
1510
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Fade, {
1511
+ in: true,
1512
+ timeout: 500,
1513
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1514
+ className: "step-content details-step",
1515
+ children: [error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
1516
+ ref: errorRef,
1517
+ severity: "error",
1518
+ onClose: () => setError(null),
1519
+ style: {
1520
+ marginBottom: "15px",
1521
+ maxWidth: 400,
1522
+ marginLeft: "auto",
1523
+ marginRight: "auto"
1524
+ },
1525
+ children: error
1526
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1527
+ variant: "h5",
1528
+ className: "step-title",
1529
+ gutterBottom: true,
1530
+ children: "Compl\xE9tez votre demande"
1531
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1532
+ variant: "body2",
1533
+ color: "text.secondary",
1534
+ sx: {
1535
+ mb: 4
1536
+ },
1537
+ children: "Fournissez les d\xE9tails n\xE9cessaires pour traiter votre demande"
1538
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1539
+ className: "form-fields",
1540
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
1541
+ fullWidth: true,
1542
+ required: true,
1543
+ label: "Objet",
1544
+ placeholder: "R\xE9sum\xE9 de votre demande",
1545
+ value: formData.objet,
1546
+ onChange: e => setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1547
+ objet: e.target.value
1548
+ })),
1549
+ variant: "outlined",
1550
+ className: "form-field"
1551
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
1552
+ fullWidth: true,
1553
+ required: true,
1554
+ label: "Sujet",
1555
+ placeholder: "D\xE9crivez en d\xE9tail votre demande...",
1556
+ value: formData.sujet,
1557
+ onChange: e => setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1558
+ sujet: e.target.value
1559
+ })),
1560
+ variant: "outlined",
1561
+ multiline: true,
1562
+ rows: 6,
1563
+ className: "form-field",
1564
+ inputProps: {
1565
+ maxLength: 500
1566
+ }
1567
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1568
+ className: "file-upload-section",
1569
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1570
+ type: "file",
1571
+ id: "file-upload",
1572
+ accept: ALLOWED_FILE_TYPES.extensions,
1573
+ hidden: true,
1574
+ multiple: true,
1575
+ onChange: handleFileSelect
1576
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
1577
+ htmlFor: "file-upload",
1578
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1579
+ variant: "outlined",
1580
+ component: "span",
1581
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.CloudUpload, {}),
1582
+ className: "upload-button",
1583
+ fullWidth: true,
1584
+ children: "Joindre des fichiers (optionnel)"
1585
+ })
1586
+ }), formData.files.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1587
+ sx: {
1588
+ mt: 2,
1589
+ display: "flex",
1590
+ flexWrap: "wrap",
1591
+ gap: 1
1592
+ },
1593
+ children: formData.files.map((file, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
1594
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.AttachFile, {}),
1595
+ label: file.name,
1596
+ onDelete: () => removeFile(index),
1597
+ className: "file-chip",
1598
+ color: "primary",
1599
+ variant: "outlined"
1600
+ }, index))
1601
+ })]
1602
+ })]
1603
+ })]
1604
+ })
1605
+ });
1606
+ default:
1607
+ return null;
1608
+ }
1609
+ };
1610
+ if (submitted) {
1611
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Dialog, {
1612
+ open: open,
1613
+ onClose: handleClose,
1614
+ maxWidth: "sm",
1615
+ fullWidth: true,
1616
+ className: "reclamation-modal success-modal",
1617
+ PaperProps: {
1618
+ className: "modal-paper"
1619
+ },
1620
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContent, {
1621
+ className: "success-content",
1622
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Zoom, {
1623
+ in: true,
1624
+ timeout: 500,
1625
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1626
+ className: "success-container",
1627
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.CheckCircle, {
1628
+ className: "success-icon"
1629
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1630
+ variant: "h5",
1631
+ className: "success-title",
1632
+ gutterBottom: true,
1633
+ children: "Demande enregistr\xE9e !"
1634
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1635
+ variant: "body1",
1636
+ color: "text.secondary",
1637
+ sx: {
1638
+ mb: 3
1639
+ },
1640
+ children: "Votre demande a \xE9t\xE9 prise en charge avec succ\xE8s"
1641
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Paper, {
1642
+ elevation: 3,
1643
+ className: "reference-box",
1644
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1645
+ variant: "h5",
1646
+ className: "reference-number",
1647
+ children: referenceNumber
1648
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1649
+ variant: "caption",
1650
+ color: "text.secondary",
1651
+ sx: {
1652
+ mt: 1,
1653
+ display: "block"
1654
+ },
1655
+ children: "Conservez ce num\xE9ro pour suivre votre demande"
1656
+ })]
1657
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1658
+ variant: "contained",
1659
+ onClick: handleClose,
1660
+ size: "large",
1661
+ className: "close-success-button",
1662
+ fullWidth: true,
1663
+ children: "Fermer"
1664
+ })]
1665
+ })
1666
+ })
1667
+ })
1668
+ });
1669
+ }
1670
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
1671
+ open: open,
1672
+ onClose: handleClose,
1673
+ maxWidth: "md",
1674
+ fullWidth: true,
1675
+ scroll: "body",
1676
+ className: "reclamation-modal",
1677
+ PaperProps: {
1678
+ className: "modal-paper"
1679
+ },
1680
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1681
+ className: "modal-header",
1682
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1683
+ display: "flex",
1684
+ alignItems: "center",
1685
+ gap: 2,
1686
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1687
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1688
+ variant: "h6",
1689
+ className: "header-title",
1690
+ children: "Nouvelle r\xE9clamation"
1691
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1692
+ variant: "caption",
1693
+ color: "white",
1694
+ children: ["Remplissez ce formulaire en ", steps.length, " \xE9tapes"]
1695
+ })]
1696
+ })
1697
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
1698
+ onClick: handleClose,
1699
+ className: "close-button",
1700
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Close, {})
1701
+ })]
1702
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1703
+ className: "progress-section",
1704
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
1705
+ variant: "determinate",
1706
+ value: activeStep / (steps.length - 1) * 100,
1707
+ className: "progress-bar"
1708
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Stepper, {
1709
+ activeStep: activeStep,
1710
+ className: "stepper",
1711
+ children: steps.map(label => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Step, {
1712
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StepLabel, {
1713
+ children: label
1714
+ })
1715
+ }, label))
1716
+ })]
1717
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContent, {
1718
+ className: "modal-content",
1719
+ children: renderStepContent()
1720
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1721
+ className: "modal-footer",
1722
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1723
+ onClick: handleBack,
1724
+ disabled: activeStep === 0,
1725
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowBack, {}),
1726
+ className: "back-button",
1727
+ children: "Retour"
1728
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1729
+ flex: 1
1730
+ }), activeStep < steps.length - 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1731
+ variant: "contained",
1732
+ onClick: handleNext,
1733
+ endIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowForward, {}),
1734
+ disabled: activeStep === 0 && !canProceedStep1 || activeStep === 1 && !canProceedStep2,
1735
+ className: "next-button",
1736
+ children: "Suivant"
1737
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1738
+ variant: "contained",
1739
+ onClick: handleSubmit,
1740
+ disabled: !canSubmit || isLoading,
1741
+ className: "submit-button",
1742
+ startIcon: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
1743
+ size: 16,
1744
+ sx: {
1745
+ color: "var(--primary-color, #222f67)"
1746
+ }
1747
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.CheckCircle, {}),
1748
+ children: isLoading ? "Envoi en cours..." : "Soumettre"
1749
+ })]
1750
+ })]
1751
+ });
1752
+ };
1753
+ const ReclamationsList = _ref5 => {
1754
+ var _selectedReclamation$, _selectedReclamation$2;
1755
+ let {
1756
+ onClose
1757
+ } = _ref5;
1758
+ const queryClient = (0, _reactQuery.useQueryClient)();
1759
+ const [selectedReclamation, setSelectedReclamation] = (0, _react.useState)(null);
1760
+ const [detailsDialogOpen, setDetailsDialogOpen] = (0, _react.useState)(false);
1761
+ const [page, setPage] = (0, _react.useState)(1);
1762
+ const [search, setSearch] = (0, _react.useState)();
1763
+ const [searchKey, setSearchKey] = (0, _react.useState)("");
1764
+ const {
1765
+ data: reclamations,
1766
+ isFetching,
1767
+ error
1768
+ } = (0, _useReclamation.useListReclamation)(page);
1769
+ const {
1770
+ mutate: downloadDocument,
1771
+ isLoading: isDownloading,
1772
+ error: errorDownloadDocument
1773
+ } = (0, _useReclamation.useDownloadDocument)();
1774
+ const getStatusColor = statut => {
1775
+ switch (statut.toLowerCase()) {
1776
+ case "traité":
1777
+ return "#4CAF50";
1778
+ case "en cours":
1779
+ return "#FF9800";
1780
+ case "en attente":
1781
+ return "#2196F3";
1782
+ default:
1783
+ return "#757575";
1784
+ }
1785
+ };
1786
+ const handleReclamationClick = reclamation => {
1787
+ setSelectedReclamation(reclamation);
1788
+ setDetailsDialogOpen(true);
1789
+ };
1790
+ const handleCloseDetails = () => {
1791
+ setDetailsDialogOpen(false);
1792
+ setSelectedReclamation(null);
1793
+ };
1794
+ const formatDate = dateString => {
1795
+ const date = new Date(dateString);
1796
+ return date.toLocaleDateString("fr-FR", {
1797
+ day: "2-digit",
1798
+ month: "2-digit",
1799
+ year: "numeric",
1800
+ hour: "2-digit",
1801
+ minute: "2-digit"
1802
+ });
1803
+ };
1804
+ const handleDownload = (documentGuid, documentName) => {
1805
+ downloadDocument(documentGuid, {
1806
+ onSuccess: res => {
1807
+ if (!(res !== null && res !== void 0 && res.data) || !(res !== null && res !== void 0 && res.fileName)) {
1808
+ console.error("No file data or filename received");
1809
+ return;
1810
+ }
1811
+ const byteCharacters = atob(res.data);
1812
+ const byteNumbers = new Array(byteCharacters.length);
1813
+ for (let i = 0; i < byteCharacters.length; i++) {
1814
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
1815
+ }
1816
+ const byteArray = new Uint8Array(byteNumbers);
1817
+ const blob = new Blob([byteArray], {
1818
+ type: "application/octet-stream"
1819
+ });
1820
+ const link = document.createElement("a");
1821
+ link.href = URL.createObjectURL(blob);
1822
+ link.download = documentName;
1823
+ document.body.appendChild(link);
1824
+ link.click();
1825
+ document.body.removeChild(link);
1826
+ URL.revokeObjectURL(link.href);
1827
+ },
1828
+ onError: err => {
1829
+ console.error("Error downloading document:", err);
1830
+ }
1831
+ });
1832
+ };
1833
+ const onSearch = () => {
1834
+ setSearchKey(search);
1835
+ };
1836
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1837
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1838
+ style: {
1839
+ flex: 1,
1840
+ display: "flex",
1841
+ flexDirection: "column",
1842
+ backgroundColor: "#f5f5f5"
1843
+ },
1844
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1845
+ style: {
1846
+ display: "flex",
1847
+ justifyContent: "space-between",
1848
+ alignItems: "center",
1849
+ padding: "16px",
1850
+ backgroundColor: "white",
1851
+ borderBottom: "1px solid #e0e0e0"
1852
+ },
1853
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1854
+ style: {
1855
+ display: "flex",
1856
+ alignItems: "center",
1857
+ gap: "12px"
1858
+ },
1859
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1860
+ icon: _freeSolidSvgIcons.faClipboardList,
1861
+ style: {
1862
+ color: "var(--primary-color, #222f67)",
1863
+ fontSize: "20px"
1864
+ }
1865
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1866
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1867
+ component: "div",
1868
+ sx: {
1869
+ fontWeight: "600",
1870
+ color: "#333",
1871
+ fontSize: "16px",
1872
+ fontFamily: WIDGET_FONT,
1873
+ margin: 0,
1874
+ lineHeight: "normal"
1875
+ },
1876
+ children: "Mes r\xE9clamations"
1877
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1878
+ component: "div",
1879
+ sx: {
1880
+ color: "#999",
1881
+ fontSize: "12px",
1882
+ fontFamily: WIDGET_FONT,
1883
+ margin: 0,
1884
+ lineHeight: "normal"
1885
+ },
1886
+ children: [(reclamations === null || reclamations === void 0 ? void 0 : reclamations.totalElements) || 0, " r\xE9clamation(s)"]
1887
+ })]
1888
+ })]
1889
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1890
+ onClick: onClose,
1891
+ style: {
1892
+ cursor: "pointer",
1893
+ color: "#666",
1894
+ padding: "4px",
1895
+ display: "flex",
1896
+ alignItems: "center"
1897
+ },
1898
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1899
+ icon: _freeSolidSvgIcons.faTimes,
1900
+ style: {
1901
+ fontSize: "16px"
1902
+ }
1903
+ })
1904
+ })]
1905
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1906
+ className: "search-fields",
1907
+ style: {
1908
+ display: "flex",
1909
+ justifyContent: "center",
1910
+ padding: "12px",
1911
+ paddingBottom: "0px"
1912
+ },
1913
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
1914
+ placeholder: "R\xE9clamation / R\xE9f\xE9rence",
1915
+ variant: "outlined",
1916
+ size: "small",
1917
+ value: search,
1918
+ onChange: e => setSearch(e.target.value),
1919
+ fullWidth: true,
1920
+ InputLabelProps: {
1921
+ style: {
1922
+ fontSize: 12
1923
+ }
1924
+ },
1925
+ sx: {
1926
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": {
1927
+ borderColor: "var(--primary-color, #222f67)"
1928
+ }
1929
+ }
1930
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
1931
+ onClick: onSearch,
1932
+ variant: "contained",
1933
+ sx: {
1934
+ minWidth: "48px",
1935
+ width: "48px",
1936
+ height: "40px",
1937
+ borderRadius: "5px",
1938
+ backgroundColor: "var(--primary-color, #222f67)",
1939
+ "&:hover": {
1940
+ backgroundColor: "var(--primary-color, #222f67)",
1941
+ opacity: 0.9
1942
+ },
1943
+ flexShrink: 0,
1944
+ marginLeft: "0px",
1945
+ boxShadow: "none",
1946
+ padding: 0
1947
+ },
1948
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Search, {
1949
+ sx: {
1950
+ color: "white",
1951
+ fontSize: "25px"
1952
+ }
1953
+ })
1954
+ })]
1955
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1956
+ style: {
1957
+ flex: 1,
1958
+ overflowY: "auto",
1959
+ padding: "8px"
1960
+ },
1961
+ children: isFetching ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1962
+ style: {
1963
+ display: "flex",
1964
+ justifyContent: "center",
1965
+ padding: "24px"
1966
+ },
1967
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
1968
+ size: 32,
1969
+ sx: {
1970
+ color: "var(--primary-color, #222f67)"
1971
+ }
1972
+ })
1973
+ }) : (reclamations === null || reclamations === void 0 ? void 0 : reclamations.totalElements) === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1974
+ style: {
1975
+ display: "flex",
1976
+ flexDirection: "column",
1977
+ alignItems: "center",
1978
+ justifyContent: "center",
1979
+ padding: "40px 20px",
1980
+ color: "#999"
1981
+ },
1982
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
1983
+ icon: _freeSolidSvgIcons.faClipboardList,
1984
+ style: {
1985
+ fontSize: "48px",
1986
+ marginBottom: "32px"
1987
+ }
1988
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1989
+ component: "div",
1990
+ sx: {
1991
+ fontSize: "14px",
1992
+ textAlign: "center",
1993
+ fontFamily: WIDGET_FONT,
1994
+ lineHeight: "normal",
1995
+ color: "#999"
1996
+ },
1997
+ children: "Aucune r\xE9clamation trouv\xE9e"
1998
+ })]
1999
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2000
+ children: [((reclamations === null || reclamations === void 0 ? void 0 : reclamations.content) || []).map(reclamation => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2001
+ onClick: () => handleReclamationClick(reclamation),
2002
+ style: {
2003
+ backgroundColor: "white",
2004
+ borderRadius: "8px",
2005
+ padding: "16px",
2006
+ marginBottom: "5px",
2007
+ cursor: "pointer",
2008
+ boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
2009
+ transition: "all 0.2s ease",
2010
+ border: "1px solid #e0e0e0"
2011
+ },
2012
+ onMouseEnter: e => {
2013
+ e.currentTarget.style.boxShadow = "0 4px 8px rgba(0,0,0,0.15)";
2014
+ e.currentTarget.style.transform = "translateY(-2px)";
2015
+ },
2016
+ onMouseLeave: e => {
2017
+ e.currentTarget.style.boxShadow = "0 1px 3px rgba(0,0,0,0.1)";
2018
+ e.currentTarget.style.transform = "translateY(0)";
2019
+ },
2020
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2021
+ style: {
2022
+ display: "flex",
2023
+ justifyContent: "space-between",
2024
+ alignItems: "center",
2025
+ marginBottom: "12px"
2026
+ },
2027
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2028
+ component: "div",
2029
+ sx: {
2030
+ fontWeight: "600",
2031
+ color: "var(--primary-color, #222f67)",
2032
+ fontSize: "14px",
2033
+ fontFamily: WIDGET_FONT,
2034
+ lineHeight: "normal"
2035
+ },
2036
+ children: reclamation === null || reclamation === void 0 ? void 0 : reclamation.reference
2037
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2038
+ component: "div",
2039
+ sx: {
2040
+ padding: "4px 12px",
2041
+ borderRadius: "12px",
2042
+ backgroundColor: getStatusColor(reclamation === null || reclamation === void 0 ? void 0 : reclamation.statut) + "20",
2043
+ color: getStatusColor(reclamation === null || reclamation === void 0 ? void 0 : reclamation.statut),
2044
+ fontSize: "11px",
2045
+ fontWeight: "600",
2046
+ fontFamily: WIDGET_FONT,
2047
+ lineHeight: "normal"
2048
+ },
2049
+ children: reclamation === null || reclamation === void 0 ? void 0 : reclamation.statut
2050
+ })]
2051
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2052
+ component: "div",
2053
+ sx: {
2054
+ fontWeight: "500",
2055
+ color: "#333",
2056
+ fontSize: "13px",
2057
+ marginBottom: "8px",
2058
+ fontFamily: WIDGET_FONT,
2059
+ lineHeight: "normal"
2060
+ },
2061
+ children: reclamation === null || reclamation === void 0 ? void 0 : reclamation.objet
2062
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2063
+ style: {
2064
+ display: "flex",
2065
+ justifyContent: "space-between",
2066
+ alignItems: "center"
2067
+ },
2068
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2069
+ component: "div",
2070
+ sx: {
2071
+ color: "#999",
2072
+ fontSize: "11px",
2073
+ fontFamily: WIDGET_FONT,
2074
+ lineHeight: "normal"
2075
+ },
2076
+ children: formatDate(reclamation === null || reclamation === void 0 ? void 0 : reclamation.dateCreation)
2077
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
2078
+ component: "div",
2079
+ sx: {
2080
+ display: "flex",
2081
+ alignItems: "center",
2082
+ gap: "4px",
2083
+ color: "var(--primary-color, #222f67)",
2084
+ fontSize: "11px",
2085
+ fontWeight: "500",
2086
+ fontFamily: WIDGET_FONT,
2087
+ lineHeight: "normal"
2088
+ },
2089
+ children: ["Voir d\xE9tails", /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2090
+ icon: _freeSolidSvgIcons.faEye
2091
+ })]
2092
+ })]
2093
+ })]
2094
+ }, reclamation === null || reclamation === void 0 ? void 0 : reclamation.id)), (reclamations === null || reclamations === void 0 ? void 0 : reclamations.totalPages) > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2095
+ style: {
2096
+ display: "flex",
2097
+ justifyContent: "center",
2098
+ marginTop: "8px",
2099
+ marginBottom: "8px"
2100
+ },
2101
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Pagination, {
2102
+ size: "small",
2103
+ variant: "outlined",
2104
+ count: (reclamations === null || reclamations === void 0 ? void 0 : reclamations.totalPages) || 0,
2105
+ page: page,
2106
+ onChange: (event, value) => setPage(value)
2107
+ })
2108
+ })]
2109
+ })
2110
+ })]
2111
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
2112
+ open: detailsDialogOpen,
2113
+ onClose: handleCloseDetails,
2114
+ maxWidth: "sm",
2115
+ fullWidth: true,
2116
+ PaperProps: {
2117
+ sx: {
2118
+ borderRadius: 3,
2119
+ boxShadow: "0 8px 32px rgba(0,0,0,0.12)"
2120
+ }
2121
+ },
2122
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.DialogTitle, {
2123
+ sx: {
2124
+ backgroundColor: "#f8f9fa",
2125
+ borderBottom: "1px solid #e0e0e0",
2126
+ display: "flex",
2127
+ justifyContent: "space-between",
2128
+ alignItems: "center",
2129
+ padding: "20px 24px"
2130
+ },
2131
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2132
+ style: {
2133
+ display: "flex",
2134
+ alignItems: "center",
2135
+ gap: "12px"
2136
+ },
2137
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2138
+ icon: _freeSolidSvgIcons.faInfoCircle,
2139
+ style: {
2140
+ color: "var(--primary-color, #222f67)",
2141
+ fontSize: "20px"
2142
+ }
2143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2144
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2145
+ component: "div",
2146
+ sx: {
2147
+ fontWeight: "700",
2148
+ fontSize: "16px",
2149
+ margin: 0
2150
+ },
2151
+ children: "D\xE9tails de la r\xE9clamation"
2152
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2153
+ component: "div",
2154
+ sx: {
2155
+ color: "#666",
2156
+ fontSize: "12px",
2157
+ marginTop: "3px"
2158
+ },
2159
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.reference
2160
+ })]
2161
+ })]
2162
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
2163
+ label: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.statut,
2164
+ size: "small",
2165
+ sx: {
2166
+ backgroundColor: getStatusColor((selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.statut) || "") + "20",
2167
+ color: getStatusColor((selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.statut) || ""),
2168
+ fontWeight: 600,
2169
+ fontSize: "11px"
2170
+ }
2171
+ })]
2172
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContent, {
2173
+ sx: {
2174
+ padding: "24px"
2175
+ },
2176
+ children: selectedReclamation && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2177
+ style: {
2178
+ display: "flex",
2179
+ flexDirection: "column",
2180
+ gap: "20px"
2181
+ },
2182
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2183
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2184
+ component: "div",
2185
+ sx: {
2186
+ fontSize: "11px",
2187
+ color: "#999",
2188
+ fontWeight: "500",
2189
+ marginBottom: "6px",
2190
+ textTransform: "uppercase",
2191
+ letterSpacing: "0.5px",
2192
+ fontWeight: "500",
2193
+ fontFamily: WIDGET_FONT
2194
+ },
2195
+ children: "Type de demande"
2196
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2197
+ component: "div",
2198
+ sx: {
2199
+ fontSize: "14px",
2200
+ color: "#333",
2201
+ fontWeight: "500",
2202
+ fontFamily: WIDGET_FONT
2203
+ },
2204
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.type
2205
+ })]
2206
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2207
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2208
+ component: "div",
2209
+ sx: {
2210
+ fontSize: "11px",
2211
+ color: "#999",
2212
+ fontWeight: "500",
2213
+ marginBottom: "6px",
2214
+ textTransform: "uppercase",
2215
+ letterSpacing: "0.5px",
2216
+ fontFamily: WIDGET_FONT
2217
+ },
2218
+ children: "Service concern\xE9"
2219
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2220
+ component: "div",
2221
+ sx: {
2222
+ fontSize: "14px",
2223
+ color: "#333",
2224
+ fontWeight: "500",
2225
+ fontFamily: WIDGET_FONT
2226
+ },
2227
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.service
2228
+ })]
2229
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2230
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2231
+ component: "div",
2232
+ sx: {
2233
+ fontSize: "11px",
2234
+ color: "#999",
2235
+ fontWeight: "500",
2236
+ marginBottom: "6px",
2237
+ textTransform: "uppercase",
2238
+ letterSpacing: "0.5px",
2239
+ fontFamily: WIDGET_FONT
2240
+ },
2241
+ children: "R\xE9f\xE9rence"
2242
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2243
+ component: "div",
2244
+ sx: {
2245
+ fontSize: "14px",
2246
+ color: "#333",
2247
+ fontWeight: "500",
2248
+ fontFamily: WIDGET_FONT
2249
+ },
2250
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.reference
2251
+ })]
2252
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2253
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2254
+ component: "div",
2255
+ sx: {
2256
+ fontSize: "11px",
2257
+ color: "#999",
2258
+ fontWeight: "500",
2259
+ marginBottom: "6px",
2260
+ textTransform: "uppercase",
2261
+ letterSpacing: "0.5px",
2262
+ fontFamily: WIDGET_FONT
2263
+ },
2264
+ children: "Objet"
2265
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2266
+ component: "div",
2267
+ sx: {
2268
+ fontSize: "14px",
2269
+ color: "#333",
2270
+ fontWeight: "500",
2271
+ fontFamily: WIDGET_FONT
2272
+ },
2273
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.objet
2274
+ })]
2275
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2276
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2277
+ component: "div",
2278
+ sx: {
2279
+ fontSize: "11px",
2280
+ color: "#999",
2281
+ fontWeight: "500",
2282
+ marginBottom: "6px",
2283
+ textTransform: "uppercase",
2284
+ letterSpacing: "0.5px",
2285
+ fontFamily: WIDGET_FONT
2286
+ },
2287
+ children: "Description"
2288
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2289
+ component: "div",
2290
+ sx: {
2291
+ fontSize: "14px",
2292
+ color: "#333",
2293
+ lineHeight: "1.6",
2294
+ backgroundColor: "#f8f9fa",
2295
+ padding: "12px",
2296
+ borderRadius: "8px",
2297
+ border: "1px solid #e0e0e0",
2298
+ whiteSpace: "pre-line",
2299
+ fontFamily: WIDGET_FONT
2300
+ },
2301
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.description
2302
+ })]
2303
+ }), (selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.response) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2304
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
2305
+ component: "div",
2306
+ sx: {
2307
+ fontSize: "11px",
2308
+ color: "#999",
2309
+ fontWeight: "500",
2310
+ marginBottom: "6px",
2311
+ textTransform: "uppercase",
2312
+ letterSpacing: "0.5px",
2313
+ fontFamily: WIDGET_FONT,
2314
+ display: "flex",
2315
+ alignItems: "center",
2316
+ gap: "6px"
2317
+ },
2318
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2319
+ icon: _freeSolidSvgIcons.faReply,
2320
+ style: {
2321
+ color: "#6c757d",
2322
+ fontSize: "12px"
2323
+ }
2324
+ }), "R\xE9ponse"]
2325
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2326
+ style: {
2327
+ fontSize: "14px",
2328
+ color: "#333",
2329
+ lineHeight: "1.6",
2330
+ backgroundColor: "#f5f6f7",
2331
+ padding: "12px",
2332
+ borderRadius: "8px",
2333
+ border: "2px solid #6c757d",
2334
+ whiteSpace: "pre-line"
2335
+ },
2336
+ children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.response
2337
+ })]
2338
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2339
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2340
+ component: "div",
2341
+ sx: {
2342
+ fontSize: "11px",
2343
+ color: "#999",
2344
+ fontWeight: "500",
2345
+ marginBottom: "6px",
2346
+ textTransform: "uppercase",
2347
+ letterSpacing: "0.5px",
2348
+ fontFamily: WIDGET_FONT
2349
+ },
2350
+ children: "Date de cr\xE9ation"
2351
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2352
+ component: "div",
2353
+ sx: {
2354
+ fontSize: "14px",
2355
+ color: "#333",
2356
+ fontWeight: "500",
2357
+ fontFamily: WIDGET_FONT
2358
+ },
2359
+ children: formatDate(selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.dateCreation)
2360
+ })]
2361
+ }), (selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.documents) && (selectedReclamation === null || selectedReclamation === void 0 || (_selectedReclamation$ = selectedReclamation.documents) === null || _selectedReclamation$ === void 0 ? void 0 : _selectedReclamation$.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2362
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
2363
+ component: "div",
2364
+ sx: {
2365
+ fontSize: "11px",
2366
+ color: "#999",
2367
+ fontWeight: "500",
2368
+ marginBottom: "12px",
2369
+ textTransform: "uppercase",
2370
+ letterSpacing: "0.5px",
2371
+ fontFamily: WIDGET_FONT
2372
+ },
2373
+ children: ["Pi\xE8ces jointes (", selectedReclamation === null || selectedReclamation === void 0 || (_selectedReclamation$2 = selectedReclamation.documents) === null || _selectedReclamation$2 === void 0 ? void 0 : _selectedReclamation$2.length, ")"]
2374
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2375
+ style: {
2376
+ display: "flex",
2377
+ flexDirection: "column",
2378
+ gap: "8px"
2379
+ },
2380
+ children: selectedReclamation.documents.map((document, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2381
+ style: {
2382
+ display: "flex",
2383
+ alignItems: "center",
2384
+ gap: "12px",
2385
+ padding: "12px",
2386
+ backgroundColor: "#f8f9fa",
2387
+ borderRadius: "8px",
2388
+ border: "1px solid #e0e0e0",
2389
+ cursor: isDownloading ? "not-allowed" : "pointer",
2390
+ opacity: isDownloading ? 0.6 : 1,
2391
+ transition: "all 0.2s ease"
2392
+ },
2393
+ onClick: () => !isDownloading && handleDownload(document.documentGuid, document.documentName),
2394
+ onMouseEnter: e => {
2395
+ if (!isDownloading) {
2396
+ e.currentTarget.style.backgroundColor = "#e9ecef";
2397
+ e.currentTarget.style.borderColor = "var(--primary-color, #222f67)";
2398
+ }
2399
+ },
2400
+ onMouseLeave: e => {
2401
+ if (!isDownloading) {
2402
+ e.currentTarget.style.backgroundColor = "#f8f9fa";
2403
+ e.currentTarget.style.borderColor = "#e0e0e0";
2404
+ }
2405
+ },
2406
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2407
+ icon: _freeSolidSvgIcons.faPaperclip,
2408
+ style: {
2409
+ color: "var(--primary-color, #222f67)",
2410
+ fontSize: "16px"
2411
+ }
2412
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2413
+ style: {
2414
+ flex: 1
2415
+ },
2416
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2417
+ component: "div",
2418
+ sx: {
2419
+ fontSize: "13px",
2420
+ color: "#333",
2421
+ fontWeight: "500",
2422
+ fontFamily: WIDGET_FONT
2423
+ },
2424
+ children: document.documentName
2425
+ }), document.dateUpload && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
2426
+ component: "div",
2427
+ sx: {
2428
+ fontSize: "11px",
2429
+ color: "#999",
2430
+ marginTop: "2px",
2431
+ fontFamily: WIDGET_FONT
2432
+ },
2433
+ children: ["Ajout\xE9 le ", formatDate(document.dateUpload)]
2434
+ })]
2435
+ }), isDownloading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
2436
+ size: 16,
2437
+ style: {
2438
+ color: "var(--primary-color, #222f67)"
2439
+ }
2440
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2441
+ icon: _freeSolidSvgIcons.faDownload,
2442
+ style: {
2443
+ color: "var(--primary-color, #222f67)",
2444
+ fontSize: "14px"
2445
+ }
2446
+ })]
2447
+ }, document.id || index))
2448
+ })]
2449
+ })]
2450
+ })
2451
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogActions, {
2452
+ sx: {
2453
+ padding: "16px 24px",
2454
+ borderTop: "1px solid #e0e0e0",
2455
+ backgroundColor: "#f8f9fa"
2456
+ },
2457
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
2458
+ onClick: handleCloseDetails,
2459
+ variant: "contained",
2460
+ sx: {
2461
+ backgroundColor: "var(--primary-color, #222f67)",
2462
+ color: "white",
2463
+ padding: "5.5px 23px",
2464
+ borderRadius: "6px",
2465
+ fontWeight: "500",
2466
+ fontSize: "14px",
2467
+ fontFamily: WIDGET_FONT,
2468
+ textTransform: "none",
2469
+ boxShadow: "none",
2470
+ "&:hover": {
2471
+ backgroundColor: "var(--secondary-color, #2d3d7f)",
2472
+ boxShadow: "none"
2473
+ }
2474
+ },
2475
+ children: "Fermer"
2476
+ })
2477
+ })]
2478
+ })]
2479
+ });
2480
+ };
2481
+ const TijariaChatbot = selectedConversation => {
2482
+ const {
2483
+ tijariaUrl,
2484
+ apiAuthUrl,
2485
+ token
2486
+ } = (0, _PuiHelpWidgetContext.useHelpWidget)();
2487
+ const iframeRef = (0, _react.useRef)(null);
2488
+ (0, _react.useEffect)(() => {
2489
+ const handleMessage = event => {
2490
+ if (event.origin !== tijariaUrl) {
2491
+ console.warn("Message from unauthorized origin:", event.origin);
2492
+ return;
2493
+ }
2494
+ if (event.data && event.data.type === "TOKEN_RECEIVED") {
2495
+ console.log("Token delivery confirmed by iframe:", event.data);
2496
+ sessionStorage.setItem("tijaria_token", event.data.token);
2497
+ }
2498
+ };
2499
+ window.addEventListener("message", handleMessage);
2500
+ return () => window.removeEventListener("message", handleMessage);
2501
+ }, []);
2502
+ (0, _react.useEffect)(() => {
2503
+ const iframe = iframeRef.current;
2504
+ const handleLoad = () => {
2505
+ iframe.contentWindow.postMessage({
2506
+ type: "SET_TOKEN",
2507
+ token: token,
2508
+ userInfoApi: "".concat(apiAuthUrl, "/auth/keycloak/user-profile")
2509
+ }, tijariaUrl);
2510
+ };
2511
+ iframe.addEventListener("load", handleLoad);
2512
+ return () => iframe.removeEventListener("load", handleLoad);
2513
+ }, []);
2514
+ (0, _react.useEffect)(() => {
2515
+ console.log("selectedConversation", selectedConversation);
2516
+ const iframe = iframeRef.current;
2517
+ const handleSelect = () => {
2518
+ iframe.contentWindow.postMessage({
2519
+ type: "CONVERSATION_SELECTED",
2520
+ sessionId: selectedConversation.selectedConversation || null
2521
+ }, tijariaUrl);
2522
+ };
2523
+ iframe.addEventListener("load", handleSelect);
2524
+ return () => iframe.removeEventListener("load", handleSelect);
2525
+ }, [selectedConversation]);
2526
+ const isExpanded = true;
2527
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2528
+ style: {
2529
+ flex: 1,
2530
+ overflow: "auto",
2531
+ display: "flex",
2532
+ flexDirection: "column"
2533
+ },
2534
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2535
+ style: {
2536
+ flex: 1,
2537
+ position: "relative"
2538
+ },
2539
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
2540
+ ref: iframeRef,
2541
+ id: "chatbot-iframe",
2542
+ title: "TijarIA",
2543
+ src: "".concat(tijariaUrl, "/assistantBot?source=PGU&expanded=").concat(isExpanded),
2544
+ allow: "microphone",
2545
+ sandbox: "allow-popups allow-scripts allow-same-origin",
2546
+ style: {
2547
+ width: "100%",
2548
+ height: "90%",
2549
+ border: "none",
2550
+ position: "absolute",
2551
+ top: 0,
2552
+ left: 0
2553
+ }
2554
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2555
+ onClick: () => {
2556
+ const iframe = iframeRef.current;
2557
+ if (iframe) {
2558
+ iframe.contentWindow.postMessage({
2559
+ type: "toggleSize",
2560
+ isExpanded: true
2561
+ }, tijariaUrl);
2562
+ }
2563
+ },
2564
+ style: {
2565
+ position: "absolute",
2566
+ bottom: "20px",
2567
+ left: "50%",
2568
+ transform: "translateX(-50%)",
2569
+ display: "flex",
2570
+ flexDirection: "row",
2571
+ alignItems: "center",
2572
+ gap: "10px",
2573
+ padding: "8px 16px",
2574
+ border: "none",
2575
+ backgroundColor: "transparent",
2576
+ cursor: "pointer"
2577
+ },
2578
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
2579
+ src: _tijariaLogo.default,
2580
+ alt: "Tijaria Logo",
2581
+ style: {
2582
+ width: "24px",
2583
+ height: "24px",
2584
+ objectFit: "contain",
2585
+ flexShrink: 0
2586
+ }
2587
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2588
+ component: "div",
2589
+ sx: {
2590
+ fontSize: "16px",
2591
+ fontWeight: "500",
2592
+ fontFamily: WIDGET_FONT,
2593
+ margin: 0,
2594
+ lineHeight: "normal",
2595
+ color: "#495057"
2596
+ },
2597
+ children: "TijarIA"
2598
+ })]
2599
+ })]
2600
+ })
2601
+ });
2602
+ };
2603
+ const TijariaHistory = _ref6 => {
2604
+ let {
2605
+ onClose,
2606
+ setSelectedConversation
2607
+ } = _ref6;
2608
+ const [conversations, setConversations] = (0, _react.useState)([]);
2609
+ const [loading, setLoading] = (0, _react.useState)(true);
2610
+ const [error, setError] = (0, _react.useState)(null);
2611
+ (0, _react.useEffect)(() => {
2612
+ fetchUserHistory();
2613
+ }, []);
2614
+ const fetchUserHistory = async () => {
2615
+ try {
2616
+ setLoading(true);
2617
+ const response = await fetch("https://chatbot-dev.portnet.ma/api/user/getUserHistory", {
2618
+ method: "GET",
2619
+ headers: {
2620
+ Authorization: "Bearer ".concat(sessionStorage.getItem("tijaria_token")),
2621
+ "Content-Type": "application/json"
2622
+ }
2623
+ });
2624
+ if (!response.ok) {
2625
+ throw new Error("Erreur lors de la récupération de l'historique");
2626
+ }
2627
+ const data = await response.json();
2628
+ setConversations(data);
2629
+ setError(null);
2630
+ } catch (err) {
2631
+ console.error("Error fetching history:", err);
2632
+ setError(err.message);
2633
+ setConversations([]);
2634
+ } finally {
2635
+ setLoading(false);
2636
+ }
2637
+ };
2638
+ const handleConversationClick = conversation => {
2639
+ console.log(" Conversation clicked:", conversation);
2640
+ setSelectedConversation(conversation.sessionId);
2641
+ onClose();
2642
+ };
2643
+ const formatDate = dateString => {
2644
+ if (!dateString) return "N/A";
2645
+ const date = new Date(dateString);
2646
+ return date.toLocaleDateString("fr-FR", {
2647
+ day: "2-digit",
2648
+ month: "2-digit",
2649
+ year: "numeric",
2650
+ hour: "2-digit",
2651
+ minute: "2-digit"
2652
+ });
2653
+ };
2654
+ const truncateText = function truncateText(text) {
2655
+ let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 80;
2656
+ if (!text) return "";
2657
+ return text.length > maxLength ? text.substring(0, maxLength) + "..." : text;
2658
+ };
2659
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2660
+ style: {
2661
+ flex: 1,
2662
+ display: "flex",
2663
+ flexDirection: "column",
2664
+ backgroundColor: "#f5f5f5"
2665
+ },
2666
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2667
+ style: {
2668
+ display: "flex",
2669
+ justifyContent: "space-between",
2670
+ alignItems: "center",
2671
+ padding: "16px",
2672
+ backgroundColor: "white",
2673
+ borderBottom: "1px solid #e0e0e0"
2674
+ },
2675
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2676
+ style: {
2677
+ display: "flex",
2678
+ alignItems: "center",
2679
+ gap: "12px"
2680
+ },
2681
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2682
+ icon: _freeSolidSvgIcons.faComments,
2683
+ style: {
2684
+ color: "var(--primary-color, #222f67)",
2685
+ fontSize: "20px"
2686
+ }
2687
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2688
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2689
+ component: "div",
2690
+ sx: {
2691
+ fontWeight: "600",
2692
+ color: "#333",
2693
+ fontSize: "16px",
2694
+ fontFamily: WIDGET_FONT,
2695
+ margin: 0,
2696
+ lineHeight: "normal"
2697
+ },
2698
+ children: "Historique TijarIA"
2699
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2700
+ component: "div",
2701
+ sx: {
2702
+ color: "#999",
2703
+ fontSize: "12px",
2704
+ fontFamily: WIDGET_FONT,
2705
+ margin: 0,
2706
+ lineHeight: "normal"
2707
+ },
2708
+ children: loading ? "Chargement..." : "".concat(conversations.length, " conversation(s)")
2709
+ })]
2710
+ })]
2711
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2712
+ onClick: onClose,
2713
+ style: {
2714
+ cursor: "pointer",
2715
+ color: "#666",
2716
+ padding: "4px",
2717
+ display: "flex",
2718
+ alignItems: "center"
2719
+ },
2720
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2721
+ icon: _freeSolidSvgIcons.faTimes,
2722
+ style: {
2723
+ fontSize: "16px"
2724
+ }
2725
+ })
2726
+ })]
2727
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2728
+ style: {
2729
+ flex: 1,
2730
+ overflowY: "auto",
2731
+ padding: "12px"
2732
+ },
2733
+ children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2734
+ style: {
2735
+ display: "flex",
2736
+ flexDirection: "column",
2737
+ alignItems: "center",
2738
+ justifyContent: "center",
2739
+ padding: "40px 20px",
2740
+ color: "#999"
2741
+ },
2742
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2743
+ style: {
2744
+ width: "40px",
2745
+ height: "40px",
2746
+ border: "4px solid #f3f3f3",
2747
+ borderTop: "4px solid var(--primary-color, #222f67)",
2748
+ borderRadius: "50%",
2749
+ animation: "spin 1s linear infinite"
2750
+ }
2751
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
2752
+ children: "\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "
2753
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2754
+ component: "div",
2755
+ sx: {
2756
+ fontSize: "14px",
2757
+ marginTop: "32px",
2758
+ fontFamily: WIDGET_FONT,
2759
+ lineHeight: "normal",
2760
+ color: "#999"
2761
+ },
2762
+ children: "Chargement de l'historique..."
2763
+ })]
2764
+ }) : error ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2765
+ style: {
2766
+ display: "flex",
2767
+ flexDirection: "column",
2768
+ alignItems: "center",
2769
+ justifyContent: "center",
2770
+ padding: "40px 20px",
2771
+ color: "#dc3545"
2772
+ },
2773
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2774
+ icon: _freeSolidSvgIcons.faWarning,
2775
+ style: {
2776
+ fontSize: "48px",
2777
+ marginBottom: "16px"
2778
+ }
2779
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2780
+ component: "div",
2781
+ sx: {
2782
+ fontSize: "14px",
2783
+ textAlign: "center",
2784
+ fontFamily: WIDGET_FONT,
2785
+ margin: 0,
2786
+ lineHeight: "normal"
2787
+ },
2788
+ children: error
2789
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
2790
+ onClick: fetchUserHistory,
2791
+ variant: "contained",
2792
+ sx: {
2793
+ marginTop: "35px",
2794
+ padding: "6px 20px",
2795
+ backgroundColor: "var(--primary-color, #222f67)",
2796
+ color: "white",
2797
+ borderRadius: "6px",
2798
+ fontSize: "14px",
2799
+ fontWeight: "600",
2800
+ fontFamily: WIDGET_FONT,
2801
+ textTransform: "none",
2802
+ boxShadow: "none",
2803
+ "&:hover": {
2804
+ backgroundColor: "var(--primary-color, #222f67)",
2805
+ opacity: 0.9,
2806
+ boxShadow: "none"
2807
+ }
2808
+ },
2809
+ children: "R\xE9essayer"
2810
+ })]
2811
+ }) : conversations.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2812
+ style: {
2813
+ display: "flex",
2814
+ flexDirection: "column",
2815
+ alignItems: "center",
2816
+ justifyContent: "center",
2817
+ padding: "40px 20px",
2818
+ color: "#999"
2819
+ },
2820
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2821
+ icon: _freeSolidSvgIcons.faComments,
2822
+ style: {
2823
+ fontSize: "48px",
2824
+ marginBottom: "32px"
2825
+ }
2826
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2827
+ component: "div",
2828
+ sx: {
2829
+ fontSize: "14px",
2830
+ textAlign: "center",
2831
+ fontFamily: WIDGET_FONT,
2832
+ lineHeight: "normal",
2833
+ color: "#999"
2834
+ },
2835
+ children: "Aucune conversation trouv\xE9e"
2836
+ })]
2837
+ }) : conversations.map((conversation, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2838
+ onClick: () => handleConversationClick(conversation),
2839
+ style: {
2840
+ backgroundColor: "white",
2841
+ borderRadius: "8px",
2842
+ padding: "16px",
2843
+ marginBottom: "12px",
2844
+ cursor: "pointer",
2845
+ boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
2846
+ transition: "all 0.2s ease",
2847
+ border: "1px solid #e0e0e0"
2848
+ },
2849
+ onMouseEnter: e => {
2850
+ e.currentTarget.style.boxShadow = "0 4px 8px rgba(0,0,0,0.15)";
2851
+ e.currentTarget.style.transform = "translateY(-2px)";
2852
+ },
2853
+ onMouseLeave: e => {
2854
+ e.currentTarget.style.boxShadow = "0 1px 3px rgba(0,0,0,0.1)";
2855
+ e.currentTarget.style.transform = "translateY(0)";
2856
+ },
2857
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2858
+ style: {
2859
+ display: "flex",
2860
+ justifyContent: "space-between",
2861
+ alignItems: "center",
2862
+ marginBottom: "12px"
2863
+ },
2864
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2865
+ style: {
2866
+ display: "flex",
2867
+ alignItems: "center",
2868
+ gap: "8px"
2869
+ },
2870
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
2871
+ icon: _freeSolidSvgIcons.faComments,
2872
+ style: {
2873
+ color: "var(--primary-color, #222f67)",
2874
+ fontSize: "14px"
2875
+ }
2876
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
2877
+ component: "div",
2878
+ sx: {
2879
+ fontWeight: "600",
2880
+ color: "#333",
2881
+ fontSize: "13px",
2882
+ fontFamily: WIDGET_FONT,
2883
+ margin: 0,
2884
+ lineHeight: "normal"
2885
+ },
2886
+ children: truncateText(conversation.title || "Aucun titre disponible")
2887
+ })]
2888
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2889
+ style: {
2890
+ color: "#999",
2891
+ fontSize: "11px"
2892
+ },
2893
+ children: conversation.createdAt && formatDate(conversation.createdAt)
2894
+ })]
2895
+ })
2896
+ }, conversation.id || index))
2897
+ })]
2898
+ });
2899
+ };
2900
+ const PuiHelpWidget = _ref7 => {
2901
+ let {
2902
+ showReclamation = true,
2903
+ showGuides = false,
2904
+ currentProjectCode = null,
2905
+ guideBaseUrl
2906
+ } = _ref7;
2907
+ const [dropdownOpen, setDropdownOpen] = (0, _react.useState)(false);
2908
+ const [isTourActive, setIsTourActive] = (0, _react.useState)(false);
2909
+ const {
2910
+ guideApi
2911
+ } = (0, _PuiHelpWidgetContext.useHelpWidget)();
2912
+ const toggle = () => {
2913
+ setDropdownOpen(prev => !prev);
2914
+ };
2915
+ (0, _react.useEffect)(() => {
2916
+ const openDropdown = () => {
2917
+ setIsOpen(true);
2918
+ setIsTourActive(true);
2919
+ };
2920
+ const closeDropdown = () => {
2921
+ setIsOpen(false);
2922
+ setIsTourActive(false);
2923
+ };
2924
+ window.addEventListener("open-aide-dropdown", openDropdown);
2925
+ window.addEventListener("close-aide-dropdown", closeDropdown);
2926
+ return () => {
2927
+ window.removeEventListener("open-aide-dropdown", openDropdown);
2928
+ window.removeEventListener("close-aide-dropdown", closeDropdown);
2929
+ };
2930
+ }, []);
2931
+ const dispatch = (0, _reactRedux.useDispatch)();
2932
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
2933
+ const sidebarRef = (0, _react.useRef)(null);
2934
+ const triggerRef = (0, _react.useRef)(null);
2935
+ const firstFocusableRef = (0, _react.useRef)(null);
2936
+ const contactPopoverRef = (0, _react.useRef)(null);
2937
+ const firstContactFocusableRef = (0, _react.useRef)(null);
2938
+ const previousContactActiveElement = (0, _react.useRef)(null);
2939
+ const previousActiveElement = (0, _react.useRef)(null);
2940
+ const [hoveredIndex, setHoveredIndex] = (0, _react.useState)(null);
2941
+ const [activeChat, setActiveChat] = (0, _react.useState)(null);
2942
+ const [infoMessages, setInfoMessages] = (0, _react.useState)([]);
2943
+ const [incidentMessages, setIncidentMessages] = (0, _react.useState)([]);
2944
+ const [reclamationModalOpen, setReclamationModalOpen] = (0, _react.useState)(false);
2945
+ const [viewingReclamations, setViewingReclamations] = (0, _react.useState)(false);
2946
+ const [viewingTijariaHistory, setViewingTijariaHistory] = (0, _react.useState)(false);
2947
+ const [contactUsMenuAnchor, setContactUsMenuAnchor] = (0, _react.useState)(null);
2948
+ const contactUsMenuOpen = Boolean(contactUsMenuAnchor);
2949
+ const [popupPosition, setPopupPosition] = (0, _react.useState)({
2950
+ x: 0,
2951
+ y: 0
2952
+ });
2953
+ const [isDragging, setIsDragging] = (0, _react.useState)(false);
2954
+ const [dragStart, setDragStart] = (0, _react.useState)({
2955
+ x: 0,
2956
+ y: 0
2957
+ });
2958
+ const [guidesPanelOpen, setGuidesPanelOpen] = (0, _react.useState)(false);
2959
+ const [faqPanelOpen, setFaqPanelOpen] = (0, _react.useState)(false);
2960
+ const [guideData, setGuideData] = (0, _react.useState)(null);
2961
+ const [faqData, setFaqData] = (0, _react.useState)(null);
2962
+ const [loadingGuide, setLoadingGuide] = (0, _react.useState)(false);
2963
+ (0, _react.useEffect)(() => {
2964
+ async function fetchGuideData() {
2965
+ if (!showGuides || !currentProjectCode || !guidesPanelOpen) return;
2966
+ try {
2967
+ var _response$data;
2968
+ const response = await guideApi.getGuideContent(currentProjectCode);
2969
+ setGuideData(response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.body);
2970
+ } catch (error) {
2971
+ console.error("Error loading guide data:", error);
2972
+ setGuideData(null);
2973
+ }
2974
+ }
2975
+ fetchGuideData();
2976
+ }, [currentProjectCode, guidesPanelOpen, showGuides]);
2977
+ (0, _react.useEffect)(() => {
2978
+ async function fetchFaqData() {
2979
+ if (!faqPanelOpen) return;
2980
+ try {
2981
+ const faqModule = await _guides.default["FAQ"];
2982
+ const data = faqModule.default || faqModule;
2983
+ setFaqData(data);
2984
+ } catch (error) {
2985
+ console.error("Error loading FAQ data:", error);
2986
+ setFaqData(null);
2987
+ }
2988
+ }
2989
+ fetchFaqData();
2990
+ }, [faqPanelOpen]);
2991
+ const handleGuideMenuClick = event => {
2992
+ setIsOpen(false);
2993
+ setGuidesPanelOpen(true);
2994
+ };
2995
+ const handleFaqClick = () => {
2996
+ setIsOpen(false);
2997
+ setFaqPanelOpen(true);
2998
+ };
2999
+ const handleContactUsClick = event => {
3000
+ const rect = event.currentTarget.getBoundingClientRect();
3001
+ setContactUsMenuAnchor(event.currentTarget);
3002
+ setPopupPosition({
3003
+ x: rect.left - 291,
3004
+ y: rect.top
3005
+ });
3006
+ };
3007
+ const handleContactUsMenuClose = () => {
3008
+ setContactUsMenuAnchor(null);
3009
+ };
3010
+ const handleContactClick = () => {
3011
+ window.location.href = "mailto:support@moroccotradenet.ma";
3012
+ handleContactUsMenuClose();
3013
+ };
3014
+ const handlePdfGuideClick = async () => {
3015
+ setLoadingGuide(true);
3016
+ try {
3017
+ var _response$data2;
3018
+ const response = await guideApi.getGuideByProjectCode(currentProjectCode);
3019
+ const guideData = response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.body;
3020
+ if (guideData !== null && guideData !== void 0 && guideData.urlFichier) {
3021
+ const link = document.createElement("a");
3022
+ link.href = guideData.urlFichier;
3023
+ link.setAttribute("download", "");
3024
+ document.body.appendChild(link);
3025
+ link.click();
3026
+ document.body.removeChild(link);
3027
+ } else {
3028
+ console.warn("No PDF guide found for project: ".concat(currentProjectCode));
3029
+ }
3030
+ } catch (error) {
3031
+ console.error("Error fetching guide:", error);
3032
+ } finally {
3033
+ setLoadingGuide(false);
3034
+ }
3035
+ };
3036
+ const handleMouseDown = e => {
3037
+ if (e.target.classList.contains("draggable-handle")) {
3038
+ setIsDragging(true);
3039
+ setDragStart({
3040
+ x: e.clientX - popupPosition.x,
3041
+ y: e.clientY - popupPosition.y
3042
+ });
3043
+ }
3044
+ };
3045
+ const handleMouseMove = e => {
3046
+ if (isDragging) {
3047
+ setPopupPosition({
3048
+ x: e.clientX - dragStart.x,
3049
+ y: e.clientY - dragStart.y
3050
+ });
3051
+ }
3052
+ };
3053
+ const handleMouseUp = () => {
3054
+ setIsDragging(false);
3055
+ };
3056
+ (0, _react.useEffect)(() => {
3057
+ if (isDragging) {
3058
+ document.addEventListener("mousemove", handleMouseMove);
3059
+ document.addEventListener("mouseup", handleMouseUp);
3060
+ return () => {
3061
+ document.removeEventListener("mousemove", handleMouseMove);
3062
+ document.removeEventListener("mouseup", handleMouseUp);
3063
+ };
3064
+ }
3065
+ }, [isDragging, dragStart, popupPosition]);
3066
+ (0, _react.useEffect)(() => {
3067
+ if (isOpen) {
3068
+ previousActiveElement.current = document.activeElement;
3069
+ setTimeout(() => {
3070
+ var _firstFocusableRef$cu3;
3071
+ (_firstFocusableRef$cu3 = firstFocusableRef.current) === null || _firstFocusableRef$cu3 === void 0 || _firstFocusableRef$cu3.focus();
3072
+ }, 100);
3073
+ } else {
3074
+ if (previousActiveElement.current) {
3075
+ previousActiveElement.current.focus();
3076
+ }
3077
+ }
3078
+ }, [isOpen]);
3079
+ (0, _react.useEffect)(() => {
3080
+ if (!isOpen) return;
3081
+ const handleKeyDown = e => {
3082
+ if (e.key === "Escape") {
3083
+ setIsOpen(false);
3084
+ return;
3085
+ }
3086
+ if (e.key === "Tab") {
3087
+ const sidebar = sidebarRef.current;
3088
+ if (!sidebar) return;
3089
+ const focusableElements = sidebar.querySelectorAll('button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])');
3090
+ const focusableArray = Array.from(focusableElements);
3091
+ const firstElement = focusableArray[0];
3092
+ const lastElement = focusableArray[focusableArray.length - 1];
3093
+ if (focusableArray.length === 0) return;
3094
+ if (e.shiftKey) {
3095
+ if (document.activeElement === firstElement) {
3096
+ lastElement.focus();
3097
+ e.preventDefault();
3098
+ }
3099
+ } else {
3100
+ if (document.activeElement === lastElement) {
3101
+ firstElement.focus();
3102
+ e.preventDefault();
3103
+ }
3104
+ }
3105
+ }
3106
+ };
3107
+ document.addEventListener("keydown", handleKeyDown);
3108
+ return () => document.removeEventListener("keydown", handleKeyDown);
3109
+ }, [isOpen]);
3110
+ (0, _react.useEffect)(() => {
3111
+ if (isOpen) {
3112
+ document.body.style.overflow = "hidden";
3113
+ } else {
3114
+ document.body.style.overflow = "";
3115
+ }
3116
+ return () => {
3117
+ document.body.style.overflow = "";
3118
+ };
3119
+ }, [isOpen]);
3120
+ (0, _react.useEffect)(() => {
3121
+ if (contactUsMenuOpen) {
3122
+ previousContactActiveElement.current = document.activeElement;
3123
+ setTimeout(() => {
3124
+ const popover = contactPopoverRef.current;
3125
+ if (popover) {
3126
+ const firstMenuItem = popover.querySelector('[role="menuitem"]');
3127
+ if (firstMenuItem) {
3128
+ firstMenuItem.focus();
3129
+ }
3130
+ }
3131
+ }, 100);
3132
+ } else {
3133
+ if (previousContactActiveElement.current) {
3134
+ previousContactActiveElement.current.focus();
3135
+ }
3136
+ }
3137
+ }, [contactUsMenuOpen]);
3138
+ (0, _react.useEffect)(() => {
3139
+ if (!contactUsMenuOpen) return;
3140
+ const handleKeyDown = e => {
3141
+ if (e.key === "Escape") {
3142
+ handleContactUsMenuClose();
3143
+ return;
3144
+ }
3145
+ if (e.key === "Tab") {
3146
+ const popover = contactPopoverRef.current;
3147
+ if (!popover) return;
3148
+ const focusableElements = popover.querySelectorAll('button:not([disabled]), [role="menuitem"]:not([disabled]), [href]:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])');
3149
+ const focusableArray = Array.from(focusableElements);
3150
+ const firstElement = focusableArray[0];
3151
+ const lastElement = focusableArray[focusableArray.length - 1];
3152
+ if (focusableArray.length === 0) return;
3153
+ if (e.shiftKey) {
3154
+ if (document.activeElement === firstElement) {
3155
+ lastElement.focus();
3156
+ e.preventDefault();
3157
+ }
3158
+ } else {
3159
+ if (document.activeElement === lastElement) {
3160
+ firstElement.focus();
3161
+ e.preventDefault();
3162
+ }
3163
+ }
3164
+ }
3165
+ };
3166
+ document.addEventListener("keydown", handleKeyDown);
3167
+ return () => document.removeEventListener("keydown", handleKeyDown);
3168
+ }, [contactUsMenuOpen]);
3169
+ const navigationLinks = [...(showGuides && currentProjectCode ? [{
3170
+ icon: _freeSolidSvgIcons.faBook,
3171
+ title: "Guides utilisateurs",
3172
+ action: handleGuideMenuClick
3173
+ }] : []), {
3174
+ icon: _freeSolidSvgIcons.faPen,
3175
+ title: "Foires aux questions",
3176
+ id: "foire-aux-questions",
3177
+ action: handleFaqClick
3178
+ }, ...(showReclamation ? [{
3179
+ icon: _freeSolidSvgIcons.faClipboardList,
3180
+ title: "Mes réclamations",
3181
+ id: "mes-reclamations",
3182
+ action: () => setViewingReclamations(true)
3183
+ }, {
3184
+ icon: _freeSolidSvgIcons.faBullhorn,
3185
+ title: "Nouvelle réclamation",
3186
+ id: "nouvelle-reclamation",
3187
+ action: () => setReclamationModalOpen(true)
3188
+ }] : []), {
3189
+ icon: _freeSolidSvgIcons.faAddressBook,
3190
+ title: "Contactez-nous",
3191
+ id: "contactez-nous",
3192
+ action: handleContactUsClick
3193
+ },
3194
+ /*{
3195
+ icon: faComments,
3196
+ title: "TijarIA",
3197
+ action: () => {
3198
+ setActiveChat(null);
3199
+ setViewingReclamations(false);
3200
+ },
3201
+ },*/
3202
+ {
3203
+ icon: _freeSolidSvgIcons.faComments,
3204
+ title: "Mes Conversations",
3205
+ id: "mes-conversations",
3206
+ action: () => {
3207
+ setViewingTijariaHistory(true);
3208
+ setViewingReclamations(false);
3209
+ }
3210
+ }];
3211
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
3212
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3213
+ className: "help-widget-button ".concat(isOpen ? "open" : ""),
3214
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactstrap.Button, {
3215
+ ref: triggerRef,
3216
+ color: "light",
3217
+ className: "help-trigger",
3218
+ onClick: () => setIsOpen(!isOpen),
3219
+ "aria-label": "Ouvrir le centre d'aide",
3220
+ "aria-expanded": isOpen,
3221
+ "aria-controls": "help-sidebar",
3222
+ tabIndex: 0,
3223
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
3224
+ component: "div",
3225
+ sx: {
3226
+ fontWeight: "600",
3227
+ fontSize: "14px",
3228
+ color: "#282828",
3229
+ fontFamily: WIDGET_FONT,
3230
+ margin: 0,
3231
+ padding: 0,
3232
+ lineHeight: "normal"
3233
+ },
3234
+ children: "Besoin d'aide ?"
3235
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
3236
+ icon: isOpen ? _freeSolidSvgIcons.faChevronLeft : _freeSolidSvgIcons.faChevronRight,
3237
+ className: "arrow-icon",
3238
+ "aria-hidden": "true"
3239
+ })]
3240
+ })
3241
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3242
+ id: "help-sidebar",
3243
+ ref: sidebarRef,
3244
+ className: "help-widget-sidebar ".concat(isOpen ? "open" : ""),
3245
+ role: "dialog",
3246
+ "aria-modal": "true",
3247
+ "aria-labelledby": "help-title",
3248
+ "aria-hidden": !isOpen,
3249
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Card, {
3250
+ className: "h-100 border-0 shadow-lg",
3251
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactstrap.CardBody, {
3252
+ className: "p-0 d-flex flex-column",
3253
+ style: {
3254
+ flex: 1,
3255
+ minHeight: 0
3256
+ },
3257
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
3258
+ style: {
3259
+ paddingTop: "12px",
3260
+ paddingBottom: "20px",
3261
+ paddingLeft: "17px",
3262
+ paddingRight: "20px",
3263
+ borderBottom: "1px solid #e9ecef",
3264
+ backgroundColor: "white",
3265
+ display: "flex",
3266
+ alignItems: "center",
3267
+ justifyContent: "space-between"
3268
+ },
3269
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
3270
+ style: {
3271
+ display: "flex",
3272
+ alignItems: "center"
3273
+ },
3274
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
3275
+ icon: _freeRegularSvgIcons.faQuestionCircle,
3276
+ style: {
3277
+ color: "var(--primary-color, #222f67)",
3278
+ fontSize: "24px",
3279
+ marginRight: "8px",
3280
+ flexShrink: 0
3281
+ },
3282
+ "aria-hidden": "true"
3283
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
3284
+ id: "help-title",
3285
+ component: "div",
3286
+ onClick: () => setIsOpen(false),
3287
+ sx: {
3288
+ margin: 0,
3289
+ color: "#495057",
3290
+ fontWeight: "600",
3291
+ fontSize: "16px",
3292
+ cursor: "pointer",
3293
+ userSelect: "none",
3294
+ flex: 1,
3295
+ lineHeight: "normal",
3296
+ fontFamily: WIDGET_FONT,
3297
+ "&:hover": {
3298
+ color: "var(--primary-color, #222f67)"
3299
+ }
3300
+ },
3301
+ children: "Centre d'aide"
3302
+ })]
3303
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
3304
+ ref: firstFocusableRef,
3305
+ onClick: () => setIsOpen(false),
3306
+ "aria-label": "Fermer le centre d'aide",
3307
+ tabIndex: 0,
3308
+ style: {
3309
+ background: "none",
3310
+ border: "none",
3311
+ fontSize: "20px",
3312
+ cursor: "pointer",
3313
+ padding: "4px 8px",
3314
+ color: "#6c757d",
3315
+ lineHeight: 1,
3316
+ borderRadius: "4px"
3317
+ },
3318
+ onMouseEnter: e => {
3319
+ e.currentTarget.style.backgroundColor = "#f0f0f0";
3320
+ },
3321
+ onMouseLeave: e => {
3322
+ e.currentTarget.style.backgroundColor = "transparent";
3323
+ },
3324
+ children: "\u2715"
3325
+ })]
3326
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3327
+ style: {
3328
+ padding: "15px 15px",
3329
+ borderBottom: "1px solid #e9ecef",
3330
+ backgroundColor: "white"
3331
+ },
3332
+ children: navigationLinks.map((link, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
3333
+ id: link.id,
3334
+ onClick: link.action,
3335
+ onKeyDown: e => {
3336
+ if (e.key === "Enter" || e.key === " ") {
3337
+ e.preventDefault();
3338
+ link.action(e);
3339
+ }
3340
+ },
3341
+ role: "button",
3342
+ tabIndex: 0,
3343
+ "aria-label": link.title,
3344
+ style: {
3345
+ display: "flex",
3346
+ alignItems: "center",
3347
+ padding: "8px 12px",
3348
+ marginRight: "130px",
3349
+ cursor: "pointer",
3350
+ transition: "all 0.2s ease",
3351
+ borderRadius: "4px",
3352
+ backgroundColor: hoveredIndex === index ? "#f0f0ef" : "transparent"
3353
+ },
3354
+ onMouseEnter: () => setHoveredIndex(index),
3355
+ onMouseLeave: () => setHoveredIndex(null),
3356
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3357
+ style: {
3358
+ width: "20px",
3359
+ display: "flex",
3360
+ justifyContent: "center",
3361
+ marginRight: "10px"
3362
+ },
3363
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
3364
+ icon: link.icon,
3365
+ style: {
3366
+ color: hoveredIndex === index ? "var(--primary-color, #222f67)" : "#6c757d",
3367
+ fontSize: "14px",
3368
+ transition: "color 0.2s ease"
3369
+ },
3370
+ "aria-hidden": "true"
3371
+ })
3372
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
3373
+ component: "div",
3374
+ sx: {
3375
+ color: hoveredIndex === index ? "var(--primary-color, #222f67)" : "#6c757d",
3376
+ fontSize: "12.2px",
3377
+ fontWeight: "500",
3378
+ transition: "color 0.2s ease",
3379
+ lineHeight: "normal",
3380
+ fontFamily: WIDGET_FONT,
3381
+ margin: 0,
3382
+ padding: 0
3383
+ },
3384
+ children: link.title
3385
+ })]
3386
+ }, index))
3387
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(BottomContent, {
3388
+ viewingReclamations: viewingReclamations,
3389
+ viewingTijariaHistory: viewingTijariaHistory,
3390
+ activeChat: activeChat,
3391
+ infoMessages: infoMessages,
3392
+ incidentMessages: incidentMessages,
3393
+ setViewingReclamations: setViewingReclamations,
3394
+ setViewingTijariaHistory: setViewingTijariaHistory,
3395
+ setActiveChat: setActiveChat,
3396
+ setInfoMessages: setInfoMessages,
3397
+ setIncidentMessages: setIncidentMessages
3398
+ })]
3399
+ })
3400
+ })
3401
+ }), showGuides && /*#__PURE__*/(0, _jsxRuntime.jsx)(ContentPanel, {
3402
+ isOpen: guidesPanelOpen,
3403
+ onClose: () => {
3404
+ setGuidesPanelOpen(false);
3405
+ setGuideData(null);
3406
+ },
3407
+ contentData: guideData,
3408
+ title: "Guide utilisateurs",
3409
+ showDownloadButton: true,
3410
+ onDownload: handlePdfGuideClick,
3411
+ loadingDownload: loadingGuide,
3412
+ projectCode: currentProjectCode,
3413
+ guideBaseUrl: guideBaseUrl
3414
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ContentPanel, {
3415
+ isOpen: faqPanelOpen,
3416
+ onClose: () => {
3417
+ setFaqPanelOpen(false);
3418
+ setFaqData(null);
3419
+ },
3420
+ contentData: faqData,
3421
+ title: "Foire aux questions",
3422
+ showDownloadButton: false,
3423
+ showExternalLinkLabel: true,
3424
+ externalLinkUrl: "https://www.portnet.ma/faq"
3425
+ }), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3426
+ className: "help-widget-overlay",
3427
+ onClick: () => setIsOpen(false),
3428
+ style: {
3429
+ position: "fixed",
3430
+ top: 0,
3431
+ left: 0,
3432
+ width: "100vw",
3433
+ height: "100vh",
3434
+ backgroundColor: "rgba(0, 0, 0, 0.3)",
3435
+ zIndex: 999
3436
+ }
3437
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Popover, {
3438
+ open: contactUsMenuOpen,
3439
+ anchorEl: contactUsMenuAnchor,
3440
+ onClose: handleContactUsMenuClose,
3441
+ anchorReference: "anchorPosition",
3442
+ anchorPosition: {
3443
+ top: popupPosition.y,
3444
+ left: popupPosition.x
3445
+ },
3446
+ PaperProps: {
3447
+ ref: contactPopoverRef,
3448
+ elevation: 8,
3449
+ sx: {
3450
+ minWidth: 280,
3451
+ borderRadius: 3,
3452
+ overflow: "visible",
3453
+ boxShadow: "0 8px 32px rgba(0,0,0,0.12)"
3454
+ },
3455
+ role: "dialog",
3456
+ "aria-modal": "true",
3457
+ "aria-labelledby": "contact-title"
3458
+ },
3459
+ TransitionProps: {
3460
+ timeout: 300
3461
+ },
3462
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
3463
+ className: "draggable-handle",
3464
+ onMouseDown: handleMouseDown,
3465
+ style: {
3466
+ padding: "16px 20px",
3467
+ borderBottom: "1px solid #e0e0e0",
3468
+ cursor: "move",
3469
+ userSelect: "none",
3470
+ backgroundColor: "#f8f9fa",
3471
+ borderTopLeftRadius: "12px",
3472
+ borderTopRightRadius: "12px",
3473
+ display: "flex",
3474
+ justifyContent: "center",
3475
+ alignItems: "center",
3476
+ position: "relative"
3477
+ },
3478
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
3479
+ style: {
3480
+ display: "flex",
3481
+ alignItems: "center",
3482
+ gap: "8px"
3483
+ },
3484
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
3485
+ component: "div",
3486
+ id: "contact-title",
3487
+ sx: {
3488
+ fontWeight: "600",
3489
+ fontSize: "15px",
3490
+ color: "#333",
3491
+ fontFamily: WIDGET_FONT,
3492
+ margin: 0,
3493
+ padding: 0,
3494
+ lineHeight: "normal"
3495
+ },
3496
+ children: "Contactez-nous"
3497
+ })
3498
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
3499
+ onClick: handleContactUsMenuClose,
3500
+ "aria-label": "Fermer",
3501
+ tabIndex: 0,
3502
+ style: {
3503
+ cursor: "pointer",
3504
+ padding: "4px",
3505
+ borderRadius: "4px",
3506
+ display: "flex",
3507
+ alignItems: "center",
3508
+ justifyContent: "center",
3509
+ transition: "background-color 0.2s",
3510
+ position: "absolute",
3511
+ right: "16px",
3512
+ background: "none",
3513
+ border: "none"
3514
+ },
3515
+ onMouseEnter: e => e.currentTarget.style.backgroundColor = "#e0e0e0",
3516
+ onMouseLeave: e => e.currentTarget.style.backgroundColor = "transparent",
3517
+ onFocus: e => {
3518
+ e.currentTarget.style.backgroundColor = "#e0e0e0";
3519
+ e.currentTarget.style.outline = "2px solid var(--primary-color, #222f67)";
3520
+ e.currentTarget.style.outlineOffset = "2px";
3521
+ },
3522
+ onBlur: e => {
3523
+ e.currentTarget.style.backgroundColor = "transparent";
3524
+ e.currentTarget.style.outline = "none";
3525
+ },
3526
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
3527
+ icon: _freeSolidSvgIcons.faTimes,
3528
+ style: {
3529
+ fontSize: "14px",
3530
+ color: "#666"
3531
+ },
3532
+ "aria-hidden": "true"
3533
+ })
3534
+ })]
3535
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
3536
+ style: {
3537
+ padding: "8px"
3538
+ },
3539
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
3540
+ onClick: handleContactClick,
3541
+ onKeyDown: e => {
3542
+ if (e.key === "Enter" || e.key === " ") {
3543
+ e.preventDefault();
3544
+ handleContactClick();
3545
+ }
3546
+ },
3547
+ tabIndex: 0,
3548
+ sx: {
3549
+ borderRadius: 1,
3550
+ mb: 0.5,
3551
+ py: 1.5,
3552
+ "&:hover": {
3553
+ backgroundColor: "var(--primary-alpha-8, rgba(34, 47, 103, 0.08))"
3554
+ },
3555
+ "&:focus": {
3556
+ backgroundColor: "var(--primary-alpha-8, rgba(34, 47, 103, 0.08))",
3557
+ outline: "2px solid var(--primary-color, #222f67)",
3558
+ outlineOffset: "2px"
3559
+ }
3560
+ },
3561
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
3562
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Email, {
3563
+ fontSize: "small",
3564
+ sx: {
3565
+ color: "var(--primary-color, #222f67)"
3566
+ },
3567
+ "aria-hidden": "true"
3568
+ })
3569
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
3570
+ primary: "Contacter le support",
3571
+ secondary: "Envoyez-nous un email",
3572
+ primaryTypographyProps: {
3573
+ fontSize: "14px",
3574
+ fontWeight: "500"
3575
+ },
3576
+ secondaryTypographyProps: {
3577
+ fontSize: "12px"
3578
+ }
3579
+ })]
3580
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
3581
+ onClick: () => {
3582
+ window.open("tel:+212520473100", "_self");
3583
+ handleContactUsMenuClose();
3584
+ },
3585
+ onKeyDown: e => {
3586
+ if (e.key === "Enter" || e.key === " ") {
3587
+ e.preventDefault();
3588
+ window.open("tel:+212520473100", "_self");
3589
+ handleContactUsMenuClose();
3590
+ }
3591
+ },
3592
+ tabIndex: 0,
3593
+ sx: {
3594
+ borderRadius: 1,
3595
+ mb: 0.5,
3596
+ py: 1.5,
3597
+ "&:hover": {
3598
+ backgroundColor: "var(--primary-alpha-8, rgba(34, 47, 103, 0.08))"
3599
+ },
3600
+ "&:focus": {
3601
+ backgroundColor: "var(--primary-alpha-8, rgba(34, 47, 103, 0.08))",
3602
+ outline: "2px solid var(--primary-color, #222f67)",
3603
+ outlineOffset: "2px"
3604
+ }
3605
+ },
3606
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
3607
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Phone, {
3608
+ fontSize: "small",
3609
+ sx: {
3610
+ color: "var(--primary-color, #222f67)"
3611
+ },
3612
+ "aria-hidden": "true"
3613
+ })
3614
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
3615
+ primary: "Assistance t\xE9l\xE9phonique",
3616
+ secondary: "+212 520 47 31 00",
3617
+ primaryTypographyProps: {
3618
+ fontSize: "14px",
3619
+ fontWeight: "500"
3620
+ },
3621
+ secondaryTypographyProps: {
3622
+ fontSize: "12px"
3623
+ }
3624
+ })]
3625
+ })]
3626
+ })]
3627
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ReclamationFormModal, {
3628
+ open: reclamationModalOpen,
3629
+ onClose: () => setReclamationModalOpen(false)
3630
+ })]
3631
+ });
3632
+ };
3633
+ var _default = exports.default = PuiHelpWidget;