jett.admin.npmpackage 2.0.1 → 2.0.2

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 +1434 -1434
  2. package/dist/index.js +1430 -1430
  3. package/dist/index.mjs +1395 -1395
  4. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,1395 +1,1395 @@
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
- variant = "DEFAULT",
18
- children,
19
- className,
20
- onClick,
21
- disabled = false,
22
- icon
23
- }) => {
24
- return /* @__PURE__ */ React.createElement(
25
- "div",
26
- {
27
- className: cn(
28
- `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`,
29
- variantStyles[variant],
30
- className
31
- ),
32
- onClick
33
- },
34
- icon && /* @__PURE__ */ React.createElement("div", null, icon),
35
- children
36
- );
37
- };
38
-
39
- // src/inputs/Autocomplete.jsx
40
- import React2, { useState, useRef } from "react";
41
- import { ChevronDown, Check, Search } from "lucide-react";
42
- var CustomAutocomplete = ({
43
- label,
44
- value,
45
- onChange,
46
- options,
47
- placeholder = "Search & select...",
48
- isRequired = false,
49
- error,
50
- heading,
51
- disabled = false
52
- }) => {
53
- const [open, setOpen] = useState(false);
54
- const [search, setSearch] = useState("");
55
- const wrapperRef = useRef(null);
56
- const selectedOptions = options.filter((opt) => value.includes(opt.value));
57
- const handleBlur = (e) => {
58
- var _a;
59
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
60
- setOpen(false);
61
- }
62
- };
63
- const filteredOptions = options.filter(
64
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
65
- );
66
- const toggleValue = (val) => {
67
- if (value.includes(val)) {
68
- onChange(value.filter((v) => v !== val));
69
- } else {
70
- onChange([...value, val]);
71
- }
72
- };
73
- return /* @__PURE__ */ React2.createElement(
74
- "div",
75
- {
76
- className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
77
- ref: wrapperRef,
78
- tabIndex: disabled ? -1 : 0,
79
- onBlur: handleBlur
80
- },
81
- heading && /* @__PURE__ */ React2.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1" }, heading),
82
- label && /* @__PURE__ */ React2.createElement(
83
- "label",
84
- {
85
- className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`
86
- },
87
- label,
88
- " ",
89
- isRequired && /* @__PURE__ */ React2.createElement("span", { className: "text-red-500" }, "*")
90
- ),
91
- /* @__PURE__ */ React2.createElement(
92
- "div",
93
- {
94
- onClick: () => {
95
- if (!disabled) setOpen((prev) => !prev);
96
- },
97
- 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
98
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
99
- ${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"}
100
- `
101
- },
102
- /* @__PURE__ */ React2.createElement("div", { className: "flex flex-wrap gap-1 flex-1" }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ React2.createElement(
103
- "span",
104
- {
105
- key: opt.value,
106
- 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"
107
- },
108
- opt.label,
109
- /* @__PURE__ */ React2.createElement(
110
- "button",
111
- {
112
- onClick: (e) => {
113
- e.stopPropagation();
114
- toggleValue(opt.value);
115
- },
116
- className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white"
117
- },
118
- "\u2715"
119
- )
120
- )) : /* @__PURE__ */ React2.createElement("span", { className: "text-gray-400" }, placeholder)),
121
- /* @__PURE__ */ React2.createElement(
122
- ChevronDown,
123
- {
124
- className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
125
- }
126
- )
127
- ),
128
- !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" }, /* @__PURE__ */ React2.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200" }, /* @__PURE__ */ React2.createElement(Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React2.createElement(
129
- "input",
130
- {
131
- type: "text",
132
- value: search,
133
- onChange: (e) => setSearch(e.target.value),
134
- placeholder: "Search...",
135
- className: "flex-1 text-sm focus:outline-none"
136
- }
137
- )), /* @__PURE__ */ React2.createElement("ul", null, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
138
- const selected = value.includes(opt.value);
139
- return /* @__PURE__ */ React2.createElement(
140
- "li",
141
- {
142
- key: opt.value,
143
- onClick: () => toggleValue(opt.value),
144
- 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" : ""}`
145
- },
146
- /* @__PURE__ */ React2.createElement(
147
- "span",
148
- {
149
- 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"}`
150
- },
151
- selected && /* @__PURE__ */ React2.createElement(Check, { size: 14 })
152
- ),
153
- opt.label
154
- );
155
- }) : /* @__PURE__ */ React2.createElement("li", { className: "px-3 py-2 text-sm text-gray-400" }, "No results found")))
156
- );
157
- };
158
-
159
- // src/inputs/Checkbox.jsx
160
- import React3 from "react";
161
- var CustomCheckbox = ({ onChange, checked }) => {
162
- const handleChange = (e) => {
163
- onChange(e.target.checked);
164
- };
165
- return /* @__PURE__ */ React3.createElement("label", { className: "inline-flex items-center cursor-pointer select-none" }, /* @__PURE__ */ React3.createElement(
166
- "input",
167
- {
168
- type: "checkbox",
169
- checked,
170
- onChange: handleChange,
171
- className: "peer hidden"
172
- }
173
- ), /* @__PURE__ */ React3.createElement(
174
- "span",
175
- {
176
- 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 "
177
- },
178
- checked && /* @__PURE__ */ React3.createElement(
179
- "svg",
180
- {
181
- className: "w-4 h-4 text-white",
182
- fill: "none",
183
- stroke: "currentColor",
184
- strokeWidth: "3",
185
- viewBox: "0 0 24 24"
186
- },
187
- /* @__PURE__ */ React3.createElement("path", { d: "M5 13l4 4L19 7" })
188
- )
189
- ));
190
- };
191
-
192
- // src/inputs/Chip.jsx
193
- import React4 from "react";
194
- var VARIANTS = {
195
- PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
196
- GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
197
- RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
198
- YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
199
- };
200
- var Chip = ({ label, variant }) => {
201
- return /* @__PURE__ */ React4.createElement(
202
- "div",
203
- {
204
- className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`
205
- },
206
- label
207
- );
208
- };
209
-
210
- // src/inputs/CustomSwitch.jsx
211
- import React5 from "react";
212
- var CustomSwitch = ({ checked, onChange, label, description }) => {
213
- return /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement(
214
- "button",
215
- {
216
- type: "button",
217
- role: "switch",
218
- "aria-checked": checked,
219
- onClick: () => onChange(!checked),
220
- className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`
221
- },
222
- /* @__PURE__ */ React5.createElement(
223
- "span",
224
- {
225
- className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`
226
- }
227
- )
228
- ), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-col" }, label && /* @__PURE__ */ React5.createElement("h3", { className: "font-[500] text-sm text-black mb-2" }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "font-[500] text-sm text-[#737373]" }, description)));
229
- };
230
-
231
- // src/inputs/Input.jsx
232
- import React6 from "react";
233
- var CustomInput = ({
234
- label,
235
- isRequired,
236
- value,
237
- onChange,
238
- placeholder,
239
- disabled = false,
240
- error,
241
- heading
242
- }) => {
243
- return /* @__PURE__ */ React6.createElement("div", { className: "flex flex-col gap-1 w-full" }, heading && /* @__PURE__ */ React6.createElement("h3", { className: "text-lg font-semibold" }, heading), /* @__PURE__ */ React6.createElement(
244
- "label",
245
- {
246
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`
247
- },
248
- label,
249
- " ",
250
- isRequired && /* @__PURE__ */ React6.createElement("span", { className: "text-red-500" }, "*")
251
- ), /* @__PURE__ */ React6.createElement(
252
- "input",
253
- {
254
- className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
255
- focus:outline-2 outline-black dark:outline-white outline-offset-2
256
- dark:bg-transparent dark:text-white dark:border-[#303036]
257
- ${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%)]"}
258
- `,
259
- value,
260
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
261
- placeholder,
262
- disabled,
263
- readOnly: disabled
264
- }
265
- ));
266
- };
267
-
268
- // src/inputs/ProgressBar.jsx
269
- import React7 from "react";
270
- var ProgressBar = ({ step, totalSteps }) => {
271
- const progress = step / totalSteps * 100;
272
- return /* @__PURE__ */ React7.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React7.createElement("p", { className: "text-gray-600 text-sm mb-2" }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ React7.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2" }, /* @__PURE__ */ React7.createElement(
273
- "div",
274
- {
275
- className: "bg-black h-2 rounded-full transition-all duration-300",
276
- style: { width: `${progress}%` }
277
- }
278
- )));
279
- };
280
-
281
- // src/inputs/Search.jsx
282
- import React8 from "react";
283
- import { Search as Search2 } from "lucide-react";
284
- var CustomSearch = ({
285
- value,
286
- onChange,
287
- placeholder = "Search Markets..."
288
- }) => {
289
- 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" }, /* @__PURE__ */ React8.createElement(Search2, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ React8.createElement(
290
- "input",
291
- {
292
- type: "text",
293
- value,
294
- onChange,
295
- placeholder,
296
- className: "bg-transparent w-full h-full focus:outline-none"
297
- }
298
- ));
299
- };
300
-
301
- // src/inputs/TextArea.jsx
302
- import React9 from "react";
303
- var CustomTextarea = ({
304
- label,
305
- isRequired,
306
- value,
307
- onChange,
308
- placeholder,
309
- disabled = false,
310
- error,
311
- heading,
312
- rows = 4
313
- }) => {
314
- return /* @__PURE__ */ React9.createElement("div", { className: "flex flex-col gap-1 w-full" }, heading && /* @__PURE__ */ React9.createElement("h3", { className: "text-lg font-semibold" }, heading), /* @__PURE__ */ React9.createElement(
315
- "label",
316
- {
317
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`
318
- },
319
- label,
320
- " ",
321
- isRequired && /* @__PURE__ */ React9.createElement("span", { className: "text-red-500" }, "*")
322
- ), /* @__PURE__ */ React9.createElement(
323
- "textarea",
324
- {
325
- rows,
326
- className: `border rounded-md px-4 py-2 w-full text-[14px]
327
- focus:outline-2 focus:outline-black focus:outline-offset-2
328
- focus:ring-0 focus:shadow-none focus:border-black
329
- ${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%)]"}
330
- `,
331
- value,
332
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
333
- placeholder,
334
- disabled,
335
- readOnly: disabled
336
- }
337
- ));
338
- };
339
-
340
- // src/inputs/Upload.jsx
341
- import React10, { useRef as useRef2 } from "react";
342
- import { Upload } from "lucide-react";
343
- var CustomUpload = ({
344
- label = "Supporting documents",
345
- description = "Drop items here or Browse Files",
346
- accept = ".pdf,.jpg,.jpeg,.png",
347
- maxSizeMB = 5,
348
- onChange,
349
- error,
350
- value
351
- }) => {
352
- const inputRef = useRef2(null);
353
- const handleFileSelect = (files) => {
354
- if (!files || files.length === 0) return;
355
- const selectedFile = files[0];
356
- if (selectedFile.size > maxSizeMB * 1024 * 1024) {
357
- alert(`File size must be less than ${maxSizeMB} MB`);
358
- return;
359
- }
360
- onChange == null ? void 0 : onChange(selectedFile);
361
- };
362
- return /* @__PURE__ */ React10.createElement("div", { className: "flex flex-col gap-2 w-full" }, label && /* @__PURE__ */ React10.createElement("label", { className: "text-sm font-medium" }, label), /* @__PURE__ */ React10.createElement(
363
- "div",
364
- {
365
- className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
366
- ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
367
- onClick: () => {
368
- var _a;
369
- return (_a = inputRef.current) == null ? void 0 : _a.click();
370
- },
371
- onDragOver: (e) => e.preventDefault(),
372
- onDrop: (e) => {
373
- e.preventDefault();
374
- handleFileSelect(e.dataTransfer.files);
375
- }
376
- },
377
- /* @__PURE__ */ React10.createElement(Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
378
- /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-gray-700" }, description),
379
- /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-gray-500 mt-1" }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
380
- /* @__PURE__ */ React10.createElement(
381
- "input",
382
- {
383
- ref: inputRef,
384
- type: "file",
385
- accept,
386
- className: "hidden",
387
- onChange: (e) => handleFileSelect(e.target.files)
388
- }
389
- )
390
- ), value && /* @__PURE__ */ React10.createElement("span", { className: "text-sm truncate text-gray-500" }, "Selected: ", value.name), error && /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-red-500" }, error));
391
- };
392
-
393
- // src/sideBar/SideBar.jsx
394
- import {
395
- ChevronDown as ChevronDown3,
396
- Globe,
397
- LogOut,
398
- Menu,
399
- X
400
- } from "lucide-react";
401
- import React12, { useEffect, useState as useState3, useCallback } from "react";
402
-
403
- // ConstantUI.js
404
- import {
405
- Home,
406
- Banknote,
407
- LifeBuoy,
408
- Cog,
409
- Building,
410
- Handshake,
411
- DollarSign,
412
- BarChart3
413
- } from "lucide-react";
414
- var encodedAuthData = localStorage.getItem("encodedAuthData");
415
- var navItemsConstant = [
416
- {
417
- Icon: Home,
418
- label: "Home",
419
- onClick: () => {
420
- window.location.href = "/";
421
- },
422
- isDropDown: false
423
- },
424
- {
425
- Icon: Building,
426
- label: "Consumer Ecosystem",
427
- onClick: () => {
428
- },
429
- options: [
430
- {
431
- label: "Corporate",
432
- onClick: () => {
433
- window.location.href = "/corporate/";
434
- }
435
- },
436
- {
437
- label: "Trips",
438
- onClick: () => {
439
- window.location.href = "/trips/";
440
- }
441
- },
442
- {
443
- label: "Users",
444
- onClick: () => {
445
- window.location.href = "/users/users";
446
- }
447
- },
448
- {
449
- label: "Tags (Consumer Variables)",
450
- onClick: () => {
451
- window.location.href = "/orgselector/?path=tag";
452
- }
453
- },
454
- {
455
- label: "Special Request",
456
- onClick: () => {
457
- window.location.href = "/orgselector/?path=special-requests";
458
- }
459
- },
460
- {
461
- label: "Support Tickets (Coming Soon)",
462
- isDisabled: true
463
- // onClick: () => {},
464
- }
465
- ],
466
- isDropDown: true
467
- },
468
- {
469
- Icon: Banknote,
470
- label: "Finance",
471
- onClick: () => {
472
- },
473
- isDropDown: true,
474
- options: [
475
- {
476
- label: "Credit Management",
477
- onClick: () => {
478
- window.location.href = "/finance/paymentsLedger/";
479
- }
480
- },
481
- {
482
- label: "Booking & Invoices",
483
- onClick: () => {
484
- window.location.href = "/finance/bookingHistory/";
485
- }
486
- }
487
- ]
488
- },
489
- {
490
- Icon: DollarSign,
491
- label: "Revenue Management",
492
- onClick: () => {
493
- },
494
- isDropDown: true,
495
- options: [
496
- {
497
- label: "Pricing Engine",
498
- onClick: () => {
499
- window.location.href = "/orgselector/?path=pricing-policy";
500
- }
501
- },
502
- {
503
- label: "Offers",
504
- onClick: () => {
505
- window.location.href = "/orgselector/?path=offer";
506
- }
507
- },
508
- {
509
- label: "Vouchers",
510
- onClick: () => {
511
- window.location.href = "/orgselector/?path=voucher";
512
- }
513
- }
514
- ]
515
- },
516
- {
517
- Icon: Handshake,
518
- label: "Supplier Ecosystem",
519
- onClick: () => {
520
- },
521
- isDropDown: true,
522
- options: [
523
- {
524
- label: "Suppliers List",
525
- onClick: () => {
526
- window.location.href = "/orgselector/?path=supplier-list";
527
- }
528
- },
529
- {
530
- label: "Supplier Deals",
531
- onClick: () => {
532
- window.location.href = "/supplierdeals/";
533
- }
534
- }
535
- ]
536
- },
537
- {
538
- Icon: BarChart3,
539
- label: "Reports",
540
- onClick: () => {
541
- },
542
- isDropDown: true,
543
- options: [
544
- {
545
- label: "Reports (Coming Soon)",
546
- isDisabled: true
547
- // onClick: () => {
548
- // window.open("https://viz.jett.travel", "_blank");
549
- // },
550
- }
551
- ]
552
- },
553
- {
554
- Icon: Cog,
555
- label: "Settings",
556
- onClick: () => {
557
- },
558
- isDropDown: true,
559
- options: [
560
- {
561
- label: "Whitelabel",
562
- onClick: () => {
563
- window.location.href = "/whitelabel/";
564
- }
565
- },
566
- {
567
- label: "Markets",
568
- onClick: () => {
569
- window.location.href = "/market/";
570
- }
571
- },
572
- {
573
- label: "Users",
574
- onClick: () => {
575
- window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
576
- }
577
- },
578
- {
579
- label: "Reports Configurations (Coming Soon)",
580
- isDisabled: true
581
- // onClick: () => {},
582
- }
583
- ]
584
- }
585
- ];
586
- var additionalItemsConstant = [
587
- {
588
- Icon: LifeBuoy,
589
- label: "Help",
590
- onClick: () => {
591
- window.location.href = "/help";
592
- }
593
- }
594
- ];
595
-
596
- // src/assests/logo/logo-white.svg
597
- var logo_white_default = "./logo-white-RYMEJOWI.svg";
598
-
599
- // src/sideBar/SideBar.jsx
600
- import Cookies from "js-cookie";
601
-
602
- // src/inputs/CustomSelect.jsx
603
- import React11, { useState as useState2, useRef as useRef3 } from "react";
604
- import { ChevronDown as ChevronDown2, Search as Search3 } from "lucide-react";
605
- var CustomSelect = ({
606
- label,
607
- value,
608
- onChange,
609
- options,
610
- placeholder = "Select...",
611
- isRequired = false,
612
- error,
613
- heading,
614
- disabled = false
615
- }) => {
616
- const [open, setOpen] = useState2(false);
617
- const [search, setSearch] = useState2("");
618
- const wrapperRef = useRef3(null);
619
- const handleBlur = (e) => {
620
- var _a;
621
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
622
- setOpen(false);
623
- }
624
- };
625
- const filteredOptions = options.filter(
626
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
627
- );
628
- const handleSelect = (val) => {
629
- onChange(val);
630
- setOpen(false);
631
- };
632
- const selectedOption = options.find((opt) => opt.value === value);
633
- return /* @__PURE__ */ React11.createElement(
634
- "div",
635
- {
636
- className: "flex flex-col w-full relative",
637
- ref: wrapperRef,
638
- tabIndex: disabled ? -1 : 0,
639
- onBlur: handleBlur
640
- },
641
- heading && /* @__PURE__ */ React11.createElement("h3", { className: "text-lg font-semibold mb-1" }, heading),
642
- label && /* @__PURE__ */ React11.createElement(
643
- "label",
644
- {
645
- className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`
646
- },
647
- label,
648
- " ",
649
- isRequired && /* @__PURE__ */ React11.createElement("span", { className: "text-red-500" }, "*")
650
- ),
651
- /* @__PURE__ */ React11.createElement(
652
- "div",
653
- {
654
- onClick: () => !disabled && setOpen((prev) => !prev),
655
- 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
656
- ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
657
- ${error ? "border-red-500" : "border-gray-300"}
658
- `
659
- },
660
- /* @__PURE__ */ React11.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}` }, selectedOption ? selectedOption.label : placeholder),
661
- /* @__PURE__ */ React11.createElement(
662
- ChevronDown2,
663
- {
664
- className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
665
- }
666
- )
667
- ),
668
- 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" }, /* @__PURE__ */ React11.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200" }, /* @__PURE__ */ React11.createElement(Search3, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React11.createElement(
669
- "input",
670
- {
671
- type: "text",
672
- value: search,
673
- onChange: (e) => setSearch(e.target.value),
674
- placeholder: "Search...",
675
- className: "flex-1 text-sm focus:outline-none"
676
- }
677
- )), /* @__PURE__ */ React11.createElement("ul", null, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ React11.createElement(
678
- "li",
679
- {
680
- key: opt.value,
681
- onClick: () => handleSelect(opt.value),
682
- 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" : ""}`
683
- },
684
- opt.label
685
- )) : /* @__PURE__ */ React11.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white" }, "No results found")))
686
- );
687
- };
688
-
689
- // src/sideBar/SideBar.jsx
690
- var AppSideBar = ({
691
- username,
692
- role,
693
- navItems,
694
- additionalItems,
695
- sideBarLogo
696
- }) => {
697
- var _a, _b;
698
- const [authData, setAuthData] = useState3(null);
699
- const [selectedCountry, setSelectedCountry] = useState3("dubai");
700
- const [isMobileMenuOpen, setIsMobileMenuOpen] = useState3(false);
701
- const [openMenus, setOpenMenus] = useState3(/* @__PURE__ */ new Set());
702
- const [activeMenuPath, setActiveMenuPath] = useState3(null);
703
- const [currAppearance, setCurrAppearance] = useState3("light");
704
- useEffect(() => {
705
- setCurrAppearance("light");
706
- localStorage.setItem("themeMode", "light");
707
- }, []);
708
- const countryOptions = [
709
- { label: "India", value: "india" },
710
- { label: "Dubai", value: "dubai" },
711
- { label: "Singapore", value: "singapore" },
712
- { label: "Qatar", value: "qatar" }
713
- ];
714
- const toggleMenu = (menuKey) => {
715
- setOpenMenus((prev) => {
716
- const newSet = new Set(prev);
717
- if (newSet.has(menuKey)) {
718
- newSet.delete(menuKey);
719
- } else {
720
- newSet.add(menuKey);
721
- }
722
- return newSet;
723
- });
724
- };
725
- const isMenuOpen = (menuKey) => {
726
- return openMenus.has(menuKey);
727
- };
728
- const handleMenuClick = (item, index, e) => {
729
- if (item.isDropDown) {
730
- e.preventDefault();
731
- const menuKey = `menu-${index}`;
732
- toggleMenu(menuKey);
733
- setActiveMenuPath(`menu-${index}`);
734
- } else {
735
- setActiveMenuPath(`menu-${index}`);
736
- if (item.onClick) {
737
- item.onClick(e);
738
- }
739
- closeMobileMenu();
740
- }
741
- };
742
- const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
743
- const parentMenuKey = `menu-${parentIndex}`;
744
- setOpenMenus((prev) => {
745
- const newSet = new Set(prev);
746
- newSet.add(parentMenuKey);
747
- return newSet;
748
- });
749
- if (option.isDropDown) {
750
- e.preventDefault();
751
- const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
752
- toggleMenu(menuKey);
753
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
754
- } else {
755
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
756
- if (option.onClick) {
757
- option.onClick();
758
- }
759
- closeMobileMenu();
760
- }
761
- };
762
- const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
763
- const parentMenuKey = `menu-${parentIndex}`;
764
- const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
765
- setOpenMenus((prev) => {
766
- const newSet = new Set(prev);
767
- newSet.add(parentMenuKey);
768
- newSet.add(subMenuKey);
769
- return newSet;
770
- });
771
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
772
- if (subOption.onClick) {
773
- subOption.onClick();
774
- }
775
- closeMobileMenu();
776
- };
777
- useEffect(() => {
778
- const storedAuthData = localStorage.getItem("authData");
779
- if (storedAuthData) {
780
- let parseData = JSON.parse(storedAuthData);
781
- setAuthData(parseData);
782
- }
783
- }, [localStorage.getItem("authData")]);
784
- const extractUrlFromOnClick = (onClick) => {
785
- if (!onClick || typeof onClick !== "function") return null;
786
- const funcString = onClick.toString();
787
- let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
788
- if (!match) {
789
- match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
790
- }
791
- if (match && match[1]) {
792
- try {
793
- if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
794
- const url = new URL(match[1]);
795
- return {
796
- pathname: url.pathname,
797
- search: url.search,
798
- fullPath: url.pathname + url.search
799
- };
800
- }
801
- if (match[1].startsWith("/")) {
802
- const url = new URL(match[1], window.location.origin);
803
- return {
804
- pathname: url.pathname,
805
- search: url.search,
806
- fullPath: url.pathname + url.search
807
- };
808
- }
809
- return null;
810
- } catch {
811
- const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
812
- if (pathMatch) {
813
- return {
814
- pathname: pathMatch[1],
815
- search: pathMatch[2] || "",
816
- fullPath: match[1]
817
- };
818
- }
819
- return null;
820
- }
821
- }
822
- return null;
823
- };
824
- const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
825
- if (!menuUrlData || !currentPath) return false;
826
- const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
827
- const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
828
- if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
829
- const menuParams = new URLSearchParams(menuUrlData.search);
830
- const currentParams = new URLSearchParams(currentSearch);
831
- const menuRole = menuParams.get("role");
832
- const currentRole = currentParams.get("role");
833
- if (menuRole && currentRole) {
834
- return menuRole === currentRole;
835
- }
836
- if (menuRole && !currentRole || !menuRole && currentRole) {
837
- return false;
838
- }
839
- return true;
840
- }
841
- if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
842
- return true;
843
- }
844
- if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
845
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
846
- if (currentPathParam === "supplier-list") {
847
- return true;
848
- }
849
- }
850
- if (normalizedMenuPath === "/trips") {
851
- if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
852
- return true;
853
- }
854
- }
855
- if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
856
- const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
857
- if (menuPathParam) {
858
- const pathRouteMap = {
859
- "offer": "/offer/offer",
860
- "voucher": "/voucher/voucher",
861
- "tag": "/tags/tags",
862
- "special-requests": "/corporate/special-requests",
863
- "pricing-policy": "/policies/pricing-policy",
864
- "users": "/users/users"
865
- // Consumer Ecosystem Users (no role param)
866
- };
867
- const expectedRoute = pathRouteMap[menuPathParam];
868
- if (expectedRoute) {
869
- if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
870
- if (menuPathParam === "users") {
871
- const currentParams = new URLSearchParams(currentSearch);
872
- const currentRole = currentParams.get("role");
873
- return currentRole !== "admin";
874
- }
875
- return true;
876
- }
877
- }
878
- }
879
- if (normalizedCurrentPath === "/orgselector") {
880
- const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
881
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
882
- if (menuPathParam2 && currentPathParam) {
883
- return menuPathParam2 === currentPathParam;
884
- }
885
- }
886
- }
887
- if (normalizedMenuPath === normalizedCurrentPath) {
888
- if (menuUrlData.search) {
889
- const menuParams = new URLSearchParams(menuUrlData.search);
890
- const currentParams = new URLSearchParams(currentSearch);
891
- for (const [key, value] of menuParams.entries()) {
892
- if (key === "auth") {
893
- continue;
894
- }
895
- if (currentParams.get(key) !== value) {
896
- return false;
897
- }
898
- }
899
- return true;
900
- }
901
- return true;
902
- }
903
- if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
904
- return true;
905
- }
906
- return false;
907
- };
908
- const navItemsLocal = navItems ?? navItemsConstant;
909
- const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
910
- const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
911
- const detectAndSetActiveMenu = useCallback(() => {
912
- const currentPath = window.location.pathname;
913
- const currentSearch = window.location.search;
914
- const newOpenMenus = /* @__PURE__ */ new Set();
915
- let foundActivePath = null;
916
- navItemsLocal.forEach((item, index) => {
917
- if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
918
- const itemUrlData = extractUrlFromOnClick(item.onClick);
919
- if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
920
- foundActivePath = `menu-${index}`;
921
- }
922
- }
923
- if (item.options && item.options.length > 0) {
924
- item.options.forEach((option, optionsIndex) => {
925
- if (option.onClick && typeof option.onClick === "function") {
926
- const optionUrlData = extractUrlFromOnClick(option.onClick);
927
- if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
928
- const menuKey = `menu-${index}`;
929
- newOpenMenus.add(menuKey);
930
- foundActivePath = `menu-${index}-option-${optionsIndex}`;
931
- if (option.options && option.options.length > 0) {
932
- option.options.forEach((subOption, subIndex) => {
933
- const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
934
- if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
935
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
936
- newOpenMenus.add(subMenuKey);
937
- foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
938
- }
939
- });
940
- }
941
- }
942
- }
943
- });
944
- }
945
- });
946
- if (foundActivePath) {
947
- setOpenMenus(newOpenMenus);
948
- setActiveMenuPath(foundActivePath);
949
- }
950
- }, [navItemsLocal]);
951
- const [currentUrl, setCurrentUrl] = useState3(
952
- () => window.location.pathname + window.location.search
953
- );
954
- useEffect(() => {
955
- detectAndSetActiveMenu();
956
- setCurrentUrl(window.location.pathname + window.location.search);
957
- }, [detectAndSetActiveMenu]);
958
- useEffect(() => {
959
- let lastUrl = window.location.pathname + window.location.search;
960
- const handleLocationChange = () => {
961
- const newUrl = window.location.pathname + window.location.search;
962
- if (newUrl !== lastUrl) {
963
- lastUrl = newUrl;
964
- setCurrentUrl(newUrl);
965
- detectAndSetActiveMenu();
966
- }
967
- };
968
- window.addEventListener("popstate", handleLocationChange);
969
- const checkInterval = setInterval(() => {
970
- const newUrl = window.location.pathname + window.location.search;
971
- if (newUrl !== lastUrl) {
972
- handleLocationChange();
973
- }
974
- }, 250);
975
- return () => {
976
- window.removeEventListener("popstate", handleLocationChange);
977
- clearInterval(checkInterval);
978
- };
979
- }, [detectAndSetActiveMenu]);
980
- useEffect(() => {
981
- detectAndSetActiveMenu();
982
- }, [currentUrl, detectAndSetActiveMenu]);
983
- const toggleMobileMenu = () => {
984
- setIsMobileMenuOpen(!isMobileMenuOpen);
985
- };
986
- const closeMobileMenu = () => {
987
- setIsMobileMenuOpen(false);
988
- };
989
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.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" }, /* @__PURE__ */ React12.createElement(
990
- "button",
991
- {
992
- onClick: toggleMobileMenu,
993
- className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
994
- "aria-label": "Toggle menu"
995
- },
996
- isMobileMenuOpen ? /* @__PURE__ */ React12.createElement(X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ React12.createElement(Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
997
- ), /* @__PURE__ */ React12.createElement("div", { className: "flex-1 flex justify-center" }, sideBarLogo && /* @__PURE__ */ React12.createElement(
998
- "img",
999
- {
1000
- src: sideBarLogo,
1001
- alt: "sidebarLogo",
1002
- width: 108,
1003
- height: 40,
1004
- className: "object-contain"
1005
- }
1006
- )), /* @__PURE__ */ React12.createElement("div", { className: "w-10" })), isMobileMenuOpen && /* @__PURE__ */ React12.createElement(
1007
- "div",
1008
- {
1009
- className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1010
- onClick: closeMobileMenu
1011
- }
1012
- ), /* @__PURE__ */ React12.createElement(
1013
- "div",
1014
- {
1015
- 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"}`
1016
- },
1017
- /* @__PURE__ */ React12.createElement("div", { className: "p-2 mb-2 hidden md:block" }, /* @__PURE__ */ React12.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2" }, sideBarLogo && /* @__PURE__ */ React12.createElement(
1018
- "img",
1019
- {
1020
- src: sideBarLogo,
1021
- alt: "sidebarLogo",
1022
- width: 108,
1023
- height: 40,
1024
- className: "object-contain"
1025
- }
1026
- ))),
1027
- /* @__PURE__ */ React12.createElement("div", { className: "mb-4" }),
1028
- /* @__PURE__ */ React12.createElement("div", { className: "overflow-y-auto scrollbar-hide" }, /* @__PURE__ */ React12.createElement("div", null, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1029
- const menuKey = `menu-${index}`;
1030
- const isOpen = isMenuOpen(menuKey);
1031
- const isActive = activeMenuPath === menuKey;
1032
- return /* @__PURE__ */ React12.createElement("div", { key: index, className: "" }, /* @__PURE__ */ React12.createElement(
1033
- "div",
1034
- {
1035
- 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]" : ""}`,
1036
- onClick: (e) => handleMenuClick(item, index, e)
1037
- },
1038
- /* @__PURE__ */ React12.createElement("div", { className: "text-primary" }, /* @__PURE__ */ React12.createElement(item.Icon, { width: 20, height: 20 })),
1039
- /* @__PURE__ */ React12.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]" }, item.label),
1040
- item.isDropDown && /* @__PURE__ */ React12.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}` }, /* @__PURE__ */ React12.createElement(ChevronDown3, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1041
- ), item.options && item.options.length > 0 && /* @__PURE__ */ React12.createElement(
1042
- "div",
1043
- {
1044
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`
1045
- },
1046
- item.options.map((options, optionsIndex) => {
1047
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1048
- const isSubMenuOpen = isMenuOpen(subMenuKey);
1049
- const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1050
- return /* @__PURE__ */ React12.createElement("div", { key: optionsIndex, className: "" }, /* @__PURE__ */ React12.createElement(
1051
- "div",
1052
- {
1053
- className: `flex items-center gap-3 py-2 px-3 ml-4 mr-2 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer rounded-md transition-colors duration-200 ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1054
- onClick: (e) => handleSubMenuClick(options, optionsIndex, index, e)
1055
- },
1056
- /* @__PURE__ */ React12.createElement("div", null),
1057
- /* @__PURE__ */ React12.createElement("span", { className: "!font-medium !text-[15px] !text-[#3f3f46cc] dark:text-[#a1a1aa]" }, options.label),
1058
- options.isDropDown && /* @__PURE__ */ React12.createElement(
1059
- "div",
1060
- {
1061
- className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`
1062
- },
1063
- /* @__PURE__ */ React12.createElement(ChevronDown3, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1064
- )
1065
- ), options.options && options.options.length > 0 && /* @__PURE__ */ React12.createElement(
1066
- "div",
1067
- {
1068
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`
1069
- },
1070
- options.options.map((subOption, subIndex) => {
1071
- const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1072
- return /* @__PURE__ */ React12.createElement(
1073
- "div",
1074
- {
1075
- key: subIndex,
1076
- 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]" : ""}`,
1077
- onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e)
1078
- },
1079
- subOption.label
1080
- );
1081
- })
1082
- ));
1083
- })
1084
- ));
1085
- }))),
1086
- /* @__PURE__ */ React12.createElement("div", { className: "mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2" }, /* @__PURE__ */ React12.createElement(
1087
- "div",
1088
- {
1089
- className: "flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1090
- onClick: () => {
1091
- window.location.href = "/profile";
1092
- }
1093
- },
1094
- /* @__PURE__ */ React12.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React12.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10" }, /* @__PURE__ */ React12.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" }, ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.UserName) ? authData.userInfo.UserName.split("")[0] : "A")), /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]" }, ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.UserName) ? authData.userInfo.UserName : "Admin"), /* @__PURE__ */ React12.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]" }, role)))
1095
- ))
1096
- ));
1097
- };
1098
-
1099
- // src/RightSheet/RightSheet.jsx
1100
- import React13, { useEffect as useEffect2, useState as useState4 } from "react";
1101
- var RightSheet = ({
1102
- open,
1103
- setOpen,
1104
- children,
1105
- callBack,
1106
- actionLabel = "Save",
1107
- onAction = () => {
1108
- }
1109
- }) => {
1110
- const [visible, setVisible] = useState4(open);
1111
- useEffect2(() => {
1112
- if (open) {
1113
- document.body.style.overflow = "hidden";
1114
- setVisible(true);
1115
- }
1116
- return () => {
1117
- document.body.style.overflow = "auto";
1118
- };
1119
- }, [open]);
1120
- const handleClose = () => {
1121
- setVisible(false);
1122
- setTimeout(() => {
1123
- setOpen(false);
1124
- callBack();
1125
- }, 200);
1126
- };
1127
- const handleAction = () => {
1128
- onAction();
1129
- handleClose();
1130
- };
1131
- if (!visible) return null;
1132
- return /* @__PURE__ */ React13.createElement(
1133
- "div",
1134
- {
1135
- className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1136
- onClick: handleClose
1137
- },
1138
- /* @__PURE__ */ React13.createElement(
1139
- "div",
1140
- {
1141
- className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1142
- ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1143
- onClick: (e) => e.stopPropagation()
1144
- },
1145
- /* @__PURE__ */ React13.createElement("div", { className: " min-h-full " }, children),
1146
- /* @__PURE__ */ React13.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" }, /* @__PURE__ */ React13.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose() }, "Cancel"), /* @__PURE__ */ React13.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction }, actionLabel))
1147
- )
1148
- );
1149
- };
1150
-
1151
- // src/Table/CustomTable.jsx
1152
- import React14 from "react";
1153
- var CustomTable = ({
1154
- tableHeader,
1155
- setIsAllChecked,
1156
- isAllChecked,
1157
- children,
1158
- isHideCheckbox = "false"
1159
- }) => {
1160
- return /* @__PURE__ */ React14.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto" }, /* @__PURE__ */ React14.createElement("div", { className: "w-full relative overflow-x-auto" }, /* @__PURE__ */ React14.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse" }, /* @__PURE__ */ React14.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]" }, /* @__PURE__ */ React14.createElement(
1161
- "tr",
1162
- {
1163
- className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted"
1164
- },
1165
- !isHideCheckbox && /* @__PURE__ */ React14.createElement("th", { className: "px-4 py-3 text-left w-[50px]" }, /* @__PURE__ */ React14.createElement(
1166
- CustomCheckbox,
1167
- {
1168
- checked: isAllChecked,
1169
- onChange: () => {
1170
- setIsAllChecked(!isAllChecked);
1171
- }
1172
- }
1173
- )),
1174
- tableHeader.map((header, index) => {
1175
- return /* @__PURE__ */ React14.createElement(
1176
- "th",
1177
- {
1178
- className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1179
- key: header + index
1180
- },
1181
- header
1182
- );
1183
- })
1184
- )), /* @__PURE__ */ React14.createElement("tbody", null, children))));
1185
- };
1186
-
1187
- // src/Pagination/Pagination.jsx
1188
- import React15, { useMemo, useState as useState5, useEffect as useEffect3 } from "react";
1189
- import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
1190
- var Pagination = ({
1191
- data = [],
1192
- component: Component,
1193
- itemsPerPage = 6,
1194
- itemsPerPageOptions = [5, 10, 20, 50, 100],
1195
- // Controlled props (optional)
1196
- currentPage: controlledCurrentPage,
1197
- onPageChange: controlledOnPageChange,
1198
- onItemsPerPageChange: controlledOnItemsPerPageChange,
1199
- // Legacy props for backward compatibility
1200
- totalPages,
1201
- totalItems: legacyTotalItems,
1202
- onPageChange: legacyOnPageChange,
1203
- onItemsPerPageChange: legacyOnItemsPerPageChange,
1204
- tableHeader,
1205
- isHideCheckbox,
1206
- callback,
1207
- isTable = false,
1208
- // Component props - any additional props to pass to the component
1209
- componentProps = {},
1210
- ...restProps
1211
- }) => {
1212
- const [internalCurrentPage, setInternalCurrentPage] = useState5(1);
1213
- const [internalItemsPerPage, setInternalItemsPerPage] = useState5(itemsPerPage);
1214
- const isControlled = controlledCurrentPage !== void 0;
1215
- const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1216
- const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1217
- const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1218
- const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1219
- const calculatedTotalPages = useMemo(() => {
1220
- if (totalItems > 0 && activeItemsPerPage > 0) {
1221
- return Math.ceil(totalItems / activeItemsPerPage);
1222
- }
1223
- return 1;
1224
- }, [totalItems, activeItemsPerPage]);
1225
- const paginatedData = useMemo(() => {
1226
- if (!data || data.length === 0) return [];
1227
- const startIndex = (currentPage - 1) * activeItemsPerPage;
1228
- const endIndex = startIndex + activeItemsPerPage;
1229
- return data.slice(startIndex, endIndex);
1230
- }, [data, currentPage, activeItemsPerPage]);
1231
- useEffect3(() => {
1232
- if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1233
- setInternalCurrentPage(1);
1234
- }
1235
- }, [calculatedTotalPages, isControlled, currentPage]);
1236
- const getPageNumbers = () => {
1237
- const pages = [];
1238
- const maxVisible = 5;
1239
- let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1240
- let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1241
- if (endPage - startPage < maxVisible - 1) {
1242
- startPage = Math.max(1, endPage - maxVisible + 1);
1243
- }
1244
- for (let i = startPage; i <= endPage; i++) {
1245
- pages.push(i);
1246
- }
1247
- return pages;
1248
- };
1249
- const handlePageChange = (page) => {
1250
- if (page >= 1 && page <= calculatedTotalPages) {
1251
- if (isControlled && controlledOnPageChange) {
1252
- controlledOnPageChange(page);
1253
- } else if (legacyOnPageChange) {
1254
- legacyOnPageChange(page);
1255
- } else {
1256
- setInternalCurrentPage(page);
1257
- }
1258
- }
1259
- };
1260
- const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1261
- const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1262
- const renderContent = () => {
1263
- if (Component) {
1264
- if (React15.isValidElement(Component)) {
1265
- const ComponentType = Component.type;
1266
- const elementProps = Component.props;
1267
- if (isTable) {
1268
- return /* @__PURE__ */ React15.createElement(
1269
- CustomTable,
1270
- {
1271
- tableHeader,
1272
- isHideCheckbox
1273
- },
1274
- data.map((item, index) => {
1275
- return /* @__PURE__ */ React15.createElement(
1276
- ComponentType,
1277
- {
1278
- key: item.id || item._id || index,
1279
- data: item,
1280
- ...elementProps,
1281
- ...componentProps,
1282
- ...restProps
1283
- }
1284
- );
1285
- })
1286
- );
1287
- } else {
1288
- if (isTable) {
1289
- return /* @__PURE__ */ React15.createElement(
1290
- CustomTable,
1291
- {
1292
- tableHeader,
1293
- isHideCheckbox
1294
- },
1295
- paginatedData.map((item, index) => {
1296
- return /* @__PURE__ */ React15.createElement(
1297
- ComponentType,
1298
- {
1299
- key: item.id || item._id || index,
1300
- data: item,
1301
- ...elementProps,
1302
- ...componentProps,
1303
- ...restProps
1304
- }
1305
- );
1306
- })
1307
- );
1308
- }
1309
- }
1310
- } else {
1311
- return /* @__PURE__ */ React15.createElement(
1312
- CustomTable,
1313
- {
1314
- tableHeader,
1315
- isHideCheckbox
1316
- },
1317
- paginatedData.map((item, index) => {
1318
- return /* @__PURE__ */ React15.createElement(
1319
- Component,
1320
- {
1321
- key: item.id || item._id || index,
1322
- data: item,
1323
- ...componentProps,
1324
- ...restProps
1325
- }
1326
- );
1327
- })
1328
- );
1329
- }
1330
- }
1331
- return null;
1332
- };
1333
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(React15.Fragment, null, renderContent()), /* @__PURE__ */ React15.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" }, totalItems !== void 0 && /* @__PURE__ */ React15.createElement("div", { className: "text-sm text-[#737373] dark:text-white" }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ React15.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React15.createElement(
1334
- "button",
1335
- {
1336
- onClick: () => handlePageChange(1),
1337
- disabled: currentPage === 1,
1338
- 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]"}`,
1339
- title: "First page"
1340
- },
1341
- /* @__PURE__ */ React15.createElement(ChevronsLeft, { size: 16 })
1342
- ), /* @__PURE__ */ React15.createElement(
1343
- "button",
1344
- {
1345
- onClick: () => handlePageChange(currentPage - 1),
1346
- disabled: currentPage === 1,
1347
- 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]"}`,
1348
- title: "Previous page"
1349
- },
1350
- /* @__PURE__ */ React15.createElement(ChevronLeft, { size: 16 })
1351
- ), getPageNumbers().map((pageNum) => /* @__PURE__ */ React15.createElement(
1352
- "button",
1353
- {
1354
- key: pageNum,
1355
- onClick: () => handlePageChange(pageNum),
1356
- 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]"}`
1357
- },
1358
- pageNum
1359
- )), /* @__PURE__ */ React15.createElement(
1360
- "button",
1361
- {
1362
- onClick: () => handlePageChange(currentPage + 1),
1363
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1364
- 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]"}`,
1365
- title: "Next page"
1366
- },
1367
- /* @__PURE__ */ React15.createElement(ChevronRight, { size: 16 })
1368
- ), /* @__PURE__ */ React15.createElement(
1369
- "button",
1370
- {
1371
- onClick: () => handlePageChange(calculatedTotalPages),
1372
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1373
- 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]"}`,
1374
- title: "Last page"
1375
- },
1376
- /* @__PURE__ */ React15.createElement(ChevronsRight, { size: 16 })
1377
- ))));
1378
- };
1379
- export {
1380
- AppSideBar,
1381
- Chip,
1382
- CustomAutocomplete,
1383
- CustomButton,
1384
- CustomCheckbox,
1385
- CustomInput,
1386
- CustomSearch,
1387
- CustomSelect,
1388
- CustomSwitch,
1389
- CustomTable,
1390
- CustomTextarea,
1391
- CustomUpload,
1392
- Pagination,
1393
- ProgressBar,
1394
- RightSheet
1395
- };
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
+ variant = "DEFAULT",
18
+ children,
19
+ className,
20
+ onClick,
21
+ disabled = false,
22
+ icon
23
+ }) => {
24
+ return /* @__PURE__ */ React.createElement(
25
+ "div",
26
+ {
27
+ className: cn(
28
+ `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`,
29
+ variantStyles[variant],
30
+ className
31
+ ),
32
+ onClick
33
+ },
34
+ icon && /* @__PURE__ */ React.createElement("div", null, icon),
35
+ children
36
+ );
37
+ };
38
+
39
+ // src/inputs/Autocomplete.jsx
40
+ import React2, { useState, useRef } from "react";
41
+ import { ChevronDown, Check, Search } from "lucide-react";
42
+ var CustomAutocomplete = ({
43
+ label,
44
+ value,
45
+ onChange,
46
+ options,
47
+ placeholder = "Search & select...",
48
+ isRequired = false,
49
+ error,
50
+ heading,
51
+ disabled = false
52
+ }) => {
53
+ const [open, setOpen] = useState(false);
54
+ const [search, setSearch] = useState("");
55
+ const wrapperRef = useRef(null);
56
+ const selectedOptions = options.filter((opt) => value.includes(opt.value));
57
+ const handleBlur = (e) => {
58
+ var _a;
59
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
60
+ setOpen(false);
61
+ }
62
+ };
63
+ const filteredOptions = options.filter(
64
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
65
+ );
66
+ const toggleValue = (val) => {
67
+ if (value.includes(val)) {
68
+ onChange(value.filter((v) => v !== val));
69
+ } else {
70
+ onChange([...value, val]);
71
+ }
72
+ };
73
+ return /* @__PURE__ */ React2.createElement(
74
+ "div",
75
+ {
76
+ className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
77
+ ref: wrapperRef,
78
+ tabIndex: disabled ? -1 : 0,
79
+ onBlur: handleBlur
80
+ },
81
+ heading && /* @__PURE__ */ React2.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1" }, heading),
82
+ label && /* @__PURE__ */ React2.createElement(
83
+ "label",
84
+ {
85
+ className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`
86
+ },
87
+ label,
88
+ " ",
89
+ isRequired && /* @__PURE__ */ React2.createElement("span", { className: "text-red-500" }, "*")
90
+ ),
91
+ /* @__PURE__ */ React2.createElement(
92
+ "div",
93
+ {
94
+ onClick: () => {
95
+ if (!disabled) setOpen((prev) => !prev);
96
+ },
97
+ 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
98
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
99
+ ${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"}
100
+ `
101
+ },
102
+ /* @__PURE__ */ React2.createElement("div", { className: "flex flex-wrap gap-1 flex-1" }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ React2.createElement(
103
+ "span",
104
+ {
105
+ key: opt.value,
106
+ 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"
107
+ },
108
+ opt.label,
109
+ /* @__PURE__ */ React2.createElement(
110
+ "button",
111
+ {
112
+ onClick: (e) => {
113
+ e.stopPropagation();
114
+ toggleValue(opt.value);
115
+ },
116
+ className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white"
117
+ },
118
+ "\u2715"
119
+ )
120
+ )) : /* @__PURE__ */ React2.createElement("span", { className: "text-gray-400" }, placeholder)),
121
+ /* @__PURE__ */ React2.createElement(
122
+ ChevronDown,
123
+ {
124
+ className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
125
+ }
126
+ )
127
+ ),
128
+ !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" }, /* @__PURE__ */ React2.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200" }, /* @__PURE__ */ React2.createElement(Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React2.createElement(
129
+ "input",
130
+ {
131
+ type: "text",
132
+ value: search,
133
+ onChange: (e) => setSearch(e.target.value),
134
+ placeholder: "Search...",
135
+ className: "flex-1 text-sm focus:outline-none"
136
+ }
137
+ )), /* @__PURE__ */ React2.createElement("ul", null, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
138
+ const selected = value.includes(opt.value);
139
+ return /* @__PURE__ */ React2.createElement(
140
+ "li",
141
+ {
142
+ key: opt.value,
143
+ onClick: () => toggleValue(opt.value),
144
+ 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" : ""}`
145
+ },
146
+ /* @__PURE__ */ React2.createElement(
147
+ "span",
148
+ {
149
+ 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"}`
150
+ },
151
+ selected && /* @__PURE__ */ React2.createElement(Check, { size: 14 })
152
+ ),
153
+ opt.label
154
+ );
155
+ }) : /* @__PURE__ */ React2.createElement("li", { className: "px-3 py-2 text-sm text-gray-400" }, "No results found")))
156
+ );
157
+ };
158
+
159
+ // src/inputs/Checkbox.jsx
160
+ import React3 from "react";
161
+ var CustomCheckbox = ({ onChange, checked }) => {
162
+ const handleChange = (e) => {
163
+ onChange(e.target.checked);
164
+ };
165
+ return /* @__PURE__ */ React3.createElement("label", { className: "inline-flex items-center cursor-pointer select-none" }, /* @__PURE__ */ React3.createElement(
166
+ "input",
167
+ {
168
+ type: "checkbox",
169
+ checked,
170
+ onChange: handleChange,
171
+ className: "peer hidden"
172
+ }
173
+ ), /* @__PURE__ */ React3.createElement(
174
+ "span",
175
+ {
176
+ 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 "
177
+ },
178
+ checked && /* @__PURE__ */ React3.createElement(
179
+ "svg",
180
+ {
181
+ className: "w-4 h-4 text-white",
182
+ fill: "none",
183
+ stroke: "currentColor",
184
+ strokeWidth: "3",
185
+ viewBox: "0 0 24 24"
186
+ },
187
+ /* @__PURE__ */ React3.createElement("path", { d: "M5 13l4 4L19 7" })
188
+ )
189
+ ));
190
+ };
191
+
192
+ // src/inputs/Chip.jsx
193
+ import React4 from "react";
194
+ var VARIANTS = {
195
+ PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
196
+ GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
197
+ RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
198
+ YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
199
+ };
200
+ var Chip = ({ label, variant }) => {
201
+ return /* @__PURE__ */ React4.createElement(
202
+ "div",
203
+ {
204
+ className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`
205
+ },
206
+ label
207
+ );
208
+ };
209
+
210
+ // src/inputs/CustomSwitch.jsx
211
+ import React5 from "react";
212
+ var CustomSwitch = ({ checked, onChange, label, description }) => {
213
+ return /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement(
214
+ "button",
215
+ {
216
+ type: "button",
217
+ role: "switch",
218
+ "aria-checked": checked,
219
+ onClick: () => onChange(!checked),
220
+ className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`
221
+ },
222
+ /* @__PURE__ */ React5.createElement(
223
+ "span",
224
+ {
225
+ className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`
226
+ }
227
+ )
228
+ ), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-col" }, label && /* @__PURE__ */ React5.createElement("h3", { className: "font-[500] text-sm text-black mb-2" }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "font-[500] text-sm text-[#737373]" }, description)));
229
+ };
230
+
231
+ // src/inputs/Input.jsx
232
+ import React6 from "react";
233
+ var CustomInput = ({
234
+ label,
235
+ isRequired,
236
+ value,
237
+ onChange,
238
+ placeholder,
239
+ disabled = false,
240
+ error,
241
+ heading
242
+ }) => {
243
+ return /* @__PURE__ */ React6.createElement("div", { className: "flex flex-col gap-1 w-full" }, heading && /* @__PURE__ */ React6.createElement("h3", { className: "text-lg font-semibold" }, heading), /* @__PURE__ */ React6.createElement(
244
+ "label",
245
+ {
246
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`
247
+ },
248
+ label,
249
+ " ",
250
+ isRequired && /* @__PURE__ */ React6.createElement("span", { className: "text-red-500" }, "*")
251
+ ), /* @__PURE__ */ React6.createElement(
252
+ "input",
253
+ {
254
+ className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
255
+ focus:outline-2 outline-black dark:outline-white outline-offset-2
256
+ dark:bg-transparent dark:text-white dark:border-[#303036]
257
+ ${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%)]"}
258
+ `,
259
+ value,
260
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
261
+ placeholder,
262
+ disabled,
263
+ readOnly: disabled
264
+ }
265
+ ));
266
+ };
267
+
268
+ // src/inputs/ProgressBar.jsx
269
+ import React7 from "react";
270
+ var ProgressBar = ({ step, totalSteps }) => {
271
+ const progress = step / totalSteps * 100;
272
+ return /* @__PURE__ */ React7.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React7.createElement("p", { className: "text-gray-600 text-sm mb-2" }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ React7.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2" }, /* @__PURE__ */ React7.createElement(
273
+ "div",
274
+ {
275
+ className: "bg-black h-2 rounded-full transition-all duration-300",
276
+ style: { width: `${progress}%` }
277
+ }
278
+ )));
279
+ };
280
+
281
+ // src/inputs/Search.jsx
282
+ import React8 from "react";
283
+ import { Search as Search2 } from "lucide-react";
284
+ var CustomSearch = ({
285
+ value,
286
+ onChange,
287
+ placeholder = "Search Markets..."
288
+ }) => {
289
+ 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" }, /* @__PURE__ */ React8.createElement(Search2, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ React8.createElement(
290
+ "input",
291
+ {
292
+ type: "text",
293
+ value,
294
+ onChange,
295
+ placeholder,
296
+ className: "bg-transparent w-full h-full focus:outline-none"
297
+ }
298
+ ));
299
+ };
300
+
301
+ // src/inputs/TextArea.jsx
302
+ import React9 from "react";
303
+ var CustomTextarea = ({
304
+ label,
305
+ isRequired,
306
+ value,
307
+ onChange,
308
+ placeholder,
309
+ disabled = false,
310
+ error,
311
+ heading,
312
+ rows = 4
313
+ }) => {
314
+ return /* @__PURE__ */ React9.createElement("div", { className: "flex flex-col gap-1 w-full" }, heading && /* @__PURE__ */ React9.createElement("h3", { className: "text-lg font-semibold" }, heading), /* @__PURE__ */ React9.createElement(
315
+ "label",
316
+ {
317
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`
318
+ },
319
+ label,
320
+ " ",
321
+ isRequired && /* @__PURE__ */ React9.createElement("span", { className: "text-red-500" }, "*")
322
+ ), /* @__PURE__ */ React9.createElement(
323
+ "textarea",
324
+ {
325
+ rows,
326
+ className: `border rounded-md px-4 py-2 w-full text-[14px]
327
+ focus:outline-2 focus:outline-black focus:outline-offset-2
328
+ focus:ring-0 focus:shadow-none focus:border-black
329
+ ${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%)]"}
330
+ `,
331
+ value,
332
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
333
+ placeholder,
334
+ disabled,
335
+ readOnly: disabled
336
+ }
337
+ ));
338
+ };
339
+
340
+ // src/inputs/Upload.jsx
341
+ import React10, { useRef as useRef2 } from "react";
342
+ import { Upload } from "lucide-react";
343
+ var CustomUpload = ({
344
+ label = "Supporting documents",
345
+ description = "Drop items here or Browse Files",
346
+ accept = ".pdf,.jpg,.jpeg,.png",
347
+ maxSizeMB = 5,
348
+ onChange,
349
+ error,
350
+ value
351
+ }) => {
352
+ const inputRef = useRef2(null);
353
+ const handleFileSelect = (files) => {
354
+ if (!files || files.length === 0) return;
355
+ const selectedFile = files[0];
356
+ if (selectedFile.size > maxSizeMB * 1024 * 1024) {
357
+ alert(`File size must be less than ${maxSizeMB} MB`);
358
+ return;
359
+ }
360
+ onChange == null ? void 0 : onChange(selectedFile);
361
+ };
362
+ return /* @__PURE__ */ React10.createElement("div", { className: "flex flex-col gap-2 w-full" }, label && /* @__PURE__ */ React10.createElement("label", { className: "text-sm font-medium" }, label), /* @__PURE__ */ React10.createElement(
363
+ "div",
364
+ {
365
+ className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
366
+ ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
367
+ onClick: () => {
368
+ var _a;
369
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
370
+ },
371
+ onDragOver: (e) => e.preventDefault(),
372
+ onDrop: (e) => {
373
+ e.preventDefault();
374
+ handleFileSelect(e.dataTransfer.files);
375
+ }
376
+ },
377
+ /* @__PURE__ */ React10.createElement(Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
378
+ /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-gray-700" }, description),
379
+ /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-gray-500 mt-1" }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
380
+ /* @__PURE__ */ React10.createElement(
381
+ "input",
382
+ {
383
+ ref: inputRef,
384
+ type: "file",
385
+ accept,
386
+ className: "hidden",
387
+ onChange: (e) => handleFileSelect(e.target.files)
388
+ }
389
+ )
390
+ ), value && /* @__PURE__ */ React10.createElement("span", { className: "text-sm truncate text-gray-500" }, "Selected: ", value.name), error && /* @__PURE__ */ React10.createElement("p", { className: "text-xs text-red-500" }, error));
391
+ };
392
+
393
+ // src/sideBar/SideBar.jsx
394
+ import {
395
+ ChevronDown as ChevronDown3,
396
+ Globe,
397
+ LogOut,
398
+ Menu,
399
+ X
400
+ } from "lucide-react";
401
+ import React12, { useEffect, useState as useState3, useCallback } from "react";
402
+
403
+ // ConstantUI.js
404
+ import {
405
+ Home,
406
+ Banknote,
407
+ LifeBuoy,
408
+ Cog,
409
+ Building,
410
+ Handshake,
411
+ DollarSign,
412
+ BarChart3
413
+ } from "lucide-react";
414
+ var encodedAuthData = localStorage.getItem("encodedAuthData");
415
+ var navItemsConstant = [
416
+ {
417
+ Icon: Home,
418
+ label: "Home",
419
+ onClick: () => {
420
+ window.location.href = "/";
421
+ },
422
+ isDropDown: false
423
+ },
424
+ {
425
+ Icon: Building,
426
+ label: "Consumer Ecosystem",
427
+ onClick: () => {
428
+ },
429
+ options: [
430
+ {
431
+ label: "Corporate",
432
+ onClick: () => {
433
+ window.location.href = "/corporate/";
434
+ }
435
+ },
436
+ {
437
+ label: "Trips",
438
+ onClick: () => {
439
+ window.location.href = "/trips/";
440
+ }
441
+ },
442
+ {
443
+ label: "Users",
444
+ onClick: () => {
445
+ window.location.href = "/users/users";
446
+ }
447
+ },
448
+ {
449
+ label: "Tags (Custom Variables)",
450
+ onClick: () => {
451
+ window.location.href = "/orgselector/?path=tag";
452
+ }
453
+ },
454
+ {
455
+ label: "Special Request",
456
+ onClick: () => {
457
+ window.location.href = "/orgselector/?path=special-requests";
458
+ }
459
+ },
460
+ {
461
+ label: "Support Tickets (Coming Soon)",
462
+ isDisabled: true
463
+ // onClick: () => {},
464
+ }
465
+ ],
466
+ isDropDown: true
467
+ },
468
+ {
469
+ Icon: Banknote,
470
+ label: "Finance",
471
+ onClick: () => {
472
+ },
473
+ isDropDown: true,
474
+ options: [
475
+ {
476
+ label: "Credit Management",
477
+ onClick: () => {
478
+ window.location.href = "/finance/paymentsLedger/";
479
+ }
480
+ },
481
+ {
482
+ label: "Booking & Invoices",
483
+ onClick: () => {
484
+ window.location.href = "/finance/bookingHistory/";
485
+ }
486
+ }
487
+ ]
488
+ },
489
+ {
490
+ Icon: DollarSign,
491
+ label: "Revenue Management",
492
+ onClick: () => {
493
+ },
494
+ isDropDown: true,
495
+ options: [
496
+ {
497
+ label: "Pricing Engine",
498
+ onClick: () => {
499
+ window.location.href = "/orgselector/?path=pricing-policy";
500
+ }
501
+ },
502
+ {
503
+ label: "Offers",
504
+ onClick: () => {
505
+ window.location.href = "/orgselector/?path=offer";
506
+ }
507
+ },
508
+ {
509
+ label: "Vouchers",
510
+ onClick: () => {
511
+ window.location.href = "/orgselector/?path=voucher";
512
+ }
513
+ }
514
+ ]
515
+ },
516
+ {
517
+ Icon: Handshake,
518
+ label: "Supplier Ecosystem",
519
+ onClick: () => {
520
+ },
521
+ isDropDown: true,
522
+ options: [
523
+ {
524
+ label: "Suppliers List",
525
+ onClick: () => {
526
+ window.location.href = "/orgselector/?path=supplier-list";
527
+ }
528
+ },
529
+ {
530
+ label: "Supplier Deals",
531
+ onClick: () => {
532
+ window.location.href = "/supplierdeals/";
533
+ }
534
+ }
535
+ ]
536
+ },
537
+ {
538
+ Icon: BarChart3,
539
+ label: "Reports",
540
+ onClick: () => {
541
+ },
542
+ isDropDown: true,
543
+ options: [
544
+ {
545
+ label: "Reports (Coming Soon)",
546
+ isDisabled: true
547
+ // onClick: () => {
548
+ // window.open("https://viz.jett.travel", "_blank");
549
+ // },
550
+ }
551
+ ]
552
+ },
553
+ {
554
+ Icon: Cog,
555
+ label: "Settings",
556
+ onClick: () => {
557
+ },
558
+ isDropDown: true,
559
+ options: [
560
+ {
561
+ label: "Whitelabel",
562
+ onClick: () => {
563
+ window.location.href = "/whitelabel/";
564
+ }
565
+ },
566
+ {
567
+ label: "Markets",
568
+ onClick: () => {
569
+ window.location.href = "/market/";
570
+ }
571
+ },
572
+ {
573
+ label: "Users",
574
+ onClick: () => {
575
+ window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
576
+ }
577
+ },
578
+ {
579
+ label: "Reports Configurations (Coming Soon)",
580
+ isDisabled: true
581
+ // onClick: () => {},
582
+ }
583
+ ]
584
+ }
585
+ ];
586
+ var additionalItemsConstant = [
587
+ {
588
+ Icon: LifeBuoy,
589
+ label: "Help",
590
+ onClick: () => {
591
+ window.location.href = "/help";
592
+ }
593
+ }
594
+ ];
595
+
596
+ // src/assests/logo/logo-white.svg
597
+ var logo_white_default = "./logo-white-RYMEJOWI.svg";
598
+
599
+ // src/sideBar/SideBar.jsx
600
+ import Cookies from "js-cookie";
601
+
602
+ // src/inputs/CustomSelect.jsx
603
+ import React11, { useState as useState2, useRef as useRef3 } from "react";
604
+ import { ChevronDown as ChevronDown2, Search as Search3 } from "lucide-react";
605
+ var CustomSelect = ({
606
+ label,
607
+ value,
608
+ onChange,
609
+ options,
610
+ placeholder = "Select...",
611
+ isRequired = false,
612
+ error,
613
+ heading,
614
+ disabled = false
615
+ }) => {
616
+ const [open, setOpen] = useState2(false);
617
+ const [search, setSearch] = useState2("");
618
+ const wrapperRef = useRef3(null);
619
+ const handleBlur = (e) => {
620
+ var _a;
621
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
622
+ setOpen(false);
623
+ }
624
+ };
625
+ const filteredOptions = options.filter(
626
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
627
+ );
628
+ const handleSelect = (val) => {
629
+ onChange(val);
630
+ setOpen(false);
631
+ };
632
+ const selectedOption = options.find((opt) => opt.value === value);
633
+ return /* @__PURE__ */ React11.createElement(
634
+ "div",
635
+ {
636
+ className: "flex flex-col w-full relative",
637
+ ref: wrapperRef,
638
+ tabIndex: disabled ? -1 : 0,
639
+ onBlur: handleBlur
640
+ },
641
+ heading && /* @__PURE__ */ React11.createElement("h3", { className: "text-lg font-semibold mb-1" }, heading),
642
+ label && /* @__PURE__ */ React11.createElement(
643
+ "label",
644
+ {
645
+ className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`
646
+ },
647
+ label,
648
+ " ",
649
+ isRequired && /* @__PURE__ */ React11.createElement("span", { className: "text-red-500" }, "*")
650
+ ),
651
+ /* @__PURE__ */ React11.createElement(
652
+ "div",
653
+ {
654
+ onClick: () => !disabled && setOpen((prev) => !prev),
655
+ 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
656
+ ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
657
+ ${error ? "border-red-500" : "border-gray-300"}
658
+ `
659
+ },
660
+ /* @__PURE__ */ React11.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}` }, selectedOption ? selectedOption.label : placeholder),
661
+ /* @__PURE__ */ React11.createElement(
662
+ ChevronDown2,
663
+ {
664
+ className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
665
+ }
666
+ )
667
+ ),
668
+ 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" }, /* @__PURE__ */ React11.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200" }, /* @__PURE__ */ React11.createElement(Search3, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ React11.createElement(
669
+ "input",
670
+ {
671
+ type: "text",
672
+ value: search,
673
+ onChange: (e) => setSearch(e.target.value),
674
+ placeholder: "Search...",
675
+ className: "flex-1 text-sm focus:outline-none"
676
+ }
677
+ )), /* @__PURE__ */ React11.createElement("ul", null, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ React11.createElement(
678
+ "li",
679
+ {
680
+ key: opt.value,
681
+ onClick: () => handleSelect(opt.value),
682
+ 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" : ""}`
683
+ },
684
+ opt.label
685
+ )) : /* @__PURE__ */ React11.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white" }, "No results found")))
686
+ );
687
+ };
688
+
689
+ // src/sideBar/SideBar.jsx
690
+ var AppSideBar = ({
691
+ username,
692
+ role,
693
+ navItems,
694
+ additionalItems,
695
+ sideBarLogo
696
+ }) => {
697
+ var _a, _b;
698
+ const [authData, setAuthData] = useState3(null);
699
+ const [selectedCountry, setSelectedCountry] = useState3("dubai");
700
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState3(false);
701
+ const [openMenus, setOpenMenus] = useState3(/* @__PURE__ */ new Set());
702
+ const [activeMenuPath, setActiveMenuPath] = useState3(null);
703
+ const [currAppearance, setCurrAppearance] = useState3("light");
704
+ useEffect(() => {
705
+ setCurrAppearance("light");
706
+ localStorage.setItem("themeMode", "light");
707
+ }, []);
708
+ const countryOptions = [
709
+ { label: "India", value: "india" },
710
+ { label: "Dubai", value: "dubai" },
711
+ { label: "Singapore", value: "singapore" },
712
+ { label: "Qatar", value: "qatar" }
713
+ ];
714
+ const toggleMenu = (menuKey) => {
715
+ setOpenMenus((prev) => {
716
+ const newSet = new Set(prev);
717
+ if (newSet.has(menuKey)) {
718
+ newSet.delete(menuKey);
719
+ } else {
720
+ newSet.add(menuKey);
721
+ }
722
+ return newSet;
723
+ });
724
+ };
725
+ const isMenuOpen = (menuKey) => {
726
+ return openMenus.has(menuKey);
727
+ };
728
+ const handleMenuClick = (item, index, e) => {
729
+ if (item.isDropDown) {
730
+ e.preventDefault();
731
+ const menuKey = `menu-${index}`;
732
+ toggleMenu(menuKey);
733
+ setActiveMenuPath(`menu-${index}`);
734
+ } else {
735
+ setActiveMenuPath(`menu-${index}`);
736
+ if (item.onClick) {
737
+ item.onClick(e);
738
+ }
739
+ closeMobileMenu();
740
+ }
741
+ };
742
+ const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
743
+ const parentMenuKey = `menu-${parentIndex}`;
744
+ setOpenMenus((prev) => {
745
+ const newSet = new Set(prev);
746
+ newSet.add(parentMenuKey);
747
+ return newSet;
748
+ });
749
+ if (option.isDropDown) {
750
+ e.preventDefault();
751
+ const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
752
+ toggleMenu(menuKey);
753
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
754
+ } else {
755
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
756
+ if (option.onClick) {
757
+ option.onClick();
758
+ }
759
+ closeMobileMenu();
760
+ }
761
+ };
762
+ const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
763
+ const parentMenuKey = `menu-${parentIndex}`;
764
+ const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
765
+ setOpenMenus((prev) => {
766
+ const newSet = new Set(prev);
767
+ newSet.add(parentMenuKey);
768
+ newSet.add(subMenuKey);
769
+ return newSet;
770
+ });
771
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
772
+ if (subOption.onClick) {
773
+ subOption.onClick();
774
+ }
775
+ closeMobileMenu();
776
+ };
777
+ useEffect(() => {
778
+ const storedAuthData = localStorage.getItem("authData");
779
+ if (storedAuthData) {
780
+ let parseData = JSON.parse(storedAuthData);
781
+ setAuthData(parseData);
782
+ }
783
+ }, [localStorage.getItem("authData")]);
784
+ const extractUrlFromOnClick = (onClick) => {
785
+ if (!onClick || typeof onClick !== "function") return null;
786
+ const funcString = onClick.toString();
787
+ let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
788
+ if (!match) {
789
+ match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
790
+ }
791
+ if (match && match[1]) {
792
+ try {
793
+ if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
794
+ const url = new URL(match[1]);
795
+ return {
796
+ pathname: url.pathname,
797
+ search: url.search,
798
+ fullPath: url.pathname + url.search
799
+ };
800
+ }
801
+ if (match[1].startsWith("/")) {
802
+ const url = new URL(match[1], window.location.origin);
803
+ return {
804
+ pathname: url.pathname,
805
+ search: url.search,
806
+ fullPath: url.pathname + url.search
807
+ };
808
+ }
809
+ return null;
810
+ } catch {
811
+ const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
812
+ if (pathMatch) {
813
+ return {
814
+ pathname: pathMatch[1],
815
+ search: pathMatch[2] || "",
816
+ fullPath: match[1]
817
+ };
818
+ }
819
+ return null;
820
+ }
821
+ }
822
+ return null;
823
+ };
824
+ const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
825
+ if (!menuUrlData || !currentPath) return false;
826
+ const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
827
+ const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
828
+ if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
829
+ const menuParams = new URLSearchParams(menuUrlData.search);
830
+ const currentParams = new URLSearchParams(currentSearch);
831
+ const menuRole = menuParams.get("role");
832
+ const currentRole = currentParams.get("role");
833
+ if (menuRole && currentRole) {
834
+ return menuRole === currentRole;
835
+ }
836
+ if (menuRole && !currentRole || !menuRole && currentRole) {
837
+ return false;
838
+ }
839
+ return true;
840
+ }
841
+ if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
842
+ return true;
843
+ }
844
+ if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
845
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
846
+ if (currentPathParam === "supplier-list") {
847
+ return true;
848
+ }
849
+ }
850
+ if (normalizedMenuPath === "/trips") {
851
+ if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
852
+ return true;
853
+ }
854
+ }
855
+ if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
856
+ const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
857
+ if (menuPathParam) {
858
+ const pathRouteMap = {
859
+ "offer": "/offer/offer",
860
+ "voucher": "/voucher/voucher",
861
+ "tag": "/tags/tags",
862
+ "special-requests": "/corporate/special-requests",
863
+ "pricing-policy": "/policies/pricing-policy",
864
+ "users": "/users/users"
865
+ // Consumer Ecosystem Users (no role param)
866
+ };
867
+ const expectedRoute = pathRouteMap[menuPathParam];
868
+ if (expectedRoute) {
869
+ if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
870
+ if (menuPathParam === "users") {
871
+ const currentParams = new URLSearchParams(currentSearch);
872
+ const currentRole = currentParams.get("role");
873
+ return currentRole !== "admin";
874
+ }
875
+ return true;
876
+ }
877
+ }
878
+ }
879
+ if (normalizedCurrentPath === "/orgselector") {
880
+ const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
881
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
882
+ if (menuPathParam2 && currentPathParam) {
883
+ return menuPathParam2 === currentPathParam;
884
+ }
885
+ }
886
+ }
887
+ if (normalizedMenuPath === normalizedCurrentPath) {
888
+ if (menuUrlData.search) {
889
+ const menuParams = new URLSearchParams(menuUrlData.search);
890
+ const currentParams = new URLSearchParams(currentSearch);
891
+ for (const [key, value] of menuParams.entries()) {
892
+ if (key === "auth") {
893
+ continue;
894
+ }
895
+ if (currentParams.get(key) !== value) {
896
+ return false;
897
+ }
898
+ }
899
+ return true;
900
+ }
901
+ return true;
902
+ }
903
+ if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
904
+ return true;
905
+ }
906
+ return false;
907
+ };
908
+ const navItemsLocal = navItems ?? navItemsConstant;
909
+ const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
910
+ const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
911
+ const detectAndSetActiveMenu = useCallback(() => {
912
+ const currentPath = window.location.pathname;
913
+ const currentSearch = window.location.search;
914
+ const newOpenMenus = /* @__PURE__ */ new Set();
915
+ let foundActivePath = null;
916
+ navItemsLocal.forEach((item, index) => {
917
+ if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
918
+ const itemUrlData = extractUrlFromOnClick(item.onClick);
919
+ if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
920
+ foundActivePath = `menu-${index}`;
921
+ }
922
+ }
923
+ if (item.options && item.options.length > 0) {
924
+ item.options.forEach((option, optionsIndex) => {
925
+ if (option.onClick && typeof option.onClick === "function") {
926
+ const optionUrlData = extractUrlFromOnClick(option.onClick);
927
+ if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
928
+ const menuKey = `menu-${index}`;
929
+ newOpenMenus.add(menuKey);
930
+ foundActivePath = `menu-${index}-option-${optionsIndex}`;
931
+ if (option.options && option.options.length > 0) {
932
+ option.options.forEach((subOption, subIndex) => {
933
+ const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
934
+ if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
935
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
936
+ newOpenMenus.add(subMenuKey);
937
+ foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
938
+ }
939
+ });
940
+ }
941
+ }
942
+ }
943
+ });
944
+ }
945
+ });
946
+ if (foundActivePath) {
947
+ setOpenMenus(newOpenMenus);
948
+ setActiveMenuPath(foundActivePath);
949
+ }
950
+ }, [navItemsLocal]);
951
+ const [currentUrl, setCurrentUrl] = useState3(
952
+ () => window.location.pathname + window.location.search
953
+ );
954
+ useEffect(() => {
955
+ detectAndSetActiveMenu();
956
+ setCurrentUrl(window.location.pathname + window.location.search);
957
+ }, [detectAndSetActiveMenu]);
958
+ useEffect(() => {
959
+ let lastUrl = window.location.pathname + window.location.search;
960
+ const handleLocationChange = () => {
961
+ const newUrl = window.location.pathname + window.location.search;
962
+ if (newUrl !== lastUrl) {
963
+ lastUrl = newUrl;
964
+ setCurrentUrl(newUrl);
965
+ detectAndSetActiveMenu();
966
+ }
967
+ };
968
+ window.addEventListener("popstate", handleLocationChange);
969
+ const checkInterval = setInterval(() => {
970
+ const newUrl = window.location.pathname + window.location.search;
971
+ if (newUrl !== lastUrl) {
972
+ handleLocationChange();
973
+ }
974
+ }, 250);
975
+ return () => {
976
+ window.removeEventListener("popstate", handleLocationChange);
977
+ clearInterval(checkInterval);
978
+ };
979
+ }, [detectAndSetActiveMenu]);
980
+ useEffect(() => {
981
+ detectAndSetActiveMenu();
982
+ }, [currentUrl, detectAndSetActiveMenu]);
983
+ const toggleMobileMenu = () => {
984
+ setIsMobileMenuOpen(!isMobileMenuOpen);
985
+ };
986
+ const closeMobileMenu = () => {
987
+ setIsMobileMenuOpen(false);
988
+ };
989
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.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" }, /* @__PURE__ */ React12.createElement(
990
+ "button",
991
+ {
992
+ onClick: toggleMobileMenu,
993
+ className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
994
+ "aria-label": "Toggle menu"
995
+ },
996
+ isMobileMenuOpen ? /* @__PURE__ */ React12.createElement(X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ React12.createElement(Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
997
+ ), /* @__PURE__ */ React12.createElement("div", { className: "flex-1 flex justify-center" }, sideBarLogo && /* @__PURE__ */ React12.createElement(
998
+ "img",
999
+ {
1000
+ src: sideBarLogo,
1001
+ alt: "sidebarLogo",
1002
+ width: 108,
1003
+ height: 40,
1004
+ className: "object-contain"
1005
+ }
1006
+ )), /* @__PURE__ */ React12.createElement("div", { className: "w-10" })), isMobileMenuOpen && /* @__PURE__ */ React12.createElement(
1007
+ "div",
1008
+ {
1009
+ className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1010
+ onClick: closeMobileMenu
1011
+ }
1012
+ ), /* @__PURE__ */ React12.createElement(
1013
+ "div",
1014
+ {
1015
+ 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"}`
1016
+ },
1017
+ /* @__PURE__ */ React12.createElement("div", { className: "p-2 mb-2 hidden md:block" }, /* @__PURE__ */ React12.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2" }, sideBarLogo && /* @__PURE__ */ React12.createElement(
1018
+ "img",
1019
+ {
1020
+ src: sideBarLogo,
1021
+ alt: "sidebarLogo",
1022
+ width: 108,
1023
+ height: 40,
1024
+ className: "object-contain"
1025
+ }
1026
+ ))),
1027
+ /* @__PURE__ */ React12.createElement("div", { className: "mb-4" }),
1028
+ /* @__PURE__ */ React12.createElement("div", { className: "overflow-y-auto scrollbar-hide" }, /* @__PURE__ */ React12.createElement("div", null, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1029
+ const menuKey = `menu-${index}`;
1030
+ const isOpen = isMenuOpen(menuKey);
1031
+ const isActive = activeMenuPath === menuKey;
1032
+ return /* @__PURE__ */ React12.createElement("div", { key: index, className: "" }, /* @__PURE__ */ React12.createElement(
1033
+ "div",
1034
+ {
1035
+ 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]" : ""}`,
1036
+ onClick: (e) => handleMenuClick(item, index, e)
1037
+ },
1038
+ /* @__PURE__ */ React12.createElement("div", { className: "text-primary" }, /* @__PURE__ */ React12.createElement(item.Icon, { width: 20, height: 20 })),
1039
+ /* @__PURE__ */ React12.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]" }, item.label),
1040
+ item.isDropDown && /* @__PURE__ */ React12.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}` }, /* @__PURE__ */ React12.createElement(ChevronDown3, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1041
+ ), item.options && item.options.length > 0 && /* @__PURE__ */ React12.createElement(
1042
+ "div",
1043
+ {
1044
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`
1045
+ },
1046
+ item.options.map((options, optionsIndex) => {
1047
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1048
+ const isSubMenuOpen = isMenuOpen(subMenuKey);
1049
+ const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1050
+ return /* @__PURE__ */ React12.createElement("div", { key: optionsIndex, className: "" }, /* @__PURE__ */ React12.createElement(
1051
+ "div",
1052
+ {
1053
+ className: `flex items-center gap-3 py-2 px-3 ml-4 mr-2 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer rounded-md transition-colors duration-200 ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1054
+ onClick: (e) => handleSubMenuClick(options, optionsIndex, index, e)
1055
+ },
1056
+ /* @__PURE__ */ React12.createElement("div", null),
1057
+ /* @__PURE__ */ React12.createElement("span", { className: "!font-medium !text-[15px] !text-[#3f3f46cc] dark:text-[#a1a1aa]" }, options.label),
1058
+ options.isDropDown && /* @__PURE__ */ React12.createElement(
1059
+ "div",
1060
+ {
1061
+ className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`
1062
+ },
1063
+ /* @__PURE__ */ React12.createElement(ChevronDown3, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1064
+ )
1065
+ ), options.options && options.options.length > 0 && /* @__PURE__ */ React12.createElement(
1066
+ "div",
1067
+ {
1068
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`
1069
+ },
1070
+ options.options.map((subOption, subIndex) => {
1071
+ const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1072
+ return /* @__PURE__ */ React12.createElement(
1073
+ "div",
1074
+ {
1075
+ key: subIndex,
1076
+ 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]" : ""}`,
1077
+ onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e)
1078
+ },
1079
+ subOption.label
1080
+ );
1081
+ })
1082
+ ));
1083
+ })
1084
+ ));
1085
+ }))),
1086
+ /* @__PURE__ */ React12.createElement("div", { className: "mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2" }, /* @__PURE__ */ React12.createElement(
1087
+ "div",
1088
+ {
1089
+ className: "flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1090
+ onClick: () => {
1091
+ window.location.href = "/profile";
1092
+ }
1093
+ },
1094
+ /* @__PURE__ */ React12.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React12.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10" }, /* @__PURE__ */ React12.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" }, ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.UserName) ? authData.userInfo.UserName.split("")[0] : "A")), /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]" }, ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.UserName) ? authData.userInfo.UserName : "Admin"), /* @__PURE__ */ React12.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]" }, role)))
1095
+ ))
1096
+ ));
1097
+ };
1098
+
1099
+ // src/RightSheet/RightSheet.jsx
1100
+ import React13, { useEffect as useEffect2, useState as useState4 } from "react";
1101
+ var RightSheet = ({
1102
+ open,
1103
+ setOpen,
1104
+ children,
1105
+ callBack,
1106
+ actionLabel = "Save",
1107
+ onAction = () => {
1108
+ }
1109
+ }) => {
1110
+ const [visible, setVisible] = useState4(open);
1111
+ useEffect2(() => {
1112
+ if (open) {
1113
+ document.body.style.overflow = "hidden";
1114
+ setVisible(true);
1115
+ }
1116
+ return () => {
1117
+ document.body.style.overflow = "auto";
1118
+ };
1119
+ }, [open]);
1120
+ const handleClose = () => {
1121
+ setVisible(false);
1122
+ setTimeout(() => {
1123
+ setOpen(false);
1124
+ callBack();
1125
+ }, 200);
1126
+ };
1127
+ const handleAction = () => {
1128
+ onAction();
1129
+ handleClose();
1130
+ };
1131
+ if (!visible) return null;
1132
+ return /* @__PURE__ */ React13.createElement(
1133
+ "div",
1134
+ {
1135
+ className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1136
+ onClick: handleClose
1137
+ },
1138
+ /* @__PURE__ */ React13.createElement(
1139
+ "div",
1140
+ {
1141
+ className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1142
+ ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1143
+ onClick: (e) => e.stopPropagation()
1144
+ },
1145
+ /* @__PURE__ */ React13.createElement("div", { className: " min-h-full " }, children),
1146
+ /* @__PURE__ */ React13.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" }, /* @__PURE__ */ React13.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose() }, "Cancel"), /* @__PURE__ */ React13.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction }, actionLabel))
1147
+ )
1148
+ );
1149
+ };
1150
+
1151
+ // src/Table/CustomTable.jsx
1152
+ import React14 from "react";
1153
+ var CustomTable = ({
1154
+ tableHeader,
1155
+ setIsAllChecked,
1156
+ isAllChecked,
1157
+ children,
1158
+ isHideCheckbox = "false"
1159
+ }) => {
1160
+ return /* @__PURE__ */ React14.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto" }, /* @__PURE__ */ React14.createElement("div", { className: "w-full relative overflow-x-auto" }, /* @__PURE__ */ React14.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse" }, /* @__PURE__ */ React14.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]" }, /* @__PURE__ */ React14.createElement(
1161
+ "tr",
1162
+ {
1163
+ className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted"
1164
+ },
1165
+ !isHideCheckbox && /* @__PURE__ */ React14.createElement("th", { className: "px-4 py-3 text-left w-[50px]" }, /* @__PURE__ */ React14.createElement(
1166
+ CustomCheckbox,
1167
+ {
1168
+ checked: isAllChecked,
1169
+ onChange: () => {
1170
+ setIsAllChecked(!isAllChecked);
1171
+ }
1172
+ }
1173
+ )),
1174
+ tableHeader.map((header, index) => {
1175
+ return /* @__PURE__ */ React14.createElement(
1176
+ "th",
1177
+ {
1178
+ className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1179
+ key: header + index
1180
+ },
1181
+ header
1182
+ );
1183
+ })
1184
+ )), /* @__PURE__ */ React14.createElement("tbody", null, children))));
1185
+ };
1186
+
1187
+ // src/Pagination/Pagination.jsx
1188
+ import React15, { useMemo, useState as useState5, useEffect as useEffect3 } from "react";
1189
+ import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
1190
+ var Pagination = ({
1191
+ data = [],
1192
+ component: Component,
1193
+ itemsPerPage = 6,
1194
+ itemsPerPageOptions = [5, 10, 20, 50, 100],
1195
+ // Controlled props (optional)
1196
+ currentPage: controlledCurrentPage,
1197
+ onPageChange: controlledOnPageChange,
1198
+ onItemsPerPageChange: controlledOnItemsPerPageChange,
1199
+ // Legacy props for backward compatibility
1200
+ totalPages,
1201
+ totalItems: legacyTotalItems,
1202
+ onPageChange: legacyOnPageChange,
1203
+ onItemsPerPageChange: legacyOnItemsPerPageChange,
1204
+ tableHeader,
1205
+ isHideCheckbox,
1206
+ callback,
1207
+ isTable = false,
1208
+ // Component props - any additional props to pass to the component
1209
+ componentProps = {},
1210
+ ...restProps
1211
+ }) => {
1212
+ const [internalCurrentPage, setInternalCurrentPage] = useState5(1);
1213
+ const [internalItemsPerPage, setInternalItemsPerPage] = useState5(itemsPerPage);
1214
+ const isControlled = controlledCurrentPage !== void 0;
1215
+ const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1216
+ const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1217
+ const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1218
+ const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1219
+ const calculatedTotalPages = useMemo(() => {
1220
+ if (totalItems > 0 && activeItemsPerPage > 0) {
1221
+ return Math.ceil(totalItems / activeItemsPerPage);
1222
+ }
1223
+ return 1;
1224
+ }, [totalItems, activeItemsPerPage]);
1225
+ const paginatedData = useMemo(() => {
1226
+ if (!data || data.length === 0) return [];
1227
+ const startIndex = (currentPage - 1) * activeItemsPerPage;
1228
+ const endIndex = startIndex + activeItemsPerPage;
1229
+ return data.slice(startIndex, endIndex);
1230
+ }, [data, currentPage, activeItemsPerPage]);
1231
+ useEffect3(() => {
1232
+ if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1233
+ setInternalCurrentPage(1);
1234
+ }
1235
+ }, [calculatedTotalPages, isControlled, currentPage]);
1236
+ const getPageNumbers = () => {
1237
+ const pages = [];
1238
+ const maxVisible = 5;
1239
+ let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1240
+ let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1241
+ if (endPage - startPage < maxVisible - 1) {
1242
+ startPage = Math.max(1, endPage - maxVisible + 1);
1243
+ }
1244
+ for (let i = startPage; i <= endPage; i++) {
1245
+ pages.push(i);
1246
+ }
1247
+ return pages;
1248
+ };
1249
+ const handlePageChange = (page) => {
1250
+ if (page >= 1 && page <= calculatedTotalPages) {
1251
+ if (isControlled && controlledOnPageChange) {
1252
+ controlledOnPageChange(page);
1253
+ } else if (legacyOnPageChange) {
1254
+ legacyOnPageChange(page);
1255
+ } else {
1256
+ setInternalCurrentPage(page);
1257
+ }
1258
+ }
1259
+ };
1260
+ const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1261
+ const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1262
+ const renderContent = () => {
1263
+ if (Component) {
1264
+ if (React15.isValidElement(Component)) {
1265
+ const ComponentType = Component.type;
1266
+ const elementProps = Component.props;
1267
+ if (isTable) {
1268
+ return /* @__PURE__ */ React15.createElement(
1269
+ CustomTable,
1270
+ {
1271
+ tableHeader,
1272
+ isHideCheckbox
1273
+ },
1274
+ data.map((item, index) => {
1275
+ return /* @__PURE__ */ React15.createElement(
1276
+ ComponentType,
1277
+ {
1278
+ key: item.id || item._id || index,
1279
+ data: item,
1280
+ ...elementProps,
1281
+ ...componentProps,
1282
+ ...restProps
1283
+ }
1284
+ );
1285
+ })
1286
+ );
1287
+ } else {
1288
+ if (isTable) {
1289
+ return /* @__PURE__ */ React15.createElement(
1290
+ CustomTable,
1291
+ {
1292
+ tableHeader,
1293
+ isHideCheckbox
1294
+ },
1295
+ paginatedData.map((item, index) => {
1296
+ return /* @__PURE__ */ React15.createElement(
1297
+ ComponentType,
1298
+ {
1299
+ key: item.id || item._id || index,
1300
+ data: item,
1301
+ ...elementProps,
1302
+ ...componentProps,
1303
+ ...restProps
1304
+ }
1305
+ );
1306
+ })
1307
+ );
1308
+ }
1309
+ }
1310
+ } else {
1311
+ return /* @__PURE__ */ React15.createElement(
1312
+ CustomTable,
1313
+ {
1314
+ tableHeader,
1315
+ isHideCheckbox
1316
+ },
1317
+ paginatedData.map((item, index) => {
1318
+ return /* @__PURE__ */ React15.createElement(
1319
+ Component,
1320
+ {
1321
+ key: item.id || item._id || index,
1322
+ data: item,
1323
+ ...componentProps,
1324
+ ...restProps
1325
+ }
1326
+ );
1327
+ })
1328
+ );
1329
+ }
1330
+ }
1331
+ return null;
1332
+ };
1333
+ return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(React15.Fragment, null, renderContent()), /* @__PURE__ */ React15.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" }, totalItems !== void 0 && /* @__PURE__ */ React15.createElement("div", { className: "text-sm text-[#737373] dark:text-white" }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ React15.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React15.createElement(
1334
+ "button",
1335
+ {
1336
+ onClick: () => handlePageChange(1),
1337
+ disabled: currentPage === 1,
1338
+ 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]"}`,
1339
+ title: "First page"
1340
+ },
1341
+ /* @__PURE__ */ React15.createElement(ChevronsLeft, { size: 16 })
1342
+ ), /* @__PURE__ */ React15.createElement(
1343
+ "button",
1344
+ {
1345
+ onClick: () => handlePageChange(currentPage - 1),
1346
+ disabled: currentPage === 1,
1347
+ 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]"}`,
1348
+ title: "Previous page"
1349
+ },
1350
+ /* @__PURE__ */ React15.createElement(ChevronLeft, { size: 16 })
1351
+ ), getPageNumbers().map((pageNum) => /* @__PURE__ */ React15.createElement(
1352
+ "button",
1353
+ {
1354
+ key: pageNum,
1355
+ onClick: () => handlePageChange(pageNum),
1356
+ 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]"}`
1357
+ },
1358
+ pageNum
1359
+ )), /* @__PURE__ */ React15.createElement(
1360
+ "button",
1361
+ {
1362
+ onClick: () => handlePageChange(currentPage + 1),
1363
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1364
+ 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]"}`,
1365
+ title: "Next page"
1366
+ },
1367
+ /* @__PURE__ */ React15.createElement(ChevronRight, { size: 16 })
1368
+ ), /* @__PURE__ */ React15.createElement(
1369
+ "button",
1370
+ {
1371
+ onClick: () => handlePageChange(calculatedTotalPages),
1372
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1373
+ 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]"}`,
1374
+ title: "Last page"
1375
+ },
1376
+ /* @__PURE__ */ React15.createElement(ChevronsRight, { size: 16 })
1377
+ ))));
1378
+ };
1379
+ export {
1380
+ AppSideBar,
1381
+ Chip,
1382
+ CustomAutocomplete,
1383
+ CustomButton,
1384
+ CustomCheckbox,
1385
+ CustomInput,
1386
+ CustomSearch,
1387
+ CustomSelect,
1388
+ CustomSwitch,
1389
+ CustomTable,
1390
+ CustomTextarea,
1391
+ CustomUpload,
1392
+ Pagination,
1393
+ ProgressBar,
1394
+ RightSheet
1395
+ };