jett.admin.npmpackage 2.0.26 → 2.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/index.css +1486 -1486
  2. package/dist/index.js +2122 -2114
  3. package/dist/index.mjs +2091 -2083
  4. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,2083 +1,2091 @@
1
- // src/utils/cn.ts
2
- import { clsx } from "clsx";
3
- import { twMerge } from "tailwind-merge";
4
- function cn(...inputs) {
5
- return twMerge(clsx(inputs));
6
- }
7
-
8
- // src/Button.jsx
9
- import React from "react";
10
- var variantStyles = {
11
- PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
12
- SECONDARY: "bg-primary text-white dark:text-white",
13
- DEFAULT: "bg-white text-black dark:text-white",
14
- DANGER: "bg-[#ef4444] text-white dark:text-white"
15
- };
16
- var CustomButton = ({
17
- id = "button",
18
- variant = "DEFAULT",
19
- children,
20
- className,
21
- onClick,
22
- disabled = false,
23
- icon
24
- }) => {
25
- return /* @__PURE__ */ React.createElement(
26
- "div",
27
- {
28
- className: cn(
29
- `cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
30
- variantStyles[variant],
31
- className
32
- ),
33
- onClick,
34
- id: `${id}-div-1`
35
- },
36
- icon && /* @__PURE__ */ React.createElement("div", { id: `${id}-div-2` }, icon),
37
- children
38
- );
39
- };
40
-
41
- // src/inputs/Autocomplete.jsx
42
- import React2, { useState, useRef } from "react";
43
- import { ChevronDown, Check, Search } from "lucide-react";
44
- var CustomAutocomplete = ({
45
- id = "autocomplete",
46
- label,
47
- value,
48
- onChange,
49
- options,
50
- placeholder = "Search & select...",
51
- isRequired = false,
52
- error,
53
- heading,
54
- disabled = false
55
- }) => {
56
- const [open, setOpen] = useState(false);
57
- const [search, setSearch] = useState("");
58
- const wrapperRef = useRef(null);
59
- const selectedOptions = options.filter((opt) => value.includes(opt.value));
60
- const handleBlur = (e) => {
61
- var _a;
62
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
63
- setOpen(false);
64
- }
65
- };
66
- const filteredOptions = options.filter(
67
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
68
- );
69
- const toggleValue = (val) => {
70
- if (value.includes(val)) {
71
- onChange(value.filter((v) => v !== val));
72
- } else {
73
- onChange([...value, val]);
74
- }
75
- };
76
- return /* @__PURE__ */ React2.createElement(
77
- "div",
78
- {
79
- className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
80
- ref: wrapperRef,
81
- tabIndex: disabled ? -1 : 0,
82
- onBlur: handleBlur,
83
- id: `${id}-div-1`
84
- },
85
- heading && /* @__PURE__ */ React2.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
86
- label && /* @__PURE__ */ React2.createElement(
87
- "label",
88
- {
89
- className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
90
- id: `${id}-label-1`
91
- },
92
- label,
93
- " ",
94
- isRequired && /* @__PURE__ */ React2.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
95
- ),
96
- /* @__PURE__ */ React2.createElement(
97
- "div",
98
- {
99
- onClick: () => {
100
- if (!disabled) setOpen((prev) => !prev);
101
- },
102
- className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
103
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
104
- ${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
105
- `,
106
- id: `${id}-div-2`
107
- },
108
- /* @__PURE__ */ React2.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ React2.createElement(
109
- "span",
110
- {
111
- key: opt.value,
112
- className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
113
- id: `${id}-span-2`
114
- },
115
- opt.label,
116
- /* @__PURE__ */ React2.createElement(
117
- "button",
118
- {
119
- onClick: (e) => {
120
- e.stopPropagation();
121
- toggleValue(opt.value);
122
- },
123
- className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
124
- id: `${id}-button-1`
125
- },
126
- "\u2715"
127
- )
128
- )) : /* @__PURE__ */ React2.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
129
- /* @__PURE__ */ React2.createElement(
130
- ChevronDown,
131
- {
132
- className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
133
- }
134
- )
135
- ),
136
- !disabled && open && /* @__PURE__ */ React2.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ React2.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ React2.createElement(Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React2.createElement(
137
- "input",
138
- {
139
- type: "text",
140
- value: search,
141
- onChange: (e) => setSearch(e.target.value),
142
- placeholder: "Search...",
143
- className: "flex-1 text-sm focus:outline-none",
144
- id: `${id}-input-1`
145
- }
146
- )), /* @__PURE__ */ React2.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
147
- const selected = value.includes(opt.value);
148
- return /* @__PURE__ */ React2.createElement(
149
- "li",
150
- {
151
- key: opt.value,
152
- onClick: () => toggleValue(opt.value),
153
- className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
154
- id: `${id}-li-1`
155
- },
156
- /* @__PURE__ */ React2.createElement(
157
- "span",
158
- {
159
- className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
160
- id: `${id}-span-4`
161
- },
162
- selected && /* @__PURE__ */ React2.createElement(Check, { size: 14 })
163
- ),
164
- opt.label
165
- );
166
- }) : /* @__PURE__ */ React2.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
167
- );
168
- };
169
-
170
- // src/inputs/Checkbox.jsx
171
- import React3 from "react";
172
- var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
173
- const handleChange = (e) => {
174
- onChange(e.target.checked);
175
- };
176
- return /* @__PURE__ */ React3.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ React3.createElement(
177
- "input",
178
- {
179
- type: "checkbox",
180
- checked,
181
- onChange: handleChange,
182
- className: "peer hidden",
183
- id: `${id}-input-1`
184
- }
185
- ), /* @__PURE__ */ React3.createElement(
186
- "span",
187
- {
188
- className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
189
- id: `${id}-span-1`
190
- },
191
- checked && /* @__PURE__ */ React3.createElement(
192
- "svg",
193
- {
194
- className: "w-4 h-4 text-white",
195
- fill: "none",
196
- stroke: "currentColor",
197
- strokeWidth: "3",
198
- viewBox: "0 0 24 24",
199
- id: `${id}-svg-1`
200
- },
201
- /* @__PURE__ */ React3.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
202
- )
203
- ));
204
- };
205
-
206
- // src/inputs/Chip.jsx
207
- import React4 from "react";
208
- var VARIANTS = {
209
- PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
210
- GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
211
- RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
212
- YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
213
- };
214
- var Chip = ({ id = "chip", label, variant }) => {
215
- return /* @__PURE__ */ React4.createElement(
216
- "div",
217
- {
218
- className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
219
- id: `${id}-div-1`
220
- },
221
- label
222
- );
223
- };
224
-
225
- // src/inputs/CustomSwitch.jsx
226
- import React5 from "react";
227
- var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
228
- return /* @__PURE__ */ React5.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ React5.createElement(
229
- "button",
230
- {
231
- type: "button",
232
- role: "switch",
233
- "aria-checked": checked,
234
- onClick: () => onChange(!checked),
235
- className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
236
- id: `${id}-button-1`
237
- },
238
- /* @__PURE__ */ React5.createElement(
239
- "span",
240
- {
241
- className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
242
- id: `${id}-span-1`
243
- }
244
- )
245
- ), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ React5.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
246
- };
247
-
248
- // src/inputs/Input.jsx
249
- import React6 from "react";
250
- var CustomInput = ({
251
- id = "input",
252
- label,
253
- isRequired,
254
- value,
255
- onChange,
256
- placeholder,
257
- disabled = false,
258
- error,
259
- heading
260
- }) => {
261
- return /* @__PURE__ */ React6.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ React6.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ React6.createElement(
262
- "label",
263
- {
264
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
265
- id: `${id}-label-1`
266
- },
267
- label,
268
- " ",
269
- isRequired && /* @__PURE__ */ React6.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
270
- ), /* @__PURE__ */ React6.createElement(
271
- "input",
272
- {
273
- className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
274
- placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
275
- focus:outline-2 outline-black dark:outline-white outline-offset-2
276
- dark:bg-transparent dark:text-white dark:border-[#303036]
277
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
278
- `,
279
- value,
280
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
281
- placeholder,
282
- disabled,
283
- readOnly: disabled,
284
- id: `${id}-input-1`
285
- }
286
- ));
287
- };
288
-
289
- // src/inputs/ProgressBar.jsx
290
- import React7 from "react";
291
- var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
292
- const progress = step / totalSteps * 100;
293
- return /* @__PURE__ */ React7.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ React7.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ React7.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ React7.createElement(
294
- "div",
295
- {
296
- className: "bg-black h-2 rounded-full transition-all duration-300",
297
- style: { width: `${progress}%` },
298
- id: `${id}-div-3`
299
- }
300
- )));
301
- };
302
-
303
- // src/inputs/Search.jsx
304
- import React8 from "react";
305
- import { Search as Search2 } from "lucide-react";
306
- var CustomSearch = ({
307
- id = "search",
308
- value,
309
- onChange,
310
- placeholder = "Search Markets..."
311
- }) => {
312
- return /* @__PURE__ */ React8.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ React8.createElement(Search2, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ React8.createElement(
313
- "input",
314
- {
315
- type: "text",
316
- value,
317
- onChange,
318
- placeholder,
319
- className: "bg-transparent w-full h-full focus:outline-none",
320
- id: `${id}-input-1`
321
- }
322
- ));
323
- };
324
-
325
- // src/inputs/TextArea.jsx
326
- import React9 from "react";
327
- var CustomTextarea = ({
328
- id = "text-area",
329
- label,
330
- isRequired,
331
- value,
332
- onChange,
333
- placeholder,
334
- disabled = false,
335
- error,
336
- heading,
337
- rows = 4
338
- }) => {
339
- return /* @__PURE__ */ React9.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ React9.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ React9.createElement(
340
- "label",
341
- {
342
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
343
- id: `${id}-label-1`
344
- },
345
- label,
346
- " ",
347
- isRequired && /* @__PURE__ */ React9.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
348
- ), /* @__PURE__ */ React9.createElement(
349
- "textarea",
350
- {
351
- rows,
352
- className: `border rounded-md px-4 py-2 w-full text-[14px]
353
- focus:outline-2 focus:outline-black focus:outline-offset-2
354
- focus:ring-0 focus:shadow-none focus:border-black
355
- ${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
356
- `,
357
- value,
358
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
359
- placeholder,
360
- disabled,
361
- readOnly: disabled,
362
- id: `${id}-textarea-1`
363
- }
364
- ));
365
- };
366
-
367
- // src/inputs/Upload.jsx
368
- import React10, { useRef as useRef2 } from "react";
369
- import { Upload } from "lucide-react";
370
- var CustomUpload = ({
371
- id = "upload",
372
- label = "Supporting documents",
373
- description = "Drop items here or Browse Files",
374
- accept = ".pdf,.jpg,.jpeg,.png",
375
- maxSizeMB = 5,
376
- onChange,
377
- error,
378
- value
379
- }) => {
380
- const inputRef = useRef2(null);
381
- const handleFileSelect = (files) => {
382
- if (!files || files.length === 0) return;
383
- const selectedFile = files[0];
384
- if (selectedFile.size > maxSizeMB * 1024 * 1024) {
385
- alert(`File size must be less than ${maxSizeMB} MB`);
386
- return;
387
- }
388
- onChange == null ? void 0 : onChange(selectedFile);
389
- };
390
- return /* @__PURE__ */ React10.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ React10.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ React10.createElement(
391
- "div",
392
- {
393
- className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
394
- ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
395
- onClick: () => {
396
- var _a;
397
- return (_a = inputRef.current) == null ? void 0 : _a.click();
398
- },
399
- onDragOver: (e) => e.preventDefault(),
400
- onDrop: (e) => {
401
- e.preventDefault();
402
- handleFileSelect(e.dataTransfer.files);
403
- },
404
- id: `${id}-div-2`
405
- },
406
- /* @__PURE__ */ React10.createElement(Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
407
- /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
408
- /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
409
- /* @__PURE__ */ React10.createElement(
410
- "input",
411
- {
412
- ref: inputRef,
413
- type: "file",
414
- accept,
415
- className: "hidden",
416
- onChange: (e) => handleFileSelect(e.target.files),
417
- id: `${id}-input-1`
418
- }
419
- )
420
- ), value && /* @__PURE__ */ React10.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
421
- };
422
-
423
- // src/sideBar/SideBar.jsx
424
- import {
425
- ChevronDown as ChevronDown3,
426
- ChevronRight,
427
- CircleSlash,
428
- Globe,
429
- LogOut as LogOut3,
430
- Menu,
431
- X
432
- } from "lucide-react";
433
- import React14, { useEffect as useEffect2, useState as useState4, useCallback, useRef as useRef4 } from "react";
434
-
435
- // ConstantUI.js
436
- import {
437
- Home,
438
- Banknote,
439
- LifeBuoy,
440
- Cog,
441
- Building,
442
- Handshake,
443
- DollarSign,
444
- BarChart3
445
- } from "lucide-react";
446
- var encodedAuthData = localStorage.getItem("encodedAuthData");
447
- var navItemsConstant = [
448
- {
449
- Icon: Home,
450
- label: "Home",
451
- onClick: () => {
452
- window.location.href = "/";
453
- },
454
- isDropDown: false
455
- },
456
- {
457
- Icon: Building,
458
- label: "Consumer Ecosystem",
459
- onClick: () => {
460
- },
461
- options: [
462
- {
463
- label: "Corporate",
464
- onClick: () => {
465
- window.location.href = "/corporate/";
466
- }
467
- },
468
- {
469
- label: "Trips",
470
- onClick: () => {
471
- window.location.href = "/corporate/trips/";
472
- }
473
- },
474
- {
475
- label: "Users",
476
- onClick: () => {
477
- window.location.href = "/users/users";
478
- }
479
- },
480
- {
481
- label: "Tags (Custom Variables)",
482
- onClick: () => {
483
- window.location.href = "/orgselector/?path=tag";
484
- }
485
- },
486
- {
487
- label: "Special Request",
488
- onClick: () => {
489
- window.location.href = "/orgselector/?path=special-requests";
490
- }
491
- },
492
- {
493
- label: "Support Tickets (Coming Soon)",
494
- isDisabled: true
495
- // onClick: () => {},
496
- }
497
- ],
498
- isDropDown: true
499
- },
500
- {
501
- Icon: Banknote,
502
- label: "Finance",
503
- onClick: () => {
504
- },
505
- isDropDown: true,
506
- options: [
507
- {
508
- label: "Credit Management",
509
- onClick: () => {
510
- window.location.href = "/finance/paymentsLedger/";
511
- }
512
- },
513
- {
514
- label: "Booking & Invoices",
515
- onClick: () => {
516
- window.location.href = "/finance/bookingHistory/";
517
- }
518
- }
519
- ]
520
- },
521
- {
522
- Icon: DollarSign,
523
- label: "Revenue Management",
524
- onClick: () => {
525
- },
526
- isDropDown: true,
527
- options: [
528
- {
529
- label: "Pricing Engine",
530
- onClick: () => {
531
- window.location.href = "/orgselector/?path=pricing-policy";
532
- }
533
- },
534
- {
535
- label: "Offers",
536
- onClick: () => {
537
- window.location.href = "/orgselector/?path=offer";
538
- }
539
- },
540
- {
541
- label: "Vouchers",
542
- onClick: () => {
543
- window.location.href = "/orgselector/?path=voucher";
544
- }
545
- }
546
- ]
547
- },
548
- {
549
- Icon: Handshake,
550
- label: "Supplier Ecosystem",
551
- onClick: () => {
552
- },
553
- isDropDown: true,
554
- options: [
555
- {
556
- label: "Suppliers List",
557
- onClick: () => {
558
- window.location.href = "/orgselector/?path=supplier-list";
559
- }
560
- },
561
- {
562
- label: "Supplier Deals",
563
- onClick: () => {
564
- window.location.href = "/supplierdeals/";
565
- }
566
- }
567
- ]
568
- },
569
- {
570
- Icon: BarChart3,
571
- label: "Reports",
572
- onClick: () => {
573
- },
574
- isDropDown: true,
575
- options: [
576
- {
577
- label: "Reports",
578
- onClick: () => {
579
- window.location.href = "/reports/";
580
- }
581
- }
582
- ]
583
- },
584
- {
585
- Icon: Cog,
586
- label: "Settings",
587
- onClick: () => {
588
- },
589
- isDropDown: true,
590
- options: [
591
- {
592
- label: "Whitelabel",
593
- onClick: () => {
594
- window.location.href = "/whitelabel/";
595
- }
596
- },
597
- {
598
- label: "Markets",
599
- onClick: () => {
600
- window.location.href = "/market/";
601
- }
602
- },
603
- {
604
- label: "Users",
605
- onClick: () => {
606
- window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
607
- }
608
- },
609
- {
610
- label: "Reports Configurations",
611
- onClick: () => {
612
- window.location.href = "/reports/";
613
- }
614
- }
615
- ]
616
- }
617
- ];
618
- var additionalItemsConstant = [
619
- {
620
- Icon: LifeBuoy,
621
- label: "Help",
622
- onClick: () => {
623
- window.location.href = "/help";
624
- }
625
- }
626
- ];
627
-
628
- // src/sideBar/SideBar.jsx
629
- import Cookies from "js-cookie";
630
-
631
- // src/inputs/CustomSelect.jsx
632
- import React11, { useState as useState2, useRef as useRef3 } from "react";
633
- import { ChevronDown as ChevronDown2, Search as Search3 } from "lucide-react";
634
- var CustomSelect = ({
635
- id = "custom-select",
636
- label,
637
- value,
638
- onChange,
639
- options,
640
- placeholder = "Select...",
641
- isRequired = false,
642
- error,
643
- heading,
644
- disabled = false
645
- }) => {
646
- const [open, setOpen] = useState2(false);
647
- const [search, setSearch] = useState2("");
648
- const wrapperRef = useRef3(null);
649
- const handleBlur = (e) => {
650
- var _a;
651
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
652
- setOpen(false);
653
- }
654
- };
655
- const filteredOptions = options.filter(
656
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
657
- );
658
- const handleSelect = (val) => {
659
- onChange(val);
660
- setOpen(false);
661
- };
662
- const selectedOption = options.find((opt) => opt.value === value);
663
- return /* @__PURE__ */ React11.createElement(
664
- "div",
665
- {
666
- className: "flex flex-col w-full relative",
667
- ref: wrapperRef,
668
- tabIndex: disabled ? -1 : 0,
669
- onBlur: handleBlur,
670
- id: `${id}-div-1`
671
- },
672
- heading && /* @__PURE__ */ React11.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
673
- label && /* @__PURE__ */ React11.createElement(
674
- "label",
675
- {
676
- className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
677
- id: `${id}-label-1`
678
- },
679
- label,
680
- " ",
681
- isRequired && /* @__PURE__ */ React11.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
682
- ),
683
- /* @__PURE__ */ React11.createElement(
684
- "div",
685
- {
686
- onClick: () => !disabled && setOpen((prev) => !prev),
687
- className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
688
- ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
689
- ${error ? "border-red-500" : "border-gray-300"}
690
- `,
691
- id: `${id}-div-2`
692
- },
693
- /* @__PURE__ */ React11.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
694
- /* @__PURE__ */ React11.createElement(
695
- ChevronDown2,
696
- {
697
- className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
698
- }
699
- )
700
- ),
701
- open && !disabled && /* @__PURE__ */ React11.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ React11.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ React11.createElement(Search3, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React11.createElement(
702
- "input",
703
- {
704
- type: "text",
705
- value: search,
706
- onChange: (e) => setSearch(e.target.value),
707
- placeholder: "Search...",
708
- className: "flex-1 text-sm focus:outline-none",
709
- id: `${id}-input-1`
710
- }
711
- )), /* @__PURE__ */ React11.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ React11.createElement(
712
- "li",
713
- {
714
- key: opt.value,
715
- onClick: () => handleSelect(opt.value),
716
- className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
717
- id: `${id}-li-1`
718
- },
719
- opt.label
720
- )) : /* @__PURE__ */ React11.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
721
- );
722
- };
723
-
724
- // src/utils/cookieHelpers.js
725
- var JETT_ID_COOKIE_NAME = "jett-id";
726
- function getCookie(name) {
727
- if (typeof document === "undefined" || !document.cookie) return null;
728
- const match = document.cookie.match(
729
- new RegExp("(^|\\s)" + name + "=([^;]+)")
730
- );
731
- return match ? decodeURIComponent(match[2].trim()) : null;
732
- }
733
- function decodeBase64(value) {
734
- try {
735
- let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
736
- const pad = base64.length % 4;
737
- if (pad) base64 += "=".repeat(4 - pad);
738
- return atob(base64);
739
- } catch {
740
- return "";
741
- }
742
- }
743
- function getJettIdCookieData() {
744
- const raw = getCookie(JETT_ID_COOKIE_NAME);
745
- if (!raw) return null;
746
- try {
747
- const decoded = decodeBase64(raw);
748
- if (!decoded) return null;
749
- const data = JSON.parse(decoded);
750
- return data && typeof data === "object" ? data : null;
751
- } catch {
752
- return null;
753
- }
754
- }
755
- function getLogoFromJettIdCookie() {
756
- const data = getJettIdCookieData();
757
- if (!(data == null ? void 0 : data.CDNBasePath)) return null;
758
- const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
759
- if (!logoPath) return null;
760
- return {
761
- logoPath,
762
- CDNBasePath: data.CDNBasePath
763
- };
764
- }
765
- function getScopeFromJettIdCookie() {
766
- const data = getJettIdCookieData();
767
- return (data == null ? void 0 : data.Scope) ?? null;
768
- }
769
- function getProfilesFromJettIdCookie(all) {
770
- const data = getJettIdCookieData();
771
- if (!(data == null ? void 0 : data.Profiles)) return [];
772
- if (all) return data.Profiles;
773
- return data.Profiles.filter((profile) => {
774
- var _a;
775
- return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
776
- });
777
- }
778
- function buildLogoUrl(CDNBasePath, logoPath) {
779
- const base = (CDNBasePath || "").replace(/\/$/, "");
780
- const path = (logoPath || "").replace(/^\//, "");
781
- if (!base || !path) return "";
782
- return `${base}/${path}`;
783
- }
784
-
785
- // src/sideBar/SwitchProfileSection.jsx
786
- import React13, { useEffect, useLayoutEffect, useState as useState3 } from "react";
787
- import { createPortal as createPortal2 } from "react-dom";
788
- import { LogOut as LogOut2, SlidersHorizontal } from "lucide-react";
789
-
790
- // src/sideBar/LogoutConfirmModal.jsx
791
- import React12 from "react";
792
- import { createPortal } from "react-dom";
793
- import { LogOut } from "lucide-react";
794
- var LogoutConfirmModal = ({
795
- id = "logout-confirm",
796
- open,
797
- onConfirm,
798
- onCancel,
799
- loading = false
800
- }) => {
801
- if (!open || typeof document === "undefined") return null;
802
- const handleOverlayClick = (e) => {
803
- if (e.target === e.currentTarget && !loading) onCancel();
804
- };
805
- return createPortal(
806
- /* @__PURE__ */ React12.createElement(
807
- "div",
808
- {
809
- className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
810
- onClick: handleOverlayClick,
811
- id: `${id}-overlay`
812
- },
813
- /* @__PURE__ */ React12.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ React12.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ React12.createElement(LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ React12.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ React12.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ React12.createElement(
814
- "button",
815
- {
816
- type: "button",
817
- onClick: onCancel,
818
- disabled: loading,
819
- className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
820
- id: `${id}-cancel-button`
821
- },
822
- "No, Keep me in"
823
- ), /* @__PURE__ */ React12.createElement(
824
- "button",
825
- {
826
- type: "button",
827
- onClick: onConfirm,
828
- disabled: loading,
829
- className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
830
- id: `${id}-confirm-button`
831
- },
832
- loading ? "Logging out..." : "Yes, logout"
833
- )))
834
- ),
835
- document.body
836
- );
837
- };
838
-
839
- // src/utils/switchProfileEncryption.js
840
- import forge from "node-forge";
841
- var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
842
- var RSA_EXPONENT_BASE64 = "AQAB";
843
- var convertModulusExponentToPem = (modulus, exponent) => {
844
- const decodedModulus = forge.util.decode64(modulus);
845
- const decodedExponent = forge.util.decode64(exponent);
846
- const publicKey = forge.pki.setRsaPublicKey(
847
- new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedModulus), 16),
848
- new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedExponent), 16)
849
- );
850
- return forge.pki.publicKeyToPem(publicKey);
851
- };
852
- var cachedPemKey = null;
853
- var getPemKey = () => {
854
- if (!cachedPemKey) {
855
- cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
856
- }
857
- return cachedPemKey;
858
- };
859
- var encryptForSwitchProfile = (plainText) => {
860
- const publicKey = forge.pki.publicKeyFromPem(getPemKey());
861
- const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
862
- return forge.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
863
- };
864
-
865
- // src/sideBar/SwitchProfileSection.jsx
866
- var SwitchProfileSection = ({
867
- id = "switch-profile",
868
- open,
869
- anchorRef,
870
- onClose,
871
- onManageProfile,
872
- onProfileSwitch,
873
- onTmcSettings,
874
- onLogout
875
- }) => {
876
- const [position, setPosition] = useState3(null);
877
- const [showLogoutConfirm, setShowLogoutConfirm] = useState3(false);
878
- const [switchingProfileId, setSwitchingProfileId] = useState3(null);
879
- const [switchError, setSwitchError] = useState3(null);
880
- useLayoutEffect(() => {
881
- if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
882
- const updatePosition = () => {
883
- const rect = anchorRef.current.getBoundingClientRect();
884
- setPosition({
885
- left: rect.right + 2,
886
- bottom: window.innerHeight - rect.bottom
887
- });
888
- };
889
- updatePosition();
890
- window.addEventListener("resize", updatePosition);
891
- window.addEventListener("scroll", updatePosition, true);
892
- return () => {
893
- window.removeEventListener("resize", updatePosition);
894
- window.removeEventListener("scroll", updatePosition, true);
895
- };
896
- }, [open, anchorRef]);
897
- useEffect(() => {
898
- if (!open) setSwitchError(null);
899
- }, [open]);
900
- useEffect(() => {
901
- if (!switchError) return;
902
- const timer = setTimeout(() => setSwitchError(null), 5e3);
903
- return () => clearTimeout(timer);
904
- }, [switchError]);
905
- if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
906
- const jettIdData = getJettIdCookieData();
907
- const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
908
- const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
909
- const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
910
- const allMarkets = getProfilesFromJettIdCookie(true);
911
- const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
912
- const handleConfirmLogout = () => {
913
- setShowLogoutConfirm(false);
914
- onLogout == null ? void 0 : onLogout();
915
- };
916
- const buildRequestContext = () => ({
917
- UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
918
- TrackingId: crypto.randomUUID(),
919
- TransactionId: crypto.randomUUID(),
920
- CountryCode: "IN",
921
- IpAddress: "127.0.0.1"
922
- // Client IP cannot be retrieved from browser
923
- });
924
- const handleProfileSwitch = async (profile) => {
925
- var _a, _b, _c;
926
- if (switchingProfileId) return;
927
- setSwitchingProfileId(profile.ProfileId);
928
- setSwitchError(null);
929
- try {
930
- const encryptedRequest = encryptForSwitchProfile(
931
- JSON.stringify({
932
- ProfileToken: profile.ProfileToken,
933
- ProfileId: profile.ProfileId
934
- })
935
- );
936
- const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
937
- method: "POST",
938
- credentials: "include",
939
- headers: { "Content-Type": "application/json" },
940
- body: JSON.stringify({
941
- Context: buildRequestContext(),
942
- Request: encryptedRequest
943
- })
944
- }).then((res) => res.json());
945
- const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
946
- const isSuccess = !statusCode || statusCode === 200;
947
- if (!isSuccess) {
948
- setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
949
- setSwitchingProfileId(null);
950
- return;
951
- }
952
- if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
953
- window.location.href = response.Response.RedirectUrl;
954
- return;
955
- }
956
- setSwitchingProfileId(null);
957
- onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
958
- } catch (error) {
959
- console.error("Switch profile request failed:", error);
960
- setSwitchError("Something went wrong while switching profile. Please try again.");
961
- setSwitchingProfileId(null);
962
- }
963
- };
964
- return /* @__PURE__ */ React13.createElement(React13.Fragment, null, open && createPortal2(
965
- /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ React13.createElement(
966
- "div",
967
- {
968
- className: "fixed w-[320px] max-h-[75vh] flex p-4 flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
969
- style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
970
- id: `${id}-panel`
971
- },
972
- /* @__PURE__ */ React13.createElement("div", { className: "flex items-center justify-between gap-3 pb-4", id: `${id}-header` }, /* @__PURE__ */ React13.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ React13.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ React13.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border-2 border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "40 * 40")), /* @__PURE__ */ React13.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ React13.createElement("p", { className: "!font-semibold dark:text-white !text-[14px] truncate" }, userName || "Admin"), /* @__PURE__ */ React13.createElement("p", { className: "!text-[10px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ React13.createElement(
973
- "button",
974
- {
975
- type: "button",
976
- onClick: onManageProfile,
977
- className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[10px] font-bold uppercase tracking-wide text-[#0A0A0A] dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
978
- id: `${id}-manage-profile-button`
979
- },
980
- "Manage Profile"
981
- )),
982
- /* @__PURE__ */ React13.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
983
- /* @__PURE__ */ React13.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ React13.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ React13.createElement(
984
- "div",
985
- {
986
- className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
987
- id: `${id}-switch-error`
988
- },
989
- switchError
990
- ), /* @__PURE__ */ React13.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ React13.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
991
- const isCurrent = profile.ProfileId === currentProfileId;
992
- const isSwitching = switchingProfileId === profile.ProfileId;
993
- return /* @__PURE__ */ React13.createElement(
994
- "div",
995
- {
996
- key: profile.ProfileId,
997
- onClick: () => !isCurrent && handleProfileSwitch(profile),
998
- "aria-disabled": isSwitching,
999
- className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white bg-[#f4f4f5] text-[#0A0A0A]" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
1000
- id: `${id}-market-${profile.ProfileId}`
1001
- },
1002
- /* @__PURE__ */ React13.createElement("span", { className: "!font-bold !text-[14px] text-gray-900 dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
1003
- isCurrent && /* @__PURE__ */ React13.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 border-2 border-white text-[9px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
1004
- isSwitching && /* @__PURE__ */ React13.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
1005
- );
1006
- }))),
1007
- /* @__PURE__ */ React13.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
1008
- /* @__PURE__ */ React13.createElement("div", { className: "", id: `${id}-footer` }, /* @__PURE__ */ React13.createElement(
1009
- "div",
1010
- {
1011
- onClick: () => {
1012
- onClose == null ? void 0 : onClose();
1013
- setShowLogoutConfirm(true);
1014
- },
1015
- className: "flex items-center gap-3 p-3 rounded-lg cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
1016
- id: `${id}-logout`
1017
- },
1018
- /* @__PURE__ */ React13.createElement(LogOut2, { width: 18, height: 18 }),
1019
- /* @__PURE__ */ React13.createElement("span", { className: "!font-bold !text-[14px]" }, "Logout")
1020
- ))
1021
- )),
1022
- document.body
1023
- ), /* @__PURE__ */ React13.createElement(
1024
- LogoutConfirmModal,
1025
- {
1026
- id: `${id}-logout-confirm`,
1027
- open: showLogoutConfirm,
1028
- onCancel: () => setShowLogoutConfirm(false),
1029
- onConfirm: handleConfirmLogout
1030
- }
1031
- ));
1032
- };
1033
-
1034
- // src/sideBar/SideBar.jsx
1035
- var SCOPE_LABELS = {
1036
- TMC: "TMC Manager",
1037
- TMC_ENTITY: "TMC Entity Manager"
1038
- };
1039
- var AppSideBar = ({
1040
- id = "side-bar",
1041
- username,
1042
- navItems,
1043
- additionalItems,
1044
- sideBarLogo,
1045
- onManageProfile,
1046
- onProfileSwitch,
1047
- onTmcSettings,
1048
- onLogout
1049
- }) => {
1050
- var _a, _b;
1051
- const profileCardRef = useRef4(null);
1052
- const [authData, setAuthData] = useState4(null);
1053
- const [cookieUserName, setCookieUserName] = useState4(null);
1054
- const [scope, setScope] = useState4(null);
1055
- const [selectedCountry, setSelectedCountry] = useState4("dubai");
1056
- const [isMobileMenuOpen, setIsMobileMenuOpen] = useState4(false);
1057
- const [isSwitchProfileOpen, setIsSwitchProfileOpen] = useState4(false);
1058
- const [openMenus, setOpenMenus] = useState4(/* @__PURE__ */ new Set());
1059
- const [activeMenuPath, setActiveMenuPath] = useState4(null);
1060
- const [currAppearance, setCurrAppearance] = useState4("light");
1061
- useEffect2(() => {
1062
- setCurrAppearance("light");
1063
- }, []);
1064
- const countryOptions = [
1065
- { label: "India", value: "india" },
1066
- { label: "Dubai", value: "dubai" },
1067
- { label: "Singapore", value: "singapore" },
1068
- { label: "Qatar", value: "qatar" }
1069
- ];
1070
- const toggleMenu = (menuKey) => {
1071
- setOpenMenus((prev) => {
1072
- const newSet = new Set(prev);
1073
- if (newSet.has(menuKey)) {
1074
- newSet.delete(menuKey);
1075
- } else {
1076
- newSet.add(menuKey);
1077
- }
1078
- return newSet;
1079
- });
1080
- };
1081
- const isMenuOpen = (menuKey) => {
1082
- return openMenus.has(menuKey);
1083
- };
1084
- const handleMenuClick = (item, index, e) => {
1085
- if (item.isDropDown) {
1086
- e.preventDefault();
1087
- const menuKey = `menu-${index}`;
1088
- toggleMenu(menuKey);
1089
- setActiveMenuPath(`menu-${index}`);
1090
- } else {
1091
- setActiveMenuPath(`menu-${index}`);
1092
- if (item.onClick) {
1093
- item.onClick(e);
1094
- }
1095
- closeMobileMenu();
1096
- }
1097
- };
1098
- const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
1099
- const parentMenuKey = `menu-${parentIndex}`;
1100
- setOpenMenus((prev) => {
1101
- const newSet = new Set(prev);
1102
- newSet.add(parentMenuKey);
1103
- return newSet;
1104
- });
1105
- if (option.isDropDown) {
1106
- e.preventDefault();
1107
- const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1108
- toggleMenu(menuKey);
1109
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1110
- } else {
1111
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1112
- if (option.onClick) {
1113
- option.onClick();
1114
- }
1115
- closeMobileMenu();
1116
- }
1117
- };
1118
- const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
1119
- const parentMenuKey = `menu-${parentIndex}`;
1120
- const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1121
- setOpenMenus((prev) => {
1122
- const newSet = new Set(prev);
1123
- newSet.add(parentMenuKey);
1124
- newSet.add(subMenuKey);
1125
- return newSet;
1126
- });
1127
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
1128
- if (subOption.onClick) {
1129
- subOption.onClick();
1130
- }
1131
- closeMobileMenu();
1132
- };
1133
- useEffect2(() => {
1134
- const storedAuthData = localStorage.getItem("authData");
1135
- if (storedAuthData) {
1136
- let parseData = JSON.parse(storedAuthData);
1137
- setAuthData(parseData);
1138
- }
1139
- }, [localStorage.getItem("authData")]);
1140
- useEffect2(() => {
1141
- const jettIdData = getJettIdCookieData();
1142
- if (jettIdData == null ? void 0 : jettIdData.UserName) {
1143
- setCookieUserName(jettIdData.UserName);
1144
- }
1145
- const cookieScope = getScopeFromJettIdCookie();
1146
- if (cookieScope) {
1147
- setScope(cookieScope);
1148
- }
1149
- }, []);
1150
- const extractUrlFromOnClick = (onClick) => {
1151
- if (!onClick || typeof onClick !== "function") return null;
1152
- const funcString = onClick.toString();
1153
- let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
1154
- if (!match) {
1155
- match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
1156
- }
1157
- if (match && match[1]) {
1158
- try {
1159
- if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
1160
- const url = new URL(match[1]);
1161
- return {
1162
- pathname: url.pathname,
1163
- search: url.search,
1164
- fullPath: url.pathname + url.search
1165
- };
1166
- }
1167
- if (match[1].startsWith("/")) {
1168
- const url = new URL(match[1], window.location.origin);
1169
- return {
1170
- pathname: url.pathname,
1171
- search: url.search,
1172
- fullPath: url.pathname + url.search
1173
- };
1174
- }
1175
- return null;
1176
- } catch {
1177
- const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
1178
- if (pathMatch) {
1179
- return {
1180
- pathname: pathMatch[1],
1181
- search: pathMatch[2] || "",
1182
- fullPath: match[1]
1183
- };
1184
- }
1185
- return null;
1186
- }
1187
- }
1188
- return null;
1189
- };
1190
- const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
1191
- if (!menuUrlData || !currentPath) return false;
1192
- const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
1193
- const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
1194
- if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
1195
- const menuParams = new URLSearchParams(menuUrlData.search);
1196
- const currentParams = new URLSearchParams(currentSearch);
1197
- const menuRole = menuParams.get("role");
1198
- const currentRole = currentParams.get("role");
1199
- if (menuRole && currentRole) {
1200
- return menuRole === currentRole;
1201
- }
1202
- if (menuRole && !currentRole || !menuRole && currentRole) {
1203
- return false;
1204
- }
1205
- return true;
1206
- }
1207
- if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
1208
- return true;
1209
- }
1210
- if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
1211
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1212
- if (currentPathParam === "supplier-list") {
1213
- return true;
1214
- }
1215
- }
1216
- if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
1217
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1218
- if (currentPathParam === "supplier-deals") {
1219
- return true;
1220
- }
1221
- }
1222
- if (normalizedMenuPath === "/corporate/trips") {
1223
- if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
1224
- return true;
1225
- }
1226
- }
1227
- if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
1228
- const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
1229
- if (menuPathParam) {
1230
- const pathRouteMap = {
1231
- "offer": "/offer/offer",
1232
- "voucher": "/voucher/voucher",
1233
- "tag": "/tags/tags",
1234
- "special-requests": "/corporate/special-requests",
1235
- "pricing-policy": "/policies/pricing-policy",
1236
- "supplier-list": "/supplier",
1237
- "users": "/users/users"
1238
- // Consumer Ecosystem Users (no role param)
1239
- };
1240
- const expectedRoute = pathRouteMap[menuPathParam];
1241
- if (expectedRoute) {
1242
- if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1243
- if (menuPathParam === "users") {
1244
- const currentParams = new URLSearchParams(currentSearch);
1245
- const currentRole = currentParams.get("role");
1246
- return currentRole !== "admin";
1247
- }
1248
- return true;
1249
- }
1250
- }
1251
- }
1252
- if (normalizedCurrentPath === "/orgselector") {
1253
- const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1254
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1255
- if (menuPathParam2 && currentPathParam) {
1256
- return menuPathParam2 === currentPathParam;
1257
- }
1258
- }
1259
- }
1260
- if (normalizedMenuPath === normalizedCurrentPath) {
1261
- if (menuUrlData.search) {
1262
- const menuParams = new URLSearchParams(menuUrlData.search);
1263
- const currentParams = new URLSearchParams(currentSearch);
1264
- for (const [key, value] of menuParams.entries()) {
1265
- if (key === "auth") {
1266
- continue;
1267
- }
1268
- if (currentParams.get(key) !== value) {
1269
- return false;
1270
- }
1271
- }
1272
- return true;
1273
- }
1274
- return true;
1275
- }
1276
- if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1277
- return true;
1278
- }
1279
- return false;
1280
- };
1281
- const navItemsLocal = navItems ?? navItemsConstant;
1282
- const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
1283
- const logoFromCookie = getLogoFromJettIdCookie();
1284
- const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1285
- const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
1286
- authData.userInfo.CDNBasePath,
1287
- authData.userInfo.OrgLogo
1288
- ) : null;
1289
- const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1290
- const detectAndSetActiveMenu = useCallback(() => {
1291
- const currentPath = window.location.pathname;
1292
- const currentSearch = window.location.search;
1293
- const newOpenMenus = /* @__PURE__ */ new Set();
1294
- let foundActivePath = null;
1295
- navItemsLocal.forEach((item, index) => {
1296
- if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1297
- const itemUrlData = extractUrlFromOnClick(item.onClick);
1298
- if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1299
- foundActivePath = `menu-${index}`;
1300
- }
1301
- }
1302
- if (item.options && item.options.length > 0) {
1303
- item.options.forEach((option, optionsIndex) => {
1304
- if (option.onClick && typeof option.onClick === "function") {
1305
- const optionUrlData = extractUrlFromOnClick(option.onClick);
1306
- if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1307
- const menuKey = `menu-${index}`;
1308
- newOpenMenus.add(menuKey);
1309
- foundActivePath = `menu-${index}-option-${optionsIndex}`;
1310
- if (option.options && option.options.length > 0) {
1311
- option.options.forEach((subOption, subIndex) => {
1312
- const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1313
- if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1314
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1315
- newOpenMenus.add(subMenuKey);
1316
- foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1317
- }
1318
- });
1319
- }
1320
- }
1321
- }
1322
- });
1323
- }
1324
- });
1325
- if (foundActivePath) {
1326
- setOpenMenus(newOpenMenus);
1327
- setActiveMenuPath(foundActivePath);
1328
- }
1329
- }, [navItemsLocal]);
1330
- const [currentUrl, setCurrentUrl] = useState4(
1331
- () => window.location.pathname + window.location.search
1332
- );
1333
- useEffect2(() => {
1334
- detectAndSetActiveMenu();
1335
- setCurrentUrl(window.location.pathname + window.location.search);
1336
- }, [detectAndSetActiveMenu]);
1337
- useEffect2(() => {
1338
- let lastUrl = window.location.pathname + window.location.search;
1339
- const handleLocationChange = () => {
1340
- const newUrl = window.location.pathname + window.location.search;
1341
- if (newUrl !== lastUrl) {
1342
- lastUrl = newUrl;
1343
- setCurrentUrl(newUrl);
1344
- detectAndSetActiveMenu();
1345
- }
1346
- };
1347
- window.addEventListener("popstate", handleLocationChange);
1348
- const checkInterval = setInterval(() => {
1349
- const newUrl = window.location.pathname + window.location.search;
1350
- if (newUrl !== lastUrl) {
1351
- handleLocationChange();
1352
- }
1353
- }, 250);
1354
- return () => {
1355
- window.removeEventListener("popstate", handleLocationChange);
1356
- clearInterval(checkInterval);
1357
- };
1358
- }, [detectAndSetActiveMenu]);
1359
- useEffect2(() => {
1360
- detectAndSetActiveMenu();
1361
- }, [currentUrl, detectAndSetActiveMenu]);
1362
- const toggleMobileMenu = () => {
1363
- setIsMobileMenuOpen(!isMobileMenuOpen);
1364
- };
1365
- const closeMobileMenu = () => {
1366
- setIsMobileMenuOpen(false);
1367
- };
1368
- return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ React14.createElement(
1369
- "button",
1370
- {
1371
- onClick: toggleMobileMenu,
1372
- className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
1373
- "aria-label": "Toggle menu",
1374
- id: `${id}-button-1`
1375
- },
1376
- isMobileMenuOpen ? /* @__PURE__ */ React14.createElement(X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ React14.createElement(Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
1377
- ), /* @__PURE__ */ React14.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ React14.createElement(
1378
- "img",
1379
- {
1380
- src: sideBarLogoLocal,
1381
- alt: "sidebarLogo",
1382
- width: 208,
1383
- height: 40,
1384
- className: "object-contain",
1385
- id: `${id}-img-1`
1386
- }
1387
- )), /* @__PURE__ */ React14.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ React14.createElement(
1388
- "div",
1389
- {
1390
- className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1391
- onClick: closeMobileMenu,
1392
- id: `${id}-div-4`
1393
- }
1394
- ), /* @__PURE__ */ React14.createElement(
1395
- "div",
1396
- {
1397
- className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
1398
- id: `${id}-div-5`
1399
- },
1400
- /* @__PURE__ */ React14.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ React14.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ React14.createElement(
1401
- "img",
1402
- {
1403
- src: sideBarLogoLocal,
1404
- alt: "sidebarLogo",
1405
- width: 108,
1406
- height: 40,
1407
- className: "object-contain",
1408
- id: `${id}-img-2`
1409
- }
1410
- ))),
1411
- /* @__PURE__ */ React14.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
1412
- /* @__PURE__ */ React14.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1413
- const menuKey = `menu-${index}`;
1414
- const isOpen = isMenuOpen(menuKey);
1415
- const isActive = activeMenuPath === menuKey;
1416
- return /* @__PURE__ */ React14.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ React14.createElement(
1417
- "div",
1418
- {
1419
- className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1420
- onClick: (e) => handleMenuClick(item, index, e),
1421
- id: `${id}-div-12`
1422
- },
1423
- /* @__PURE__ */ React14.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ React14.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
1424
- /* @__PURE__ */ React14.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
1425
- item.isDropDown && /* @__PURE__ */ React14.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ React14.createElement(ChevronDown3, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1426
- ), item.options && item.options.length > 0 && /* @__PURE__ */ React14.createElement(
1427
- "div",
1428
- {
1429
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1430
- id: `${id}-div-15`
1431
- },
1432
- item.options.map((options, optionsIndex) => {
1433
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1434
- const isSubMenuOpen = isMenuOpen(subMenuKey);
1435
- const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1436
- const isDisabled = options.isDisabled;
1437
- return /* @__PURE__ */ React14.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ React14.createElement(
1438
- "div",
1439
- {
1440
- className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
1441
- onClick: (e) => {
1442
- if (isDisabled) {
1443
- e.preventDefault();
1444
- return;
1445
- }
1446
- handleSubMenuClick(options, optionsIndex, index, e);
1447
- },
1448
- id: `${id}-div-17-${optionsIndex}`
1449
- },
1450
- /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
1451
- /* @__PURE__ */ React14.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
1452
- options.isDropDown && /* @__PURE__ */ React14.createElement(
1453
- "div",
1454
- {
1455
- className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
1456
- id: `${id}-div-19-${optionsIndex}`
1457
- },
1458
- /* @__PURE__ */ React14.createElement(ChevronDown3, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1459
- )
1460
- ), options.options && options.options.length > 0 && /* @__PURE__ */ React14.createElement(
1461
- "div",
1462
- {
1463
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1464
- id: `${id}-div-20-${optionsIndex}`
1465
- },
1466
- options.options.map((subOption, subIndex) => {
1467
- const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1468
- return /* @__PURE__ */ React14.createElement(
1469
- "div",
1470
- {
1471
- key: subIndex,
1472
- className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1473
- onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
1474
- id: `${id}-div-21-${subIndex}`
1475
- },
1476
- subOption.label
1477
- );
1478
- })
1479
- ));
1480
- })
1481
- ));
1482
- }))),
1483
- /* @__PURE__ */ React14.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ React14.createElement(
1484
- "div",
1485
- {
1486
- className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1487
- onClick: () => setIsSwitchProfileOpen((prev) => !prev),
1488
- id: `${id}-div-23`
1489
- },
1490
- /* @__PURE__ */ React14.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ React14.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ React14.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ React14.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ React14.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
1491
- /* @__PURE__ */ React14.createElement(
1492
- "span",
1493
- {
1494
- className: "text-gray-600 dark:text-gray-400",
1495
- id: `${id}-span-switch`
1496
- },
1497
- /* @__PURE__ */ React14.createElement(ChevronRight, { width: 20, height: 22 })
1498
- )
1499
- ), /* @__PURE__ */ React14.createElement(
1500
- SwitchProfileSection,
1501
- {
1502
- id: `${id}-switch-profile`,
1503
- open: isSwitchProfileOpen,
1504
- anchorRef: profileCardRef,
1505
- onClose: () => setIsSwitchProfileOpen(false),
1506
- onManageProfile: () => {
1507
- setIsSwitchProfileOpen(false);
1508
- window.location.href = "/profile";
1509
- },
1510
- onProfileSwitch: (profile) => {
1511
- setIsSwitchProfileOpen(false);
1512
- onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
1513
- },
1514
- onTmcSettings: () => {
1515
- setIsSwitchProfileOpen(false);
1516
- onTmcSettings == null ? void 0 : onTmcSettings();
1517
- },
1518
- onLogout: () => {
1519
- setIsSwitchProfileOpen(false);
1520
- if (onLogout) {
1521
- onLogout();
1522
- } else {
1523
- window.location.href = `${window.location.origin}/login/logout`;
1524
- }
1525
- }
1526
- }
1527
- ))
1528
- ));
1529
- };
1530
-
1531
- // src/RightSheet/RightSheet.jsx
1532
- import React15, { useEffect as useEffect3, useState as useState5 } from "react";
1533
- var RightSheet = ({
1534
- id = "right-sheet",
1535
- open,
1536
- setOpen,
1537
- children,
1538
- callBack,
1539
- actionLabel = "Save",
1540
- onAction = () => {
1541
- },
1542
- showFooter = true
1543
- }) => {
1544
- const [visible, setVisible] = useState5(open);
1545
- useEffect3(() => {
1546
- if (open) {
1547
- document.body.style.overflow = "hidden";
1548
- setVisible(true);
1549
- }
1550
- return () => {
1551
- document.body.style.overflow = "auto";
1552
- };
1553
- }, [open]);
1554
- const handleClose = () => {
1555
- setVisible(false);
1556
- setTimeout(() => {
1557
- setOpen(false);
1558
- callBack();
1559
- }, 200);
1560
- };
1561
- const handleAction = () => {
1562
- onAction();
1563
- handleClose();
1564
- };
1565
- if (!visible) return null;
1566
- return /* @__PURE__ */ React15.createElement(
1567
- "div",
1568
- {
1569
- className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1570
- onClick: handleClose,
1571
- id: `${id}-div-1`
1572
- },
1573
- /* @__PURE__ */ React15.createElement(
1574
- "div",
1575
- {
1576
- className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1577
- ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1578
- onClick: (e) => e.stopPropagation(),
1579
- id: `${id}-div-2`
1580
- },
1581
- /* @__PURE__ */ React15.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1582
- showFooter && /* @__PURE__ */ React15.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ React15.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ React15.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1583
- )
1584
- );
1585
- };
1586
-
1587
- // src/Table/CustomTable.jsx
1588
- import React16 from "react";
1589
- var CustomTable = ({
1590
- id = "custom-table",
1591
- tableHeader,
1592
- setIsAllChecked,
1593
- isAllChecked,
1594
- children,
1595
- isHideCheckbox = "false"
1596
- }) => {
1597
- return /* @__PURE__ */ React16.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ React16.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ React16.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ React16.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ React16.createElement(
1598
- "tr",
1599
- {
1600
- className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1601
- id: `${id}-tr-1`
1602
- },
1603
- !isHideCheckbox && /* @__PURE__ */ React16.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ React16.createElement(
1604
- CustomCheckbox,
1605
- {
1606
- checked: isAllChecked,
1607
- onChange: () => {
1608
- setIsAllChecked(!isAllChecked);
1609
- },
1610
- id: `${id}-custom-checkbox-1`
1611
- }
1612
- )),
1613
- tableHeader.map((header, index) => {
1614
- return /* @__PURE__ */ React16.createElement(
1615
- "th",
1616
- {
1617
- className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1618
- key: header + index,
1619
- id: `${id}-th-2-${index}`
1620
- },
1621
- header
1622
- );
1623
- })
1624
- )), /* @__PURE__ */ React16.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1625
- };
1626
-
1627
- // src/inputs/Dropdown.jsx
1628
- import React17, { useId, useMemo } from "react";
1629
- import ReactSelect from "react-select";
1630
- var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
1631
- function buildStyles(isDark, error) {
1632
- return {
1633
- control: (base, state) => ({
1634
- ...base,
1635
- minHeight: "40px !important",
1636
- fontSize: 14,
1637
- borderRadius: "6px",
1638
- boxShadow: "none",
1639
- backgroundColor: state.isDisabled ? "#f3f4f6" : error ? "#fef2f2" : isDark ? "#18181b" : "#ffffff",
1640
- borderColor: state.isDisabled ? "#d1d5db" : error ? "#ef4444" : isDark ? "#303036" : "#e5e5e5",
1641
- outline: state.isFocused ? "2px solid #000" : "none",
1642
- outlineOffset: "2px",
1643
- "&:hover": {
1644
- borderColor: error ? "#ef4444" : "none"
1645
- }
1646
- }),
1647
- menu: (base) => ({
1648
- ...base,
1649
- backgroundColor: isDark ? "#18181b" : "#ffffff",
1650
- zIndex: 9999
1651
- }),
1652
- menuPortal: (base) => ({ ...base, zIndex: 9999 }),
1653
- option: (base, state) => ({
1654
- ...base,
1655
- fontSize: 14,
1656
- cursor: "pointer",
1657
- backgroundColor: state.isSelected ? "#0087FA" : state.isFocused ? isDark ? "#303036" : "#EBF5FF" : "transparent",
1658
- color: state.isSelected ? "#ffffff" : isDark ? "#f3f4f6" : "#111827",
1659
- "&:active": { backgroundColor: "#0087FA", color: "#ffffff" }
1660
- }),
1661
- singleValue: (base, state) => ({
1662
- ...base,
1663
- fontSize: 14,
1664
- fontWeight: 400,
1665
- color: state.isDisabled ? "#6b7280" : isDark ? "#f3f4f6" : "#111827"
1666
- }),
1667
- multiValue: (base) => ({
1668
- ...base,
1669
- backgroundColor: isDark ? "#303036" : "#EBF5FF"
1670
- }),
1671
- multiValueLabel: (base) => ({
1672
- ...base,
1673
- fontSize: 12,
1674
- color: isDark ? "#f3f4f6" : "#0087FA"
1675
- }),
1676
- multiValueRemove: (base) => ({
1677
- ...base,
1678
- color: isDark ? "#9ca3af" : "#0087FA",
1679
- "&:hover": { backgroundColor: "#0087FA", color: "#ffffff" }
1680
- }),
1681
- placeholder: (base) => ({
1682
- ...base,
1683
- fontSize: 14,
1684
- fontWeight: 400,
1685
- color: "#6b7280"
1686
- }),
1687
- input: (base) => ({
1688
- ...base,
1689
- fontSize: 14,
1690
- fontWeight: 400,
1691
- color: isDark ? "#f3f4f6" : "#111827"
1692
- }),
1693
- indicatorSeparator: () => ({ display: "none" }),
1694
- dropdownIndicator: (base) => ({
1695
- ...base,
1696
- padding: "0 6px",
1697
- color: isDark ? "#9ca3af" : "#6b7280"
1698
- }),
1699
- clearIndicator: (base) => ({
1700
- ...base,
1701
- padding: "0 4px",
1702
- color: isDark ? "#9ca3af" : "#6b7280",
1703
- cursor: "pointer",
1704
- "&:hover": { color: "#0087FA" }
1705
- }),
1706
- valueContainer: (base) => ({ ...base, padding: "2px 16px" })
1707
- };
1708
- }
1709
- var Dropdown = React17.forwardRef(
1710
- ({
1711
- id = "dropdown",
1712
- options,
1713
- placeholder = "Select...",
1714
- isDisabled = false,
1715
- isClearable = true,
1716
- isLoading = false,
1717
- error = false,
1718
- label,
1719
- heading,
1720
- isRequired = false,
1721
- name,
1722
- menuPortalTarget,
1723
- menuPosition = "absolute",
1724
- className,
1725
- style,
1726
- isMulti = false,
1727
- value,
1728
- onChange
1729
- }, ref) => {
1730
- const reactId = useId();
1731
- const isDark = isDarkMode();
1732
- const styles = useMemo(() => buildStyles(isDark, !!error), [isDark, error]);
1733
- const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
1734
- const handleChange = (selected) => {
1735
- if (isMulti) {
1736
- onChange((selected ?? []).map((o) => o.value));
1737
- } else {
1738
- onChange((selected == null ? void 0 : selected.value) ?? null);
1739
- }
1740
- };
1741
- return /* @__PURE__ */ React17.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ React17.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ React17.createElement(
1742
- "label",
1743
- {
1744
- htmlFor: reactId,
1745
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
1746
- id: `${id}-label-1`
1747
- },
1748
- label,
1749
- isRequired && /* @__PURE__ */ React17.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
1750
- ), /* @__PURE__ */ React17.createElement(
1751
- ReactSelect,
1752
- {
1753
- ref,
1754
- inputId: reactId,
1755
- name,
1756
- options,
1757
- value: selectedValue,
1758
- onChange: handleChange,
1759
- placeholder,
1760
- isDisabled,
1761
- isClearable,
1762
- isLoading,
1763
- isMulti,
1764
- styles,
1765
- menuPortalTarget,
1766
- menuPosition,
1767
- classNamePrefix: "jett-dropdown"
1768
- }
1769
- ));
1770
- }
1771
- );
1772
- Dropdown.displayName = "Dropdown";
1773
-
1774
- // src/Calendar/Calendar.tsx
1775
- import React18, { useEffect as useEffect4, useState as useState6 } from "react";
1776
- import {
1777
- DatePicker,
1778
- DateTimePicker,
1779
- DatesProvider
1780
- } from "@mantine/dates";
1781
- var Calendar = (props) => {
1782
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1783
- const {
1784
- minDate,
1785
- maxDate,
1786
- excludeDate,
1787
- firstDayOfWeek = 1,
1788
- locale,
1789
- size,
1790
- className,
1791
- error
1792
- } = props;
1793
- const isRange = props.mode === "range";
1794
- const isDateTime = props.mode === "datetime";
1795
- const datesProviderSettings = {
1796
- firstDayOfWeek,
1797
- consistentWeeks: true
1798
- };
1799
- if (locale) {
1800
- datesProviderSettings.locale = locale;
1801
- }
1802
- const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
1803
- const [displayDate, setDisplayDate] = useState6(anchorDate ?? void 0);
1804
- const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
1805
- useEffect4(() => {
1806
- if (anchorTime !== void 0) {
1807
- setDisplayDate(new Date(anchorTime));
1808
- }
1809
- }, [anchorTime]);
1810
- const weekendColorStyle = {
1811
- "--mantine-color-red-6": "var(--mantine-color-text)"
1812
- };
1813
- if (isRange) {
1814
- const datePickerProps2 = {
1815
- type: "range",
1816
- value: props.value,
1817
- defaultValue: props.defaultValue,
1818
- onChange: props.onChange,
1819
- minDate,
1820
- maxDate,
1821
- excludeDate,
1822
- size,
1823
- className,
1824
- date: displayDate,
1825
- onDateChange: setDisplayDate,
1826
- style: weekendColorStyle
1827
- };
1828
- return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DatePicker, { ...datePickerProps2 }));
1829
- }
1830
- if (isDateTime) {
1831
- const dateTimePickerProps = {
1832
- value: props.value,
1833
- defaultValue: props.defaultValue,
1834
- onChange: props.onChange,
1835
- minDate,
1836
- maxDate,
1837
- excludeDate,
1838
- size,
1839
- className,
1840
- error,
1841
- style: weekendColorStyle
1842
- };
1843
- return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DateTimePicker, { ...dateTimePickerProps }));
1844
- }
1845
- const datePickerProps = {
1846
- value: props.value,
1847
- defaultValue: props.defaultValue,
1848
- onChange: props.onChange,
1849
- minDate,
1850
- maxDate,
1851
- excludeDate,
1852
- size,
1853
- className,
1854
- date: displayDate,
1855
- onDateChange: setDisplayDate,
1856
- style: weekendColorStyle
1857
- };
1858
- return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DatePicker, { ...datePickerProps }));
1859
- };
1860
-
1861
- // src/Pagination/Pagination.jsx
1862
- import React19, { useMemo as useMemo2, useState as useState7, useEffect as useEffect5 } from "react";
1863
- import { ChevronLeft, ChevronRight as ChevronRight2, ChevronsLeft, ChevronsRight } from "lucide-react";
1864
- var Pagination = ({
1865
- id = "pagination",
1866
- data = [],
1867
- component: Component,
1868
- itemsPerPage = 6,
1869
- itemsPerPageOptions = [5, 10, 20, 50, 100],
1870
- // Controlled props (optional)
1871
- currentPage: controlledCurrentPage,
1872
- onPageChange: controlledOnPageChange,
1873
- onItemsPerPageChange: controlledOnItemsPerPageChange,
1874
- // Legacy props for backward compatibility
1875
- totalPages,
1876
- totalItems: legacyTotalItems,
1877
- onPageChange: legacyOnPageChange,
1878
- onItemsPerPageChange: legacyOnItemsPerPageChange,
1879
- tableHeader,
1880
- isHideCheckbox,
1881
- callback,
1882
- isTable = false,
1883
- // Component props - any additional props to pass to the component
1884
- componentProps = {},
1885
- ...restProps
1886
- }) => {
1887
- const [internalCurrentPage, setInternalCurrentPage] = useState7(1);
1888
- const [internalItemsPerPage, setInternalItemsPerPage] = useState7(itemsPerPage);
1889
- const isControlled = controlledCurrentPage !== void 0;
1890
- const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1891
- const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1892
- const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1893
- const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1894
- const calculatedTotalPages = useMemo2(() => {
1895
- if (totalItems > 0 && activeItemsPerPage > 0) {
1896
- return Math.ceil(totalItems / activeItemsPerPage);
1897
- }
1898
- return 1;
1899
- }, [totalItems, activeItemsPerPage]);
1900
- const paginatedData = useMemo2(() => {
1901
- if (!data || data.length === 0) return [];
1902
- const startIndex = (currentPage - 1) * activeItemsPerPage;
1903
- const endIndex = startIndex + activeItemsPerPage;
1904
- return data.slice(startIndex, endIndex);
1905
- }, [data, currentPage, activeItemsPerPage]);
1906
- useEffect5(() => {
1907
- if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1908
- setInternalCurrentPage(1);
1909
- }
1910
- }, [calculatedTotalPages, isControlled, currentPage]);
1911
- const getPageNumbers = () => {
1912
- const pages = [];
1913
- const maxVisible = 5;
1914
- let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1915
- let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1916
- if (endPage - startPage < maxVisible - 1) {
1917
- startPage = Math.max(1, endPage - maxVisible + 1);
1918
- }
1919
- for (let i = startPage; i <= endPage; i++) {
1920
- pages.push(i);
1921
- }
1922
- return pages;
1923
- };
1924
- const handlePageChange = (page) => {
1925
- if (page >= 1 && page <= calculatedTotalPages) {
1926
- if (isControlled && controlledOnPageChange) {
1927
- controlledOnPageChange(page);
1928
- } else if (legacyOnPageChange) {
1929
- legacyOnPageChange(page);
1930
- } else {
1931
- setInternalCurrentPage(page);
1932
- }
1933
- }
1934
- };
1935
- const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1936
- const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1937
- const renderContent = () => {
1938
- if (Component) {
1939
- if (React19.isValidElement(Component)) {
1940
- const ComponentType = Component.type;
1941
- const elementProps = Component.props;
1942
- if (isTable) {
1943
- return /* @__PURE__ */ React19.createElement(
1944
- CustomTable,
1945
- {
1946
- tableHeader,
1947
- isHideCheckbox,
1948
- id: `${id}-custom-table-1`
1949
- },
1950
- data.map((item, index) => {
1951
- return /* @__PURE__ */ React19.createElement(
1952
- ComponentType,
1953
- {
1954
- key: item.id || item._id || index,
1955
- data: item,
1956
- ...elementProps,
1957
- ...componentProps,
1958
- ...restProps,
1959
- id: `${id}-component-type-1-${index}`
1960
- }
1961
- );
1962
- })
1963
- );
1964
- } else {
1965
- if (isTable) {
1966
- return /* @__PURE__ */ React19.createElement(
1967
- CustomTable,
1968
- {
1969
- tableHeader,
1970
- isHideCheckbox,
1971
- id: `${id}-custom-table-2`
1972
- },
1973
- paginatedData.map((item, index) => {
1974
- return /* @__PURE__ */ React19.createElement(
1975
- ComponentType,
1976
- {
1977
- key: item.id || item._id || index,
1978
- data: item,
1979
- ...elementProps,
1980
- ...componentProps,
1981
- ...restProps,
1982
- id: `${id}-component-type-2-${index}`
1983
- }
1984
- );
1985
- })
1986
- );
1987
- }
1988
- }
1989
- } else {
1990
- return /* @__PURE__ */ React19.createElement(
1991
- CustomTable,
1992
- {
1993
- tableHeader,
1994
- isHideCheckbox,
1995
- id: `${id}-custom-table-3`
1996
- },
1997
- paginatedData.map((item, index) => {
1998
- return /* @__PURE__ */ React19.createElement(
1999
- Component,
2000
- {
2001
- key: item.id || item._id || index,
2002
- data: item,
2003
- ...componentProps,
2004
- ...restProps,
2005
- id: `${id}-component-1-${index}`
2006
- }
2007
- );
2008
- })
2009
- );
2010
- }
2011
- }
2012
- return null;
2013
- };
2014
- return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(React19.Fragment, null, renderContent()), /* @__PURE__ */ React19.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ React19.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ React19.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ React19.createElement(
2015
- "button",
2016
- {
2017
- onClick: () => handlePageChange(1),
2018
- disabled: currentPage === 1,
2019
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2020
- title: "First page",
2021
- id: `${id}-button-1`
2022
- },
2023
- /* @__PURE__ */ React19.createElement(ChevronsLeft, { size: 16 })
2024
- ), /* @__PURE__ */ React19.createElement(
2025
- "button",
2026
- {
2027
- onClick: () => handlePageChange(currentPage - 1),
2028
- disabled: currentPage === 1,
2029
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2030
- title: "Previous page",
2031
- id: `${id}-button-2`
2032
- },
2033
- /* @__PURE__ */ React19.createElement(ChevronLeft, { size: 16 })
2034
- ), getPageNumbers().map((pageNum) => /* @__PURE__ */ React19.createElement(
2035
- "button",
2036
- {
2037
- key: pageNum,
2038
- onClick: () => handlePageChange(pageNum),
2039
- className: `flex items-center justify-center min-w-9 h-9 px-3 cursor-pointer rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === pageNum ? "bg-primary text-white border-primary dark:bg-primary" : "bg-white text-black hover:bg-gray-50 dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2040
- id: `${id}-button-3`
2041
- },
2042
- pageNum
2043
- )), /* @__PURE__ */ React19.createElement(
2044
- "button",
2045
- {
2046
- onClick: () => handlePageChange(currentPage + 1),
2047
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2048
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2049
- title: "Next page",
2050
- id: `${id}-button-4`
2051
- },
2052
- /* @__PURE__ */ React19.createElement(ChevronRight2, { size: 16 })
2053
- ), /* @__PURE__ */ React19.createElement(
2054
- "button",
2055
- {
2056
- onClick: () => handlePageChange(calculatedTotalPages),
2057
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2058
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2059
- title: "Last page",
2060
- id: `${id}-button-5`
2061
- },
2062
- /* @__PURE__ */ React19.createElement(ChevronsRight, { size: 16 })
2063
- ))));
2064
- };
2065
- export {
2066
- AppSideBar,
2067
- Calendar,
2068
- Chip,
2069
- CustomAutocomplete,
2070
- CustomButton,
2071
- CustomCheckbox,
2072
- CustomInput,
2073
- CustomSearch,
2074
- CustomSelect,
2075
- CustomSwitch,
2076
- CustomTable,
2077
- CustomTextarea,
2078
- CustomUpload,
2079
- Dropdown,
2080
- Pagination,
2081
- ProgressBar,
2082
- RightSheet
2083
- };
1
+ // src/utils/cn.ts
2
+ import { clsx } from "clsx";
3
+ import { twMerge } from "tailwind-merge";
4
+ function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+
8
+ // src/Button.jsx
9
+ import React from "react";
10
+ var variantStyles = {
11
+ PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
12
+ SECONDARY: "bg-primary text-white dark:text-white",
13
+ DEFAULT: "bg-white text-black dark:text-white",
14
+ DANGER: "bg-[#ef4444] text-white dark:text-white"
15
+ };
16
+ var CustomButton = ({
17
+ id = "button",
18
+ variant = "DEFAULT",
19
+ children,
20
+ className,
21
+ onClick,
22
+ disabled = false,
23
+ icon
24
+ }) => {
25
+ return /* @__PURE__ */ React.createElement(
26
+ "div",
27
+ {
28
+ className: cn(
29
+ `cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
30
+ variantStyles[variant],
31
+ className
32
+ ),
33
+ onClick,
34
+ id: `${id}-div-1`
35
+ },
36
+ icon && /* @__PURE__ */ React.createElement("div", { id: `${id}-div-2` }, icon),
37
+ children
38
+ );
39
+ };
40
+
41
+ // src/inputs/Autocomplete.jsx
42
+ import React2, { useState, useRef } from "react";
43
+ import { ChevronDown, Check, Search } from "lucide-react";
44
+ var CustomAutocomplete = ({
45
+ id = "autocomplete",
46
+ label,
47
+ value,
48
+ onChange,
49
+ options,
50
+ placeholder = "Search & select...",
51
+ isRequired = false,
52
+ error,
53
+ heading,
54
+ disabled = false
55
+ }) => {
56
+ const [open, setOpen] = useState(false);
57
+ const [search, setSearch] = useState("");
58
+ const wrapperRef = useRef(null);
59
+ const selectedOptions = options.filter((opt) => value.includes(opt.value));
60
+ const handleBlur = (e) => {
61
+ var _a;
62
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
63
+ setOpen(false);
64
+ }
65
+ };
66
+ const filteredOptions = options.filter(
67
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
68
+ );
69
+ const toggleValue = (val) => {
70
+ if (value.includes(val)) {
71
+ onChange(value.filter((v) => v !== val));
72
+ } else {
73
+ onChange([...value, val]);
74
+ }
75
+ };
76
+ return /* @__PURE__ */ React2.createElement(
77
+ "div",
78
+ {
79
+ className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
80
+ ref: wrapperRef,
81
+ tabIndex: disabled ? -1 : 0,
82
+ onBlur: handleBlur,
83
+ id: `${id}-div-1`
84
+ },
85
+ heading && /* @__PURE__ */ React2.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
86
+ label && /* @__PURE__ */ React2.createElement(
87
+ "label",
88
+ {
89
+ className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
90
+ id: `${id}-label-1`
91
+ },
92
+ label,
93
+ " ",
94
+ isRequired && /* @__PURE__ */ React2.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
95
+ ),
96
+ /* @__PURE__ */ React2.createElement(
97
+ "div",
98
+ {
99
+ onClick: () => {
100
+ if (!disabled) setOpen((prev) => !prev);
101
+ },
102
+ className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
103
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
104
+ ${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
105
+ `,
106
+ id: `${id}-div-2`
107
+ },
108
+ /* @__PURE__ */ React2.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ React2.createElement(
109
+ "span",
110
+ {
111
+ key: opt.value,
112
+ className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
113
+ id: `${id}-span-2`
114
+ },
115
+ opt.label,
116
+ /* @__PURE__ */ React2.createElement(
117
+ "button",
118
+ {
119
+ onClick: (e) => {
120
+ e.stopPropagation();
121
+ toggleValue(opt.value);
122
+ },
123
+ className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
124
+ id: `${id}-button-1`
125
+ },
126
+ "\u2715"
127
+ )
128
+ )) : /* @__PURE__ */ React2.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
129
+ /* @__PURE__ */ React2.createElement(
130
+ ChevronDown,
131
+ {
132
+ className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
133
+ }
134
+ )
135
+ ),
136
+ !disabled && open && /* @__PURE__ */ React2.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ React2.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ React2.createElement(Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React2.createElement(
137
+ "input",
138
+ {
139
+ type: "text",
140
+ value: search,
141
+ onChange: (e) => setSearch(e.target.value),
142
+ placeholder: "Search...",
143
+ className: "flex-1 text-sm focus:outline-none",
144
+ id: `${id}-input-1`
145
+ }
146
+ )), /* @__PURE__ */ React2.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
147
+ const selected = value.includes(opt.value);
148
+ return /* @__PURE__ */ React2.createElement(
149
+ "li",
150
+ {
151
+ key: opt.value,
152
+ onClick: () => toggleValue(opt.value),
153
+ className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
154
+ id: `${id}-li-1`
155
+ },
156
+ /* @__PURE__ */ React2.createElement(
157
+ "span",
158
+ {
159
+ className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
160
+ id: `${id}-span-4`
161
+ },
162
+ selected && /* @__PURE__ */ React2.createElement(Check, { size: 14 })
163
+ ),
164
+ opt.label
165
+ );
166
+ }) : /* @__PURE__ */ React2.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
167
+ );
168
+ };
169
+
170
+ // src/inputs/Checkbox.jsx
171
+ import React3 from "react";
172
+ var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
173
+ const handleChange = (e) => {
174
+ onChange(e.target.checked);
175
+ };
176
+ return /* @__PURE__ */ React3.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ React3.createElement(
177
+ "input",
178
+ {
179
+ type: "checkbox",
180
+ checked,
181
+ onChange: handleChange,
182
+ className: "peer hidden",
183
+ id: `${id}-input-1`
184
+ }
185
+ ), /* @__PURE__ */ React3.createElement(
186
+ "span",
187
+ {
188
+ className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
189
+ id: `${id}-span-1`
190
+ },
191
+ checked && /* @__PURE__ */ React3.createElement(
192
+ "svg",
193
+ {
194
+ className: "w-4 h-4 text-white",
195
+ fill: "none",
196
+ stroke: "currentColor",
197
+ strokeWidth: "3",
198
+ viewBox: "0 0 24 24",
199
+ id: `${id}-svg-1`
200
+ },
201
+ /* @__PURE__ */ React3.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
202
+ )
203
+ ));
204
+ };
205
+
206
+ // src/inputs/Chip.jsx
207
+ import React4 from "react";
208
+ var VARIANTS = {
209
+ PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
210
+ GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
211
+ RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
212
+ YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
213
+ };
214
+ var Chip = ({ id = "chip", label, variant }) => {
215
+ return /* @__PURE__ */ React4.createElement(
216
+ "div",
217
+ {
218
+ className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
219
+ id: `${id}-div-1`
220
+ },
221
+ label
222
+ );
223
+ };
224
+
225
+ // src/inputs/CustomSwitch.jsx
226
+ import React5 from "react";
227
+ var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
228
+ return /* @__PURE__ */ React5.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ React5.createElement(
229
+ "button",
230
+ {
231
+ type: "button",
232
+ role: "switch",
233
+ "aria-checked": checked,
234
+ onClick: () => onChange(!checked),
235
+ className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
236
+ id: `${id}-button-1`
237
+ },
238
+ /* @__PURE__ */ React5.createElement(
239
+ "span",
240
+ {
241
+ className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
242
+ id: `${id}-span-1`
243
+ }
244
+ )
245
+ ), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ React5.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
246
+ };
247
+
248
+ // src/inputs/Input.jsx
249
+ import React6 from "react";
250
+ var CustomInput = ({
251
+ id = "input",
252
+ label,
253
+ isRequired,
254
+ value,
255
+ onChange,
256
+ placeholder,
257
+ disabled = false,
258
+ error,
259
+ heading
260
+ }) => {
261
+ return /* @__PURE__ */ React6.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ React6.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ React6.createElement(
262
+ "label",
263
+ {
264
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
265
+ id: `${id}-label-1`
266
+ },
267
+ label,
268
+ " ",
269
+ isRequired && /* @__PURE__ */ React6.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
270
+ ), /* @__PURE__ */ React6.createElement(
271
+ "input",
272
+ {
273
+ className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
274
+ placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
275
+ focus:outline-2 outline-black dark:outline-white outline-offset-2
276
+ dark:bg-transparent dark:text-white dark:border-[#303036]
277
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
278
+ `,
279
+ value,
280
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
281
+ placeholder,
282
+ disabled,
283
+ readOnly: disabled,
284
+ id: `${id}-input-1`
285
+ }
286
+ ));
287
+ };
288
+
289
+ // src/inputs/ProgressBar.jsx
290
+ import React7 from "react";
291
+ var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
292
+ const progress = step / totalSteps * 100;
293
+ return /* @__PURE__ */ React7.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ React7.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ React7.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ React7.createElement(
294
+ "div",
295
+ {
296
+ className: "bg-black h-2 rounded-full transition-all duration-300",
297
+ style: { width: `${progress}%` },
298
+ id: `${id}-div-3`
299
+ }
300
+ )));
301
+ };
302
+
303
+ // src/inputs/Search.jsx
304
+ import React8 from "react";
305
+ import { Search as Search2 } from "lucide-react";
306
+ var CustomSearch = ({
307
+ id = "search",
308
+ value,
309
+ onChange,
310
+ placeholder = "Search Markets..."
311
+ }) => {
312
+ return /* @__PURE__ */ React8.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ React8.createElement(Search2, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ React8.createElement(
313
+ "input",
314
+ {
315
+ type: "text",
316
+ value,
317
+ onChange,
318
+ placeholder,
319
+ className: "bg-transparent w-full h-full focus:outline-none",
320
+ id: `${id}-input-1`
321
+ }
322
+ ));
323
+ };
324
+
325
+ // src/inputs/TextArea.jsx
326
+ import React9 from "react";
327
+ var CustomTextarea = ({
328
+ id = "text-area",
329
+ label,
330
+ isRequired,
331
+ value,
332
+ onChange,
333
+ placeholder,
334
+ disabled = false,
335
+ error,
336
+ heading,
337
+ rows = 4
338
+ }) => {
339
+ return /* @__PURE__ */ React9.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ React9.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ React9.createElement(
340
+ "label",
341
+ {
342
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
343
+ id: `${id}-label-1`
344
+ },
345
+ label,
346
+ " ",
347
+ isRequired && /* @__PURE__ */ React9.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
348
+ ), /* @__PURE__ */ React9.createElement(
349
+ "textarea",
350
+ {
351
+ rows,
352
+ className: `border rounded-md px-4 py-2 w-full text-[14px]
353
+ focus:outline-2 focus:outline-black focus:outline-offset-2
354
+ focus:ring-0 focus:shadow-none focus:border-black
355
+ ${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
356
+ `,
357
+ value,
358
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
359
+ placeholder,
360
+ disabled,
361
+ readOnly: disabled,
362
+ id: `${id}-textarea-1`
363
+ }
364
+ ));
365
+ };
366
+
367
+ // src/inputs/Upload.jsx
368
+ import React10, { useRef as useRef2 } from "react";
369
+ import { Upload } from "lucide-react";
370
+ var CustomUpload = ({
371
+ id = "upload",
372
+ label = "Supporting documents",
373
+ description = "Drop items here or Browse Files",
374
+ accept = ".pdf,.jpg,.jpeg,.png",
375
+ maxSizeMB = 5,
376
+ onChange,
377
+ error,
378
+ value
379
+ }) => {
380
+ const inputRef = useRef2(null);
381
+ const handleFileSelect = (files) => {
382
+ if (!files || files.length === 0) return;
383
+ const selectedFile = files[0];
384
+ if (selectedFile.size > maxSizeMB * 1024 * 1024) {
385
+ alert(`File size must be less than ${maxSizeMB} MB`);
386
+ return;
387
+ }
388
+ onChange == null ? void 0 : onChange(selectedFile);
389
+ };
390
+ return /* @__PURE__ */ React10.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ React10.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ React10.createElement(
391
+ "div",
392
+ {
393
+ className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
394
+ ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
395
+ onClick: () => {
396
+ var _a;
397
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
398
+ },
399
+ onDragOver: (e) => e.preventDefault(),
400
+ onDrop: (e) => {
401
+ e.preventDefault();
402
+ handleFileSelect(e.dataTransfer.files);
403
+ },
404
+ id: `${id}-div-2`
405
+ },
406
+ /* @__PURE__ */ React10.createElement(Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
407
+ /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
408
+ /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
409
+ /* @__PURE__ */ React10.createElement(
410
+ "input",
411
+ {
412
+ ref: inputRef,
413
+ type: "file",
414
+ accept,
415
+ className: "hidden",
416
+ onChange: (e) => handleFileSelect(e.target.files),
417
+ id: `${id}-input-1`
418
+ }
419
+ )
420
+ ), value && /* @__PURE__ */ React10.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
421
+ };
422
+
423
+ // src/sideBar/SideBar.jsx
424
+ import {
425
+ ChevronDown as ChevronDown3,
426
+ ChevronRight,
427
+ CircleSlash,
428
+ Globe,
429
+ LogOut as LogOut3,
430
+ Menu,
431
+ X
432
+ } from "lucide-react";
433
+ import React14, { useEffect as useEffect2, useState as useState4, useCallback, useRef as useRef4 } from "react";
434
+
435
+ // ConstantUI.js
436
+ import {
437
+ Home,
438
+ Banknote,
439
+ LifeBuoy,
440
+ Cog,
441
+ Building,
442
+ Handshake,
443
+ DollarSign,
444
+ BarChart3
445
+ } from "lucide-react";
446
+ var encodedAuthData = localStorage.getItem("encodedAuthData");
447
+ var navItemsConstant = [
448
+ {
449
+ Icon: Home,
450
+ label: "Home",
451
+ onClick: () => {
452
+ window.location.href = "/";
453
+ },
454
+ isDropDown: false
455
+ },
456
+ {
457
+ Icon: Building,
458
+ label: "Consumer Ecosystem",
459
+ onClick: () => {
460
+ },
461
+ options: [
462
+ {
463
+ label: "Corporate",
464
+ onClick: () => {
465
+ window.location.href = "/corporate/";
466
+ }
467
+ },
468
+ {
469
+ label: "Trips",
470
+ onClick: () => {
471
+ window.location.href = "/corporate/trips/";
472
+ }
473
+ },
474
+ {
475
+ label: "Users",
476
+ onClick: () => {
477
+ window.location.href = "/users/users";
478
+ }
479
+ },
480
+ {
481
+ label: "Tags (Custom Variables)",
482
+ onClick: () => {
483
+ window.location.href = "/orgselector/?path=tag";
484
+ }
485
+ },
486
+ {
487
+ label: "Special Request",
488
+ onClick: () => {
489
+ window.location.href = "/orgselector/?path=special-requests";
490
+ }
491
+ },
492
+ {
493
+ label: "Support Tickets (Coming Soon)",
494
+ isDisabled: true
495
+ // onClick: () => {},
496
+ }
497
+ ],
498
+ isDropDown: true
499
+ },
500
+ {
501
+ Icon: Banknote,
502
+ label: "Finance",
503
+ onClick: () => {
504
+ },
505
+ isDropDown: true,
506
+ options: [
507
+ {
508
+ label: "Credit Management",
509
+ onClick: () => {
510
+ window.location.href = "/finance/paymentsLedger/";
511
+ }
512
+ },
513
+ {
514
+ label: "Booking & Invoices",
515
+ onClick: () => {
516
+ window.location.href = "/finance/bookingHistory/";
517
+ }
518
+ }
519
+ ]
520
+ },
521
+ {
522
+ Icon: DollarSign,
523
+ label: "Revenue Management",
524
+ onClick: () => {
525
+ },
526
+ isDropDown: true,
527
+ options: [
528
+ {
529
+ label: "Pricing Engine",
530
+ onClick: () => {
531
+ window.location.href = "/orgselector/?path=pricing-policy";
532
+ }
533
+ },
534
+ {
535
+ label: "Offers",
536
+ onClick: () => {
537
+ window.location.href = "/orgselector/?path=offer";
538
+ }
539
+ },
540
+ {
541
+ label: "Vouchers",
542
+ onClick: () => {
543
+ window.location.href = "/orgselector/?path=voucher";
544
+ }
545
+ }
546
+ ]
547
+ },
548
+ {
549
+ Icon: Handshake,
550
+ label: "Supplier Ecosystem",
551
+ onClick: () => {
552
+ },
553
+ isDropDown: true,
554
+ options: [
555
+ {
556
+ label: "Suppliers List",
557
+ onClick: () => {
558
+ window.location.href = "/orgselector/?path=supplier-list";
559
+ }
560
+ },
561
+ {
562
+ label: "Supplier Deals",
563
+ onClick: () => {
564
+ window.location.href = "/supplierdeals/";
565
+ }
566
+ }
567
+ ]
568
+ },
569
+ {
570
+ Icon: BarChart3,
571
+ label: "Reports",
572
+ onClick: () => {
573
+ },
574
+ isDropDown: true,
575
+ options: [
576
+ {
577
+ label: "Reports",
578
+ onClick: () => {
579
+ window.location.href = "/reports/";
580
+ }
581
+ }
582
+ ]
583
+ },
584
+ {
585
+ Icon: Cog,
586
+ label: "Settings",
587
+ onClick: () => {
588
+ },
589
+ isDropDown: true,
590
+ options: [
591
+ {
592
+ label: "Whitelabel",
593
+ onClick: () => {
594
+ window.location.href = "/whitelabel/";
595
+ }
596
+ },
597
+ {
598
+ label: "Markets",
599
+ onClick: () => {
600
+ window.location.href = "/market/";
601
+ }
602
+ },
603
+ {
604
+ label: "Users",
605
+ onClick: () => {
606
+ window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
607
+ }
608
+ },
609
+ {
610
+ label: "Reports Configurations",
611
+ onClick: () => {
612
+ window.location.href = "/reports/";
613
+ }
614
+ }
615
+ ]
616
+ }
617
+ ];
618
+ var additionalItemsConstant = [
619
+ {
620
+ Icon: LifeBuoy,
621
+ label: "Help",
622
+ onClick: () => {
623
+ window.location.href = "/help";
624
+ }
625
+ }
626
+ ];
627
+
628
+ // src/sideBar/SideBar.jsx
629
+ import Cookies from "js-cookie";
630
+
631
+ // src/inputs/CustomSelect.jsx
632
+ import React11, { useState as useState2, useRef as useRef3 } from "react";
633
+ import { ChevronDown as ChevronDown2, Search as Search3 } from "lucide-react";
634
+ var CustomSelect = ({
635
+ id = "custom-select",
636
+ label,
637
+ value,
638
+ onChange,
639
+ options,
640
+ placeholder = "Select...",
641
+ isRequired = false,
642
+ error,
643
+ heading,
644
+ disabled = false
645
+ }) => {
646
+ const [open, setOpen] = useState2(false);
647
+ const [search, setSearch] = useState2("");
648
+ const wrapperRef = useRef3(null);
649
+ const handleBlur = (e) => {
650
+ var _a;
651
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
652
+ setOpen(false);
653
+ }
654
+ };
655
+ const filteredOptions = options.filter(
656
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
657
+ );
658
+ const handleSelect = (val) => {
659
+ onChange(val);
660
+ setOpen(false);
661
+ };
662
+ const selectedOption = options.find((opt) => opt.value === value);
663
+ return /* @__PURE__ */ React11.createElement(
664
+ "div",
665
+ {
666
+ className: "flex flex-col w-full relative",
667
+ ref: wrapperRef,
668
+ tabIndex: disabled ? -1 : 0,
669
+ onBlur: handleBlur,
670
+ id: `${id}-div-1`
671
+ },
672
+ heading && /* @__PURE__ */ React11.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
673
+ label && /* @__PURE__ */ React11.createElement(
674
+ "label",
675
+ {
676
+ className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
677
+ id: `${id}-label-1`
678
+ },
679
+ label,
680
+ " ",
681
+ isRequired && /* @__PURE__ */ React11.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
682
+ ),
683
+ /* @__PURE__ */ React11.createElement(
684
+ "div",
685
+ {
686
+ onClick: () => !disabled && setOpen((prev) => !prev),
687
+ className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
688
+ ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
689
+ ${error ? "border-red-500" : "border-gray-300"}
690
+ `,
691
+ id: `${id}-div-2`
692
+ },
693
+ /* @__PURE__ */ React11.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
694
+ /* @__PURE__ */ React11.createElement(
695
+ ChevronDown2,
696
+ {
697
+ className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
698
+ }
699
+ )
700
+ ),
701
+ open && !disabled && /* @__PURE__ */ React11.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ React11.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ React11.createElement(Search3, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React11.createElement(
702
+ "input",
703
+ {
704
+ type: "text",
705
+ value: search,
706
+ onChange: (e) => setSearch(e.target.value),
707
+ placeholder: "Search...",
708
+ className: "flex-1 text-sm focus:outline-none",
709
+ id: `${id}-input-1`
710
+ }
711
+ )), /* @__PURE__ */ React11.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ React11.createElement(
712
+ "li",
713
+ {
714
+ key: opt.value,
715
+ onClick: () => handleSelect(opt.value),
716
+ className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
717
+ id: `${id}-li-1`
718
+ },
719
+ opt.label
720
+ )) : /* @__PURE__ */ React11.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
721
+ );
722
+ };
723
+
724
+ // src/utils/cookieHelpers.js
725
+ var JETT_ID_COOKIE_NAME = "jett-id";
726
+ function getCookie(name) {
727
+ if (typeof document === "undefined" || !document.cookie) return null;
728
+ const match = document.cookie.match(
729
+ new RegExp("(^|\\s)" + name + "=([^;]+)")
730
+ );
731
+ return match ? decodeURIComponent(match[2].trim()) : null;
732
+ }
733
+ function decodeBase64(value) {
734
+ try {
735
+ let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
736
+ const pad = base64.length % 4;
737
+ if (pad) base64 += "=".repeat(4 - pad);
738
+ return atob(base64);
739
+ } catch {
740
+ return "";
741
+ }
742
+ }
743
+ function getJettIdCookieData() {
744
+ const raw = getCookie(JETT_ID_COOKIE_NAME);
745
+ if (!raw) return null;
746
+ try {
747
+ const decoded = decodeBase64(raw);
748
+ if (!decoded) return null;
749
+ const data = JSON.parse(decoded);
750
+ return data && typeof data === "object" ? data : null;
751
+ } catch {
752
+ return null;
753
+ }
754
+ }
755
+ function getLogoFromJettIdCookie() {
756
+ const data = getJettIdCookieData();
757
+ if (!(data == null ? void 0 : data.CDNBasePath)) return null;
758
+ const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
759
+ if (!logoPath) return null;
760
+ return {
761
+ logoPath,
762
+ CDNBasePath: data.CDNBasePath
763
+ };
764
+ }
765
+ function getScopeFromJettIdCookie() {
766
+ const data = getJettIdCookieData();
767
+ return (data == null ? void 0 : data.Scope) ?? null;
768
+ }
769
+ function getProfilesFromJettIdCookie(all) {
770
+ const data = getJettIdCookieData();
771
+ if (!(data == null ? void 0 : data.Profiles)) return [];
772
+ if (all) return data.Profiles;
773
+ return data.Profiles.filter((profile) => {
774
+ var _a;
775
+ return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
776
+ });
777
+ }
778
+ function buildLogoUrl(CDNBasePath, logoPath) {
779
+ const base = (CDNBasePath || "").replace(/\/$/, "");
780
+ const path = (logoPath || "").replace(/^\//, "");
781
+ if (!base || !path) return "";
782
+ return `${base}/${path}`;
783
+ }
784
+
785
+ // src/sideBar/SwitchProfileSection.jsx
786
+ import React13, { useEffect, useLayoutEffect, useState as useState3 } from "react";
787
+ import { createPortal as createPortal2 } from "react-dom";
788
+ import { LogOut as LogOut2, SlidersHorizontal } from "lucide-react";
789
+
790
+ // src/sideBar/LogoutConfirmModal.jsx
791
+ import React12 from "react";
792
+ import { createPortal } from "react-dom";
793
+ import { LogOut } from "lucide-react";
794
+ var LogoutConfirmModal = ({
795
+ id = "logout-confirm",
796
+ open,
797
+ onConfirm,
798
+ onCancel,
799
+ loading = false
800
+ }) => {
801
+ if (!open || typeof document === "undefined") return null;
802
+ const handleOverlayClick = (e) => {
803
+ if (e.target === e.currentTarget && !loading) onCancel();
804
+ };
805
+ return createPortal(
806
+ /* @__PURE__ */ React12.createElement(
807
+ "div",
808
+ {
809
+ className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
810
+ onClick: handleOverlayClick,
811
+ id: `${id}-overlay`
812
+ },
813
+ /* @__PURE__ */ React12.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ React12.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ React12.createElement(LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ React12.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ React12.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ React12.createElement(
814
+ "button",
815
+ {
816
+ type: "button",
817
+ onClick: onCancel,
818
+ disabled: loading,
819
+ className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
820
+ id: `${id}-cancel-button`
821
+ },
822
+ "No, Keep me in"
823
+ ), /* @__PURE__ */ React12.createElement(
824
+ "button",
825
+ {
826
+ type: "button",
827
+ onClick: onConfirm,
828
+ disabled: loading,
829
+ className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
830
+ id: `${id}-confirm-button`
831
+ },
832
+ loading ? "Logging out..." : "Yes, logout"
833
+ )))
834
+ ),
835
+ document.body
836
+ );
837
+ };
838
+
839
+ // src/utils/switchProfileEncryption.js
840
+ import forge from "node-forge";
841
+ var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
842
+ var RSA_EXPONENT_BASE64 = "AQAB";
843
+ var convertModulusExponentToPem = (modulus, exponent) => {
844
+ const decodedModulus = forge.util.decode64(modulus);
845
+ const decodedExponent = forge.util.decode64(exponent);
846
+ const publicKey = forge.pki.setRsaPublicKey(
847
+ new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedModulus), 16),
848
+ new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedExponent), 16)
849
+ );
850
+ return forge.pki.publicKeyToPem(publicKey);
851
+ };
852
+ var cachedPemKey = null;
853
+ var getPemKey = () => {
854
+ if (!cachedPemKey) {
855
+ cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
856
+ }
857
+ return cachedPemKey;
858
+ };
859
+ var encryptForSwitchProfile = (plainText) => {
860
+ const publicKey = forge.pki.publicKeyFromPem(getPemKey());
861
+ const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
862
+ return forge.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
863
+ };
864
+
865
+ // src/sideBar/SwitchProfileSection.jsx
866
+ var SwitchProfileSection = ({
867
+ id = "switch-profile",
868
+ open,
869
+ anchorRef,
870
+ onClose,
871
+ onManageProfile,
872
+ onProfileSwitch,
873
+ onTmcSettings,
874
+ onLogout
875
+ }) => {
876
+ const [position, setPosition] = useState3(null);
877
+ const [showLogoutConfirm, setShowLogoutConfirm] = useState3(false);
878
+ const [switchingProfileId, setSwitchingProfileId] = useState3(null);
879
+ const [switchError, setSwitchError] = useState3(null);
880
+ const jettIdData = getJettIdCookieData();
881
+ const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
882
+ const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
883
+ const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
884
+ const allMarkets = getProfilesFromJettIdCookie(true);
885
+ const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
886
+ const buildRequestContext = () => ({
887
+ UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
888
+ TrackingId: crypto.randomUUID(),
889
+ TransactionId: crypto.randomUUID(),
890
+ CountryCode: "IN",
891
+ IpAddress: "127.0.0.1"
892
+ // Client IP cannot be retrieved from browser
893
+ });
894
+ const handleProfileSwitch = async (profile) => {
895
+ var _a, _b, _c;
896
+ if (switchingProfileId) return;
897
+ setSwitchingProfileId(profile.ProfileId);
898
+ setSwitchError(null);
899
+ try {
900
+ const encryptedRequest = encryptForSwitchProfile(
901
+ JSON.stringify({
902
+ ProfileToken: profile.ProfileToken,
903
+ ProfileId: profile.ProfileId
904
+ })
905
+ );
906
+ const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
907
+ method: "POST",
908
+ credentials: "include",
909
+ headers: { "Content-Type": "application/json" },
910
+ body: JSON.stringify({
911
+ Context: buildRequestContext(),
912
+ Request: encryptedRequest
913
+ })
914
+ }).then((res) => res.json());
915
+ const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
916
+ const isSuccess = !statusCode || statusCode === 200;
917
+ if (!isSuccess) {
918
+ setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
919
+ setSwitchingProfileId(null);
920
+ return;
921
+ }
922
+ if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
923
+ window.location.href = response.Response.RedirectUrl;
924
+ return;
925
+ }
926
+ setSwitchingProfileId(null);
927
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
928
+ } catch (error) {
929
+ console.error("Switch profile request failed:", error);
930
+ setSwitchError("Something went wrong while switching profile. Please try again.");
931
+ setSwitchingProfileId(null);
932
+ }
933
+ };
934
+ useLayoutEffect(() => {
935
+ if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
936
+ const updatePosition = () => {
937
+ const rect = anchorRef.current.getBoundingClientRect();
938
+ setPosition({
939
+ left: rect.right + 2,
940
+ bottom: window.innerHeight - rect.bottom
941
+ });
942
+ };
943
+ updatePosition();
944
+ window.addEventListener("resize", updatePosition);
945
+ window.addEventListener("scroll", updatePosition, true);
946
+ return () => {
947
+ window.removeEventListener("resize", updatePosition);
948
+ window.removeEventListener("scroll", updatePosition, true);
949
+ };
950
+ }, [open, anchorRef]);
951
+ useEffect(() => {
952
+ if (!open) setSwitchError(null);
953
+ }, [open]);
954
+ useEffect(() => {
955
+ if (!switchError) return;
956
+ const timer = setTimeout(() => setSwitchError(null), 5e3);
957
+ return () => clearTimeout(timer);
958
+ }, [switchError]);
959
+ useEffect(() => {
960
+ if (!open || switchingProfileId) return;
961
+ if (allMarkets.length <= 1) return;
962
+ const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
963
+ if (tmcProfile && tmcProfile.ProfileId !== currentProfileId) {
964
+ handleProfileSwitch(tmcProfile);
965
+ }
966
+ }, [open, allMarkets, currentProfileId, switchingProfileId]);
967
+ if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
968
+ const handleConfirmLogout = () => {
969
+ setShowLogoutConfirm(false);
970
+ onLogout == null ? void 0 : onLogout();
971
+ };
972
+ return /* @__PURE__ */ React13.createElement(React13.Fragment, null, open && createPortal2(
973
+ /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ React13.createElement(
974
+ "div",
975
+ {
976
+ className: "fixed w-[320px] max-h-[75vh] flex p-4 flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
977
+ style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
978
+ id: `${id}-panel`
979
+ },
980
+ /* @__PURE__ */ React13.createElement("div", { className: "flex items-center justify-between gap-3 pb-4", id: `${id}-header` }, /* @__PURE__ */ React13.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ React13.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ React13.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border-2 border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "40 * 40")), /* @__PURE__ */ React13.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ React13.createElement("p", { className: "!font-semibold dark:text-white !text-[14px] truncate" }, userName || "Admin"), /* @__PURE__ */ React13.createElement("p", { className: "!text-[10px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ React13.createElement(
981
+ "button",
982
+ {
983
+ type: "button",
984
+ onClick: onManageProfile,
985
+ className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[10px] font-bold uppercase tracking-wide text-[#0A0A0A] dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
986
+ id: `${id}-manage-profile-button`
987
+ },
988
+ "Manage Profile"
989
+ )),
990
+ /* @__PURE__ */ React13.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
991
+ /* @__PURE__ */ React13.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ React13.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ React13.createElement(
992
+ "div",
993
+ {
994
+ className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
995
+ id: `${id}-switch-error`
996
+ },
997
+ switchError
998
+ ), /* @__PURE__ */ React13.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ React13.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
999
+ const isCurrent = profile.ProfileId === currentProfileId;
1000
+ const isSwitching = switchingProfileId === profile.ProfileId;
1001
+ return /* @__PURE__ */ React13.createElement(
1002
+ "div",
1003
+ {
1004
+ key: profile.ProfileId,
1005
+ onClick: () => !isCurrent && handleProfileSwitch(profile),
1006
+ "aria-disabled": isSwitching,
1007
+ className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white bg-[#f4f4f5] text-[#0A0A0A]" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
1008
+ id: `${id}-market-${profile.ProfileId}`
1009
+ },
1010
+ /* @__PURE__ */ React13.createElement("span", { className: "!font-bold !text-[14px] text-gray-900 dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
1011
+ isCurrent && /* @__PURE__ */ React13.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 border-2 border-white text-[9px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
1012
+ isSwitching && /* @__PURE__ */ React13.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
1013
+ );
1014
+ }))),
1015
+ /* @__PURE__ */ React13.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
1016
+ /* @__PURE__ */ React13.createElement("div", { className: "", id: `${id}-footer` }, /* @__PURE__ */ React13.createElement(
1017
+ "div",
1018
+ {
1019
+ onClick: () => {
1020
+ onClose == null ? void 0 : onClose();
1021
+ setShowLogoutConfirm(true);
1022
+ },
1023
+ className: "flex items-center gap-3 p-3 rounded-lg cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
1024
+ id: `${id}-logout`
1025
+ },
1026
+ /* @__PURE__ */ React13.createElement(LogOut2, { width: 18, height: 18 }),
1027
+ /* @__PURE__ */ React13.createElement("span", { className: "!font-bold !text-[14px]" }, "Logout")
1028
+ ))
1029
+ )),
1030
+ document.body
1031
+ ), /* @__PURE__ */ React13.createElement(
1032
+ LogoutConfirmModal,
1033
+ {
1034
+ id: `${id}-logout-confirm`,
1035
+ open: showLogoutConfirm,
1036
+ onCancel: () => setShowLogoutConfirm(false),
1037
+ onConfirm: handleConfirmLogout
1038
+ }
1039
+ ));
1040
+ };
1041
+
1042
+ // src/sideBar/SideBar.jsx
1043
+ var SCOPE_LABELS = {
1044
+ TMC: "TMC Manager",
1045
+ TMC_ENTITY: "TMC Entity Manager"
1046
+ };
1047
+ var AppSideBar = ({
1048
+ id = "side-bar",
1049
+ username,
1050
+ navItems,
1051
+ additionalItems,
1052
+ sideBarLogo,
1053
+ onManageProfile,
1054
+ onProfileSwitch,
1055
+ onTmcSettings,
1056
+ onLogout
1057
+ }) => {
1058
+ var _a, _b;
1059
+ const profileCardRef = useRef4(null);
1060
+ const [authData, setAuthData] = useState4(null);
1061
+ const [cookieUserName, setCookieUserName] = useState4(null);
1062
+ const [scope, setScope] = useState4(null);
1063
+ const [selectedCountry, setSelectedCountry] = useState4("dubai");
1064
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState4(false);
1065
+ const [isSwitchProfileOpen, setIsSwitchProfileOpen] = useState4(false);
1066
+ const [openMenus, setOpenMenus] = useState4(/* @__PURE__ */ new Set());
1067
+ const [activeMenuPath, setActiveMenuPath] = useState4(null);
1068
+ const [currAppearance, setCurrAppearance] = useState4("light");
1069
+ useEffect2(() => {
1070
+ setCurrAppearance("light");
1071
+ }, []);
1072
+ const countryOptions = [
1073
+ { label: "India", value: "india" },
1074
+ { label: "Dubai", value: "dubai" },
1075
+ { label: "Singapore", value: "singapore" },
1076
+ { label: "Qatar", value: "qatar" }
1077
+ ];
1078
+ const toggleMenu = (menuKey) => {
1079
+ setOpenMenus((prev) => {
1080
+ const newSet = new Set(prev);
1081
+ if (newSet.has(menuKey)) {
1082
+ newSet.delete(menuKey);
1083
+ } else {
1084
+ newSet.add(menuKey);
1085
+ }
1086
+ return newSet;
1087
+ });
1088
+ };
1089
+ const isMenuOpen = (menuKey) => {
1090
+ return openMenus.has(menuKey);
1091
+ };
1092
+ const handleMenuClick = (item, index, e) => {
1093
+ if (item.isDropDown) {
1094
+ e.preventDefault();
1095
+ const menuKey = `menu-${index}`;
1096
+ toggleMenu(menuKey);
1097
+ setActiveMenuPath(`menu-${index}`);
1098
+ } else {
1099
+ setActiveMenuPath(`menu-${index}`);
1100
+ if (item.onClick) {
1101
+ item.onClick(e);
1102
+ }
1103
+ closeMobileMenu();
1104
+ }
1105
+ };
1106
+ const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
1107
+ const parentMenuKey = `menu-${parentIndex}`;
1108
+ setOpenMenus((prev) => {
1109
+ const newSet = new Set(prev);
1110
+ newSet.add(parentMenuKey);
1111
+ return newSet;
1112
+ });
1113
+ if (option.isDropDown) {
1114
+ e.preventDefault();
1115
+ const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1116
+ toggleMenu(menuKey);
1117
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1118
+ } else {
1119
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1120
+ if (option.onClick) {
1121
+ option.onClick();
1122
+ }
1123
+ closeMobileMenu();
1124
+ }
1125
+ };
1126
+ const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
1127
+ const parentMenuKey = `menu-${parentIndex}`;
1128
+ const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1129
+ setOpenMenus((prev) => {
1130
+ const newSet = new Set(prev);
1131
+ newSet.add(parentMenuKey);
1132
+ newSet.add(subMenuKey);
1133
+ return newSet;
1134
+ });
1135
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
1136
+ if (subOption.onClick) {
1137
+ subOption.onClick();
1138
+ }
1139
+ closeMobileMenu();
1140
+ };
1141
+ useEffect2(() => {
1142
+ const storedAuthData = localStorage.getItem("authData");
1143
+ if (storedAuthData) {
1144
+ let parseData = JSON.parse(storedAuthData);
1145
+ setAuthData(parseData);
1146
+ }
1147
+ }, [localStorage.getItem("authData")]);
1148
+ useEffect2(() => {
1149
+ const jettIdData = getJettIdCookieData();
1150
+ if (jettIdData == null ? void 0 : jettIdData.UserName) {
1151
+ setCookieUserName(jettIdData.UserName);
1152
+ }
1153
+ const cookieScope = getScopeFromJettIdCookie();
1154
+ if (cookieScope) {
1155
+ setScope(cookieScope);
1156
+ }
1157
+ }, []);
1158
+ const extractUrlFromOnClick = (onClick) => {
1159
+ if (!onClick || typeof onClick !== "function") return null;
1160
+ const funcString = onClick.toString();
1161
+ let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
1162
+ if (!match) {
1163
+ match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
1164
+ }
1165
+ if (match && match[1]) {
1166
+ try {
1167
+ if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
1168
+ const url = new URL(match[1]);
1169
+ return {
1170
+ pathname: url.pathname,
1171
+ search: url.search,
1172
+ fullPath: url.pathname + url.search
1173
+ };
1174
+ }
1175
+ if (match[1].startsWith("/")) {
1176
+ const url = new URL(match[1], window.location.origin);
1177
+ return {
1178
+ pathname: url.pathname,
1179
+ search: url.search,
1180
+ fullPath: url.pathname + url.search
1181
+ };
1182
+ }
1183
+ return null;
1184
+ } catch {
1185
+ const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
1186
+ if (pathMatch) {
1187
+ return {
1188
+ pathname: pathMatch[1],
1189
+ search: pathMatch[2] || "",
1190
+ fullPath: match[1]
1191
+ };
1192
+ }
1193
+ return null;
1194
+ }
1195
+ }
1196
+ return null;
1197
+ };
1198
+ const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
1199
+ if (!menuUrlData || !currentPath) return false;
1200
+ const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
1201
+ const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
1202
+ if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
1203
+ const menuParams = new URLSearchParams(menuUrlData.search);
1204
+ const currentParams = new URLSearchParams(currentSearch);
1205
+ const menuRole = menuParams.get("role");
1206
+ const currentRole = currentParams.get("role");
1207
+ if (menuRole && currentRole) {
1208
+ return menuRole === currentRole;
1209
+ }
1210
+ if (menuRole && !currentRole || !menuRole && currentRole) {
1211
+ return false;
1212
+ }
1213
+ return true;
1214
+ }
1215
+ if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
1216
+ return true;
1217
+ }
1218
+ if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
1219
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1220
+ if (currentPathParam === "supplier-list") {
1221
+ return true;
1222
+ }
1223
+ }
1224
+ if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
1225
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1226
+ if (currentPathParam === "supplier-deals") {
1227
+ return true;
1228
+ }
1229
+ }
1230
+ if (normalizedMenuPath === "/corporate/trips") {
1231
+ if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
1232
+ return true;
1233
+ }
1234
+ }
1235
+ if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
1236
+ const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
1237
+ if (menuPathParam) {
1238
+ const pathRouteMap = {
1239
+ "offer": "/offer/offer",
1240
+ "voucher": "/voucher/voucher",
1241
+ "tag": "/tags/tags",
1242
+ "special-requests": "/corporate/special-requests",
1243
+ "pricing-policy": "/policies/pricing-policy",
1244
+ "supplier-list": "/supplier",
1245
+ "users": "/users/users"
1246
+ // Consumer Ecosystem Users (no role param)
1247
+ };
1248
+ const expectedRoute = pathRouteMap[menuPathParam];
1249
+ if (expectedRoute) {
1250
+ if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1251
+ if (menuPathParam === "users") {
1252
+ const currentParams = new URLSearchParams(currentSearch);
1253
+ const currentRole = currentParams.get("role");
1254
+ return currentRole !== "admin";
1255
+ }
1256
+ return true;
1257
+ }
1258
+ }
1259
+ }
1260
+ if (normalizedCurrentPath === "/orgselector") {
1261
+ const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1262
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1263
+ if (menuPathParam2 && currentPathParam) {
1264
+ return menuPathParam2 === currentPathParam;
1265
+ }
1266
+ }
1267
+ }
1268
+ if (normalizedMenuPath === normalizedCurrentPath) {
1269
+ if (menuUrlData.search) {
1270
+ const menuParams = new URLSearchParams(menuUrlData.search);
1271
+ const currentParams = new URLSearchParams(currentSearch);
1272
+ for (const [key, value] of menuParams.entries()) {
1273
+ if (key === "auth") {
1274
+ continue;
1275
+ }
1276
+ if (currentParams.get(key) !== value) {
1277
+ return false;
1278
+ }
1279
+ }
1280
+ return true;
1281
+ }
1282
+ return true;
1283
+ }
1284
+ if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1285
+ return true;
1286
+ }
1287
+ return false;
1288
+ };
1289
+ const navItemsLocal = navItems ?? navItemsConstant;
1290
+ const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
1291
+ const logoFromCookie = getLogoFromJettIdCookie();
1292
+ const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1293
+ const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
1294
+ authData.userInfo.CDNBasePath,
1295
+ authData.userInfo.OrgLogo
1296
+ ) : null;
1297
+ const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1298
+ const detectAndSetActiveMenu = useCallback(() => {
1299
+ const currentPath = window.location.pathname;
1300
+ const currentSearch = window.location.search;
1301
+ const newOpenMenus = /* @__PURE__ */ new Set();
1302
+ let foundActivePath = null;
1303
+ navItemsLocal.forEach((item, index) => {
1304
+ if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1305
+ const itemUrlData = extractUrlFromOnClick(item.onClick);
1306
+ if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1307
+ foundActivePath = `menu-${index}`;
1308
+ }
1309
+ }
1310
+ if (item.options && item.options.length > 0) {
1311
+ item.options.forEach((option, optionsIndex) => {
1312
+ if (option.onClick && typeof option.onClick === "function") {
1313
+ const optionUrlData = extractUrlFromOnClick(option.onClick);
1314
+ if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1315
+ const menuKey = `menu-${index}`;
1316
+ newOpenMenus.add(menuKey);
1317
+ foundActivePath = `menu-${index}-option-${optionsIndex}`;
1318
+ if (option.options && option.options.length > 0) {
1319
+ option.options.forEach((subOption, subIndex) => {
1320
+ const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1321
+ if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1322
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1323
+ newOpenMenus.add(subMenuKey);
1324
+ foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1325
+ }
1326
+ });
1327
+ }
1328
+ }
1329
+ }
1330
+ });
1331
+ }
1332
+ });
1333
+ if (foundActivePath) {
1334
+ setOpenMenus(newOpenMenus);
1335
+ setActiveMenuPath(foundActivePath);
1336
+ }
1337
+ }, [navItemsLocal]);
1338
+ const [currentUrl, setCurrentUrl] = useState4(
1339
+ () => window.location.pathname + window.location.search
1340
+ );
1341
+ useEffect2(() => {
1342
+ detectAndSetActiveMenu();
1343
+ setCurrentUrl(window.location.pathname + window.location.search);
1344
+ }, [detectAndSetActiveMenu]);
1345
+ useEffect2(() => {
1346
+ let lastUrl = window.location.pathname + window.location.search;
1347
+ const handleLocationChange = () => {
1348
+ const newUrl = window.location.pathname + window.location.search;
1349
+ if (newUrl !== lastUrl) {
1350
+ lastUrl = newUrl;
1351
+ setCurrentUrl(newUrl);
1352
+ detectAndSetActiveMenu();
1353
+ }
1354
+ };
1355
+ window.addEventListener("popstate", handleLocationChange);
1356
+ const checkInterval = setInterval(() => {
1357
+ const newUrl = window.location.pathname + window.location.search;
1358
+ if (newUrl !== lastUrl) {
1359
+ handleLocationChange();
1360
+ }
1361
+ }, 250);
1362
+ return () => {
1363
+ window.removeEventListener("popstate", handleLocationChange);
1364
+ clearInterval(checkInterval);
1365
+ };
1366
+ }, [detectAndSetActiveMenu]);
1367
+ useEffect2(() => {
1368
+ detectAndSetActiveMenu();
1369
+ }, [currentUrl, detectAndSetActiveMenu]);
1370
+ const toggleMobileMenu = () => {
1371
+ setIsMobileMenuOpen(!isMobileMenuOpen);
1372
+ };
1373
+ const closeMobileMenu = () => {
1374
+ setIsMobileMenuOpen(false);
1375
+ };
1376
+ return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ React14.createElement(
1377
+ "button",
1378
+ {
1379
+ onClick: toggleMobileMenu,
1380
+ className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
1381
+ "aria-label": "Toggle menu",
1382
+ id: `${id}-button-1`
1383
+ },
1384
+ isMobileMenuOpen ? /* @__PURE__ */ React14.createElement(X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ React14.createElement(Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
1385
+ ), /* @__PURE__ */ React14.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ React14.createElement(
1386
+ "img",
1387
+ {
1388
+ src: sideBarLogoLocal,
1389
+ alt: "sidebarLogo",
1390
+ width: 208,
1391
+ height: 40,
1392
+ className: "object-contain",
1393
+ id: `${id}-img-1`
1394
+ }
1395
+ )), /* @__PURE__ */ React14.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ React14.createElement(
1396
+ "div",
1397
+ {
1398
+ className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1399
+ onClick: closeMobileMenu,
1400
+ id: `${id}-div-4`
1401
+ }
1402
+ ), /* @__PURE__ */ React14.createElement(
1403
+ "div",
1404
+ {
1405
+ className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
1406
+ id: `${id}-div-5`
1407
+ },
1408
+ /* @__PURE__ */ React14.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ React14.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ React14.createElement(
1409
+ "img",
1410
+ {
1411
+ src: sideBarLogoLocal,
1412
+ alt: "sidebarLogo",
1413
+ width: 108,
1414
+ height: 40,
1415
+ className: "object-contain",
1416
+ id: `${id}-img-2`
1417
+ }
1418
+ ))),
1419
+ /* @__PURE__ */ React14.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
1420
+ /* @__PURE__ */ React14.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1421
+ const menuKey = `menu-${index}`;
1422
+ const isOpen = isMenuOpen(menuKey);
1423
+ const isActive = activeMenuPath === menuKey;
1424
+ return /* @__PURE__ */ React14.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ React14.createElement(
1425
+ "div",
1426
+ {
1427
+ className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1428
+ onClick: (e) => handleMenuClick(item, index, e),
1429
+ id: `${id}-div-12`
1430
+ },
1431
+ /* @__PURE__ */ React14.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ React14.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
1432
+ /* @__PURE__ */ React14.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
1433
+ item.isDropDown && /* @__PURE__ */ React14.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ React14.createElement(ChevronDown3, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1434
+ ), item.options && item.options.length > 0 && /* @__PURE__ */ React14.createElement(
1435
+ "div",
1436
+ {
1437
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1438
+ id: `${id}-div-15`
1439
+ },
1440
+ item.options.map((options, optionsIndex) => {
1441
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1442
+ const isSubMenuOpen = isMenuOpen(subMenuKey);
1443
+ const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1444
+ const isDisabled = options.isDisabled;
1445
+ return /* @__PURE__ */ React14.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ React14.createElement(
1446
+ "div",
1447
+ {
1448
+ className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
1449
+ onClick: (e) => {
1450
+ if (isDisabled) {
1451
+ e.preventDefault();
1452
+ return;
1453
+ }
1454
+ handleSubMenuClick(options, optionsIndex, index, e);
1455
+ },
1456
+ id: `${id}-div-17-${optionsIndex}`
1457
+ },
1458
+ /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
1459
+ /* @__PURE__ */ React14.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
1460
+ options.isDropDown && /* @__PURE__ */ React14.createElement(
1461
+ "div",
1462
+ {
1463
+ className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
1464
+ id: `${id}-div-19-${optionsIndex}`
1465
+ },
1466
+ /* @__PURE__ */ React14.createElement(ChevronDown3, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1467
+ )
1468
+ ), options.options && options.options.length > 0 && /* @__PURE__ */ React14.createElement(
1469
+ "div",
1470
+ {
1471
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1472
+ id: `${id}-div-20-${optionsIndex}`
1473
+ },
1474
+ options.options.map((subOption, subIndex) => {
1475
+ const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1476
+ return /* @__PURE__ */ React14.createElement(
1477
+ "div",
1478
+ {
1479
+ key: subIndex,
1480
+ className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1481
+ onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
1482
+ id: `${id}-div-21-${subIndex}`
1483
+ },
1484
+ subOption.label
1485
+ );
1486
+ })
1487
+ ));
1488
+ })
1489
+ ));
1490
+ }))),
1491
+ /* @__PURE__ */ React14.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ React14.createElement(
1492
+ "div",
1493
+ {
1494
+ className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1495
+ onClick: () => setIsSwitchProfileOpen((prev) => !prev),
1496
+ id: `${id}-div-23`
1497
+ },
1498
+ /* @__PURE__ */ React14.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ React14.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ React14.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ React14.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ React14.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ React14.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
1499
+ /* @__PURE__ */ React14.createElement(
1500
+ "span",
1501
+ {
1502
+ className: "text-gray-600 dark:text-gray-400",
1503
+ id: `${id}-span-switch`
1504
+ },
1505
+ /* @__PURE__ */ React14.createElement(ChevronRight, { width: 20, height: 22 })
1506
+ )
1507
+ ), /* @__PURE__ */ React14.createElement(
1508
+ SwitchProfileSection,
1509
+ {
1510
+ id: `${id}-switch-profile`,
1511
+ open: isSwitchProfileOpen,
1512
+ anchorRef: profileCardRef,
1513
+ onClose: () => setIsSwitchProfileOpen(false),
1514
+ onManageProfile: () => {
1515
+ setIsSwitchProfileOpen(false);
1516
+ window.location.href = "/profile";
1517
+ },
1518
+ onProfileSwitch: (profile) => {
1519
+ setIsSwitchProfileOpen(false);
1520
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
1521
+ },
1522
+ onTmcSettings: () => {
1523
+ setIsSwitchProfileOpen(false);
1524
+ onTmcSettings == null ? void 0 : onTmcSettings();
1525
+ },
1526
+ onLogout: () => {
1527
+ setIsSwitchProfileOpen(false);
1528
+ if (onLogout) {
1529
+ onLogout();
1530
+ } else {
1531
+ window.location.href = `${window.location.origin}/login/logout`;
1532
+ }
1533
+ }
1534
+ }
1535
+ ))
1536
+ ));
1537
+ };
1538
+
1539
+ // src/RightSheet/RightSheet.jsx
1540
+ import React15, { useEffect as useEffect3, useState as useState5 } from "react";
1541
+ var RightSheet = ({
1542
+ id = "right-sheet",
1543
+ open,
1544
+ setOpen,
1545
+ children,
1546
+ callBack,
1547
+ actionLabel = "Save",
1548
+ onAction = () => {
1549
+ },
1550
+ showFooter = true
1551
+ }) => {
1552
+ const [visible, setVisible] = useState5(open);
1553
+ useEffect3(() => {
1554
+ if (open) {
1555
+ document.body.style.overflow = "hidden";
1556
+ setVisible(true);
1557
+ }
1558
+ return () => {
1559
+ document.body.style.overflow = "auto";
1560
+ };
1561
+ }, [open]);
1562
+ const handleClose = () => {
1563
+ setVisible(false);
1564
+ setTimeout(() => {
1565
+ setOpen(false);
1566
+ callBack();
1567
+ }, 200);
1568
+ };
1569
+ const handleAction = () => {
1570
+ onAction();
1571
+ handleClose();
1572
+ };
1573
+ if (!visible) return null;
1574
+ return /* @__PURE__ */ React15.createElement(
1575
+ "div",
1576
+ {
1577
+ className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1578
+ onClick: handleClose,
1579
+ id: `${id}-div-1`
1580
+ },
1581
+ /* @__PURE__ */ React15.createElement(
1582
+ "div",
1583
+ {
1584
+ className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1585
+ ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1586
+ onClick: (e) => e.stopPropagation(),
1587
+ id: `${id}-div-2`
1588
+ },
1589
+ /* @__PURE__ */ React15.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1590
+ showFooter && /* @__PURE__ */ React15.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ React15.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ React15.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1591
+ )
1592
+ );
1593
+ };
1594
+
1595
+ // src/Table/CustomTable.jsx
1596
+ import React16 from "react";
1597
+ var CustomTable = ({
1598
+ id = "custom-table",
1599
+ tableHeader,
1600
+ setIsAllChecked,
1601
+ isAllChecked,
1602
+ children,
1603
+ isHideCheckbox = "false"
1604
+ }) => {
1605
+ return /* @__PURE__ */ React16.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ React16.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ React16.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ React16.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ React16.createElement(
1606
+ "tr",
1607
+ {
1608
+ className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1609
+ id: `${id}-tr-1`
1610
+ },
1611
+ !isHideCheckbox && /* @__PURE__ */ React16.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ React16.createElement(
1612
+ CustomCheckbox,
1613
+ {
1614
+ checked: isAllChecked,
1615
+ onChange: () => {
1616
+ setIsAllChecked(!isAllChecked);
1617
+ },
1618
+ id: `${id}-custom-checkbox-1`
1619
+ }
1620
+ )),
1621
+ tableHeader.map((header, index) => {
1622
+ return /* @__PURE__ */ React16.createElement(
1623
+ "th",
1624
+ {
1625
+ className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1626
+ key: header + index,
1627
+ id: `${id}-th-2-${index}`
1628
+ },
1629
+ header
1630
+ );
1631
+ })
1632
+ )), /* @__PURE__ */ React16.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1633
+ };
1634
+
1635
+ // src/inputs/Dropdown.jsx
1636
+ import React17, { useId, useMemo } from "react";
1637
+ import ReactSelect from "react-select";
1638
+ var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
1639
+ function buildStyles(isDark, error) {
1640
+ return {
1641
+ control: (base, state) => ({
1642
+ ...base,
1643
+ minHeight: "40px !important",
1644
+ fontSize: 14,
1645
+ borderRadius: "6px",
1646
+ boxShadow: "none",
1647
+ backgroundColor: state.isDisabled ? "#f3f4f6" : error ? "#fef2f2" : isDark ? "#18181b" : "#ffffff",
1648
+ borderColor: state.isDisabled ? "#d1d5db" : error ? "#ef4444" : isDark ? "#303036" : "#e5e5e5",
1649
+ outline: state.isFocused ? "2px solid #000" : "none",
1650
+ outlineOffset: "2px",
1651
+ "&:hover": {
1652
+ borderColor: error ? "#ef4444" : "none"
1653
+ }
1654
+ }),
1655
+ menu: (base) => ({
1656
+ ...base,
1657
+ backgroundColor: isDark ? "#18181b" : "#ffffff",
1658
+ zIndex: 9999
1659
+ }),
1660
+ menuPortal: (base) => ({ ...base, zIndex: 9999 }),
1661
+ option: (base, state) => ({
1662
+ ...base,
1663
+ fontSize: 14,
1664
+ cursor: "pointer",
1665
+ backgroundColor: state.isSelected ? "#0087FA" : state.isFocused ? isDark ? "#303036" : "#EBF5FF" : "transparent",
1666
+ color: state.isSelected ? "#ffffff" : isDark ? "#f3f4f6" : "#111827",
1667
+ "&:active": { backgroundColor: "#0087FA", color: "#ffffff" }
1668
+ }),
1669
+ singleValue: (base, state) => ({
1670
+ ...base,
1671
+ fontSize: 14,
1672
+ fontWeight: 400,
1673
+ color: state.isDisabled ? "#6b7280" : isDark ? "#f3f4f6" : "#111827"
1674
+ }),
1675
+ multiValue: (base) => ({
1676
+ ...base,
1677
+ backgroundColor: isDark ? "#303036" : "#EBF5FF"
1678
+ }),
1679
+ multiValueLabel: (base) => ({
1680
+ ...base,
1681
+ fontSize: 12,
1682
+ color: isDark ? "#f3f4f6" : "#0087FA"
1683
+ }),
1684
+ multiValueRemove: (base) => ({
1685
+ ...base,
1686
+ color: isDark ? "#9ca3af" : "#0087FA",
1687
+ "&:hover": { backgroundColor: "#0087FA", color: "#ffffff" }
1688
+ }),
1689
+ placeholder: (base) => ({
1690
+ ...base,
1691
+ fontSize: 14,
1692
+ fontWeight: 400,
1693
+ color: "#6b7280"
1694
+ }),
1695
+ input: (base) => ({
1696
+ ...base,
1697
+ fontSize: 14,
1698
+ fontWeight: 400,
1699
+ color: isDark ? "#f3f4f6" : "#111827"
1700
+ }),
1701
+ indicatorSeparator: () => ({ display: "none" }),
1702
+ dropdownIndicator: (base) => ({
1703
+ ...base,
1704
+ padding: "0 6px",
1705
+ color: isDark ? "#9ca3af" : "#6b7280"
1706
+ }),
1707
+ clearIndicator: (base) => ({
1708
+ ...base,
1709
+ padding: "0 4px",
1710
+ color: isDark ? "#9ca3af" : "#6b7280",
1711
+ cursor: "pointer",
1712
+ "&:hover": { color: "#0087FA" }
1713
+ }),
1714
+ valueContainer: (base) => ({ ...base, padding: "2px 16px" })
1715
+ };
1716
+ }
1717
+ var Dropdown = React17.forwardRef(
1718
+ ({
1719
+ id = "dropdown",
1720
+ options,
1721
+ placeholder = "Select...",
1722
+ isDisabled = false,
1723
+ isClearable = true,
1724
+ isLoading = false,
1725
+ error = false,
1726
+ label,
1727
+ heading,
1728
+ isRequired = false,
1729
+ name,
1730
+ menuPortalTarget,
1731
+ menuPosition = "absolute",
1732
+ className,
1733
+ style,
1734
+ isMulti = false,
1735
+ value,
1736
+ onChange
1737
+ }, ref) => {
1738
+ const reactId = useId();
1739
+ const isDark = isDarkMode();
1740
+ const styles = useMemo(() => buildStyles(isDark, !!error), [isDark, error]);
1741
+ const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
1742
+ const handleChange = (selected) => {
1743
+ if (isMulti) {
1744
+ onChange((selected ?? []).map((o) => o.value));
1745
+ } else {
1746
+ onChange((selected == null ? void 0 : selected.value) ?? null);
1747
+ }
1748
+ };
1749
+ return /* @__PURE__ */ React17.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ React17.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ React17.createElement(
1750
+ "label",
1751
+ {
1752
+ htmlFor: reactId,
1753
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
1754
+ id: `${id}-label-1`
1755
+ },
1756
+ label,
1757
+ isRequired && /* @__PURE__ */ React17.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
1758
+ ), /* @__PURE__ */ React17.createElement(
1759
+ ReactSelect,
1760
+ {
1761
+ ref,
1762
+ inputId: reactId,
1763
+ name,
1764
+ options,
1765
+ value: selectedValue,
1766
+ onChange: handleChange,
1767
+ placeholder,
1768
+ isDisabled,
1769
+ isClearable,
1770
+ isLoading,
1771
+ isMulti,
1772
+ styles,
1773
+ menuPortalTarget,
1774
+ menuPosition,
1775
+ classNamePrefix: "jett-dropdown"
1776
+ }
1777
+ ));
1778
+ }
1779
+ );
1780
+ Dropdown.displayName = "Dropdown";
1781
+
1782
+ // src/Calendar/Calendar.tsx
1783
+ import React18, { useEffect as useEffect4, useState as useState6 } from "react";
1784
+ import {
1785
+ DatePicker,
1786
+ DateTimePicker,
1787
+ DatesProvider
1788
+ } from "@mantine/dates";
1789
+ var Calendar = (props) => {
1790
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1791
+ const {
1792
+ minDate,
1793
+ maxDate,
1794
+ excludeDate,
1795
+ firstDayOfWeek = 1,
1796
+ locale,
1797
+ size,
1798
+ className,
1799
+ error
1800
+ } = props;
1801
+ const isRange = props.mode === "range";
1802
+ const isDateTime = props.mode === "datetime";
1803
+ const datesProviderSettings = {
1804
+ firstDayOfWeek,
1805
+ consistentWeeks: true
1806
+ };
1807
+ if (locale) {
1808
+ datesProviderSettings.locale = locale;
1809
+ }
1810
+ const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
1811
+ const [displayDate, setDisplayDate] = useState6(anchorDate ?? void 0);
1812
+ const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
1813
+ useEffect4(() => {
1814
+ if (anchorTime !== void 0) {
1815
+ setDisplayDate(new Date(anchorTime));
1816
+ }
1817
+ }, [anchorTime]);
1818
+ const weekendColorStyle = {
1819
+ "--mantine-color-red-6": "var(--mantine-color-text)"
1820
+ };
1821
+ if (isRange) {
1822
+ const datePickerProps2 = {
1823
+ type: "range",
1824
+ value: props.value,
1825
+ defaultValue: props.defaultValue,
1826
+ onChange: props.onChange,
1827
+ minDate,
1828
+ maxDate,
1829
+ excludeDate,
1830
+ size,
1831
+ className,
1832
+ date: displayDate,
1833
+ onDateChange: setDisplayDate,
1834
+ style: weekendColorStyle
1835
+ };
1836
+ return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DatePicker, { ...datePickerProps2 }));
1837
+ }
1838
+ if (isDateTime) {
1839
+ const dateTimePickerProps = {
1840
+ value: props.value,
1841
+ defaultValue: props.defaultValue,
1842
+ onChange: props.onChange,
1843
+ minDate,
1844
+ maxDate,
1845
+ excludeDate,
1846
+ size,
1847
+ className,
1848
+ error,
1849
+ style: weekendColorStyle
1850
+ };
1851
+ return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DateTimePicker, { ...dateTimePickerProps }));
1852
+ }
1853
+ const datePickerProps = {
1854
+ value: props.value,
1855
+ defaultValue: props.defaultValue,
1856
+ onChange: props.onChange,
1857
+ minDate,
1858
+ maxDate,
1859
+ excludeDate,
1860
+ size,
1861
+ className,
1862
+ date: displayDate,
1863
+ onDateChange: setDisplayDate,
1864
+ style: weekendColorStyle
1865
+ };
1866
+ return /* @__PURE__ */ React18.createElement(DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ React18.createElement(DatePicker, { ...datePickerProps }));
1867
+ };
1868
+
1869
+ // src/Pagination/Pagination.jsx
1870
+ import React19, { useMemo as useMemo2, useState as useState7, useEffect as useEffect5 } from "react";
1871
+ import { ChevronLeft, ChevronRight as ChevronRight2, ChevronsLeft, ChevronsRight } from "lucide-react";
1872
+ var Pagination = ({
1873
+ id = "pagination",
1874
+ data = [],
1875
+ component: Component,
1876
+ itemsPerPage = 6,
1877
+ itemsPerPageOptions = [5, 10, 20, 50, 100],
1878
+ // Controlled props (optional)
1879
+ currentPage: controlledCurrentPage,
1880
+ onPageChange: controlledOnPageChange,
1881
+ onItemsPerPageChange: controlledOnItemsPerPageChange,
1882
+ // Legacy props for backward compatibility
1883
+ totalPages,
1884
+ totalItems: legacyTotalItems,
1885
+ onPageChange: legacyOnPageChange,
1886
+ onItemsPerPageChange: legacyOnItemsPerPageChange,
1887
+ tableHeader,
1888
+ isHideCheckbox,
1889
+ callback,
1890
+ isTable = false,
1891
+ // Component props - any additional props to pass to the component
1892
+ componentProps = {},
1893
+ ...restProps
1894
+ }) => {
1895
+ const [internalCurrentPage, setInternalCurrentPage] = useState7(1);
1896
+ const [internalItemsPerPage, setInternalItemsPerPage] = useState7(itemsPerPage);
1897
+ const isControlled = controlledCurrentPage !== void 0;
1898
+ const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1899
+ const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1900
+ const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1901
+ const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1902
+ const calculatedTotalPages = useMemo2(() => {
1903
+ if (totalItems > 0 && activeItemsPerPage > 0) {
1904
+ return Math.ceil(totalItems / activeItemsPerPage);
1905
+ }
1906
+ return 1;
1907
+ }, [totalItems, activeItemsPerPage]);
1908
+ const paginatedData = useMemo2(() => {
1909
+ if (!data || data.length === 0) return [];
1910
+ const startIndex = (currentPage - 1) * activeItemsPerPage;
1911
+ const endIndex = startIndex + activeItemsPerPage;
1912
+ return data.slice(startIndex, endIndex);
1913
+ }, [data, currentPage, activeItemsPerPage]);
1914
+ useEffect5(() => {
1915
+ if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1916
+ setInternalCurrentPage(1);
1917
+ }
1918
+ }, [calculatedTotalPages, isControlled, currentPage]);
1919
+ const getPageNumbers = () => {
1920
+ const pages = [];
1921
+ const maxVisible = 5;
1922
+ let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1923
+ let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1924
+ if (endPage - startPage < maxVisible - 1) {
1925
+ startPage = Math.max(1, endPage - maxVisible + 1);
1926
+ }
1927
+ for (let i = startPage; i <= endPage; i++) {
1928
+ pages.push(i);
1929
+ }
1930
+ return pages;
1931
+ };
1932
+ const handlePageChange = (page) => {
1933
+ if (page >= 1 && page <= calculatedTotalPages) {
1934
+ if (isControlled && controlledOnPageChange) {
1935
+ controlledOnPageChange(page);
1936
+ } else if (legacyOnPageChange) {
1937
+ legacyOnPageChange(page);
1938
+ } else {
1939
+ setInternalCurrentPage(page);
1940
+ }
1941
+ }
1942
+ };
1943
+ const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1944
+ const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1945
+ const renderContent = () => {
1946
+ if (Component) {
1947
+ if (React19.isValidElement(Component)) {
1948
+ const ComponentType = Component.type;
1949
+ const elementProps = Component.props;
1950
+ if (isTable) {
1951
+ return /* @__PURE__ */ React19.createElement(
1952
+ CustomTable,
1953
+ {
1954
+ tableHeader,
1955
+ isHideCheckbox,
1956
+ id: `${id}-custom-table-1`
1957
+ },
1958
+ data.map((item, index) => {
1959
+ return /* @__PURE__ */ React19.createElement(
1960
+ ComponentType,
1961
+ {
1962
+ key: item.id || item._id || index,
1963
+ data: item,
1964
+ ...elementProps,
1965
+ ...componentProps,
1966
+ ...restProps,
1967
+ id: `${id}-component-type-1-${index}`
1968
+ }
1969
+ );
1970
+ })
1971
+ );
1972
+ } else {
1973
+ if (isTable) {
1974
+ return /* @__PURE__ */ React19.createElement(
1975
+ CustomTable,
1976
+ {
1977
+ tableHeader,
1978
+ isHideCheckbox,
1979
+ id: `${id}-custom-table-2`
1980
+ },
1981
+ paginatedData.map((item, index) => {
1982
+ return /* @__PURE__ */ React19.createElement(
1983
+ ComponentType,
1984
+ {
1985
+ key: item.id || item._id || index,
1986
+ data: item,
1987
+ ...elementProps,
1988
+ ...componentProps,
1989
+ ...restProps,
1990
+ id: `${id}-component-type-2-${index}`
1991
+ }
1992
+ );
1993
+ })
1994
+ );
1995
+ }
1996
+ }
1997
+ } else {
1998
+ return /* @__PURE__ */ React19.createElement(
1999
+ CustomTable,
2000
+ {
2001
+ tableHeader,
2002
+ isHideCheckbox,
2003
+ id: `${id}-custom-table-3`
2004
+ },
2005
+ paginatedData.map((item, index) => {
2006
+ return /* @__PURE__ */ React19.createElement(
2007
+ Component,
2008
+ {
2009
+ key: item.id || item._id || index,
2010
+ data: item,
2011
+ ...componentProps,
2012
+ ...restProps,
2013
+ id: `${id}-component-1-${index}`
2014
+ }
2015
+ );
2016
+ })
2017
+ );
2018
+ }
2019
+ }
2020
+ return null;
2021
+ };
2022
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(React19.Fragment, null, renderContent()), /* @__PURE__ */ React19.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ React19.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ React19.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ React19.createElement(
2023
+ "button",
2024
+ {
2025
+ onClick: () => handlePageChange(1),
2026
+ disabled: currentPage === 1,
2027
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2028
+ title: "First page",
2029
+ id: `${id}-button-1`
2030
+ },
2031
+ /* @__PURE__ */ React19.createElement(ChevronsLeft, { size: 16 })
2032
+ ), /* @__PURE__ */ React19.createElement(
2033
+ "button",
2034
+ {
2035
+ onClick: () => handlePageChange(currentPage - 1),
2036
+ disabled: currentPage === 1,
2037
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2038
+ title: "Previous page",
2039
+ id: `${id}-button-2`
2040
+ },
2041
+ /* @__PURE__ */ React19.createElement(ChevronLeft, { size: 16 })
2042
+ ), getPageNumbers().map((pageNum) => /* @__PURE__ */ React19.createElement(
2043
+ "button",
2044
+ {
2045
+ key: pageNum,
2046
+ onClick: () => handlePageChange(pageNum),
2047
+ className: `flex items-center justify-center min-w-9 h-9 px-3 cursor-pointer rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === pageNum ? "bg-primary text-white border-primary dark:bg-primary" : "bg-white text-black hover:bg-gray-50 dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2048
+ id: `${id}-button-3`
2049
+ },
2050
+ pageNum
2051
+ )), /* @__PURE__ */ React19.createElement(
2052
+ "button",
2053
+ {
2054
+ onClick: () => handlePageChange(currentPage + 1),
2055
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2056
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2057
+ title: "Next page",
2058
+ id: `${id}-button-4`
2059
+ },
2060
+ /* @__PURE__ */ React19.createElement(ChevronRight2, { size: 16 })
2061
+ ), /* @__PURE__ */ React19.createElement(
2062
+ "button",
2063
+ {
2064
+ onClick: () => handlePageChange(calculatedTotalPages),
2065
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2066
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
2067
+ title: "Last page",
2068
+ id: `${id}-button-5`
2069
+ },
2070
+ /* @__PURE__ */ React19.createElement(ChevronsRight, { size: 16 })
2071
+ ))));
2072
+ };
2073
+ export {
2074
+ AppSideBar,
2075
+ Calendar,
2076
+ Chip,
2077
+ CustomAutocomplete,
2078
+ CustomButton,
2079
+ CustomCheckbox,
2080
+ CustomInput,
2081
+ CustomSearch,
2082
+ CustomSelect,
2083
+ CustomSwitch,
2084
+ CustomTable,
2085
+ CustomTextarea,
2086
+ CustomUpload,
2087
+ Dropdown,
2088
+ Pagination,
2089
+ ProgressBar,
2090
+ RightSheet
2091
+ };