jett.admin.npmpackage 2.0.34 → 2.0.37

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 (5) hide show
  1. package/README.md +23 -2
  2. package/dist/index.css +1621 -1486
  3. package/dist/index.js +2547 -2161
  4. package/dist/index.mjs +2508 -2130
  5. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,2161 +1,2547 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/index.js
30
- var index_exports = {};
31
- __export(index_exports, {
32
- AppSideBar: () => AppSideBar,
33
- Calendar: () => Calendar,
34
- Chip: () => Chip,
35
- CustomAutocomplete: () => CustomAutocomplete,
36
- CustomButton: () => CustomButton,
37
- CustomCheckbox: () => CustomCheckbox,
38
- CustomInput: () => CustomInput,
39
- CustomSearch: () => CustomSearch,
40
- CustomSelect: () => CustomSelect,
41
- CustomSwitch: () => CustomSwitch,
42
- CustomTable: () => CustomTable,
43
- CustomTextarea: () => CustomTextarea,
44
- CustomUpload: () => CustomUpload,
45
- Dropdown: () => Dropdown,
46
- Pagination: () => Pagination,
47
- ProgressBar: () => ProgressBar,
48
- RightSheet: () => RightSheet
49
- });
50
- module.exports = __toCommonJS(index_exports);
51
-
52
- // src/utils/cn.ts
53
- var import_clsx = require("clsx");
54
- var import_tailwind_merge = require("tailwind-merge");
55
- function cn(...inputs) {
56
- return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
57
- }
58
-
59
- // src/Button.jsx
60
- var import_react = __toESM(require("react"));
61
- var variantStyles = {
62
- PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
63
- SECONDARY: "bg-primary text-white dark:text-white",
64
- DEFAULT: "bg-white text-black dark:text-white",
65
- DANGER: "bg-[#ef4444] text-white dark:text-white"
66
- };
67
- var CustomButton = ({
68
- id = "button",
69
- variant = "DEFAULT",
70
- children,
71
- className,
72
- onClick,
73
- disabled = false,
74
- icon
75
- }) => {
76
- return /* @__PURE__ */ import_react.default.createElement(
77
- "div",
78
- {
79
- className: cn(
80
- `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`,
81
- variantStyles[variant],
82
- className
83
- ),
84
- onClick,
85
- id: `${id}-div-1`
86
- },
87
- icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
88
- children
89
- );
90
- };
91
-
92
- // src/inputs/Autocomplete.jsx
93
- var import_react2 = __toESM(require("react"));
94
- var import_lucide_react = require("lucide-react");
95
- var CustomAutocomplete = ({
96
- id = "autocomplete",
97
- label,
98
- value,
99
- onChange,
100
- options,
101
- placeholder = "Search & select...",
102
- isRequired = false,
103
- error,
104
- heading,
105
- disabled = false
106
- }) => {
107
- const [open, setOpen] = (0, import_react2.useState)(false);
108
- const [search, setSearch] = (0, import_react2.useState)("");
109
- const wrapperRef = (0, import_react2.useRef)(null);
110
- const selectedOptions = options.filter((opt) => value.includes(opt.value));
111
- const handleBlur = (e) => {
112
- var _a;
113
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
114
- setOpen(false);
115
- }
116
- };
117
- const filteredOptions = options.filter(
118
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
119
- );
120
- const toggleValue = (val) => {
121
- if (value.includes(val)) {
122
- onChange(value.filter((v) => v !== val));
123
- } else {
124
- onChange([...value, val]);
125
- }
126
- };
127
- return /* @__PURE__ */ import_react2.default.createElement(
128
- "div",
129
- {
130
- className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
131
- ref: wrapperRef,
132
- tabIndex: disabled ? -1 : 0,
133
- onBlur: handleBlur,
134
- id: `${id}-div-1`
135
- },
136
- heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
137
- label && /* @__PURE__ */ import_react2.default.createElement(
138
- "label",
139
- {
140
- className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
141
- id: `${id}-label-1`
142
- },
143
- label,
144
- " ",
145
- isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
146
- ),
147
- /* @__PURE__ */ import_react2.default.createElement(
148
- "div",
149
- {
150
- onClick: () => {
151
- if (!disabled) setOpen((prev) => !prev);
152
- },
153
- 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
154
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
155
- ${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"}
156
- `,
157
- id: `${id}-div-2`
158
- },
159
- /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
160
- "span",
161
- {
162
- key: opt.value,
163
- 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",
164
- id: `${id}-span-2`
165
- },
166
- opt.label,
167
- /* @__PURE__ */ import_react2.default.createElement(
168
- "button",
169
- {
170
- onClick: (e) => {
171
- e.stopPropagation();
172
- toggleValue(opt.value);
173
- },
174
- className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
175
- id: `${id}-button-1`
176
- },
177
- "\u2715"
178
- )
179
- )) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
180
- /* @__PURE__ */ import_react2.default.createElement(
181
- import_lucide_react.ChevronDown,
182
- {
183
- className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
184
- }
185
- )
186
- ),
187
- !disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
188
- "input",
189
- {
190
- type: "text",
191
- value: search,
192
- onChange: (e) => setSearch(e.target.value),
193
- placeholder: "Search...",
194
- className: "flex-1 text-sm focus:outline-none",
195
- id: `${id}-input-1`
196
- }
197
- )), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
198
- const selected = value.includes(opt.value);
199
- return /* @__PURE__ */ import_react2.default.createElement(
200
- "li",
201
- {
202
- key: opt.value,
203
- onClick: () => toggleValue(opt.value),
204
- 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" : ""}`,
205
- id: `${id}-li-1`
206
- },
207
- /* @__PURE__ */ import_react2.default.createElement(
208
- "span",
209
- {
210
- 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"}`,
211
- id: `${id}-span-4`
212
- },
213
- selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
214
- ),
215
- opt.label
216
- );
217
- }) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
218
- );
219
- };
220
-
221
- // src/inputs/Checkbox.jsx
222
- var import_react3 = __toESM(require("react"));
223
- var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
224
- const handleChange = (e) => {
225
- onChange(e.target.checked);
226
- };
227
- return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
228
- "input",
229
- {
230
- type: "checkbox",
231
- checked,
232
- onChange: handleChange,
233
- className: "peer hidden",
234
- id: `${id}-input-1`
235
- }
236
- ), /* @__PURE__ */ import_react3.default.createElement(
237
- "span",
238
- {
239
- 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 ",
240
- id: `${id}-span-1`
241
- },
242
- checked && /* @__PURE__ */ import_react3.default.createElement(
243
- "svg",
244
- {
245
- className: "w-4 h-4 text-white",
246
- fill: "none",
247
- stroke: "currentColor",
248
- strokeWidth: "3",
249
- viewBox: "0 0 24 24",
250
- id: `${id}-svg-1`
251
- },
252
- /* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
253
- )
254
- ));
255
- };
256
-
257
- // src/inputs/Chip.jsx
258
- var import_react4 = __toESM(require("react"));
259
- var VARIANTS = {
260
- PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
261
- GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
262
- RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
263
- YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
264
- };
265
- var Chip = ({ id = "chip", label, variant }) => {
266
- return /* @__PURE__ */ import_react4.default.createElement(
267
- "div",
268
- {
269
- className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
270
- id: `${id}-div-1`
271
- },
272
- label
273
- );
274
- };
275
-
276
- // src/inputs/CustomSwitch.jsx
277
- var import_react5 = __toESM(require("react"));
278
- var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
279
- return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
280
- "button",
281
- {
282
- type: "button",
283
- role: "switch",
284
- "aria-checked": checked,
285
- onClick: () => onChange(!checked),
286
- className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
287
- id: `${id}-button-1`
288
- },
289
- /* @__PURE__ */ import_react5.default.createElement(
290
- "span",
291
- {
292
- className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
293
- id: `${id}-span-1`
294
- }
295
- )
296
- ), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
297
- };
298
-
299
- // src/inputs/Input.jsx
300
- var import_react6 = __toESM(require("react"));
301
- var CustomInput = ({
302
- id = "input",
303
- label,
304
- isRequired,
305
- value,
306
- onChange,
307
- placeholder,
308
- disabled = false,
309
- error,
310
- heading
311
- }) => {
312
- return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
313
- "label",
314
- {
315
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
316
- id: `${id}-label-1`
317
- },
318
- label,
319
- " ",
320
- isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
321
- ), /* @__PURE__ */ import_react6.default.createElement(
322
- "input",
323
- {
324
- className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
325
- placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
326
- focus:outline-2 outline-black dark:outline-white outline-offset-2
327
- dark:bg-transparent dark:text-white dark:border-[#303036]
328
- ${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%)]"}
329
- `,
330
- value,
331
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
332
- placeholder,
333
- disabled,
334
- readOnly: disabled,
335
- id: `${id}-input-1`
336
- }
337
- ));
338
- };
339
-
340
- // src/inputs/ProgressBar.jsx
341
- var import_react7 = __toESM(require("react"));
342
- var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
343
- const progress = step / totalSteps * 100;
344
- return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
345
- "div",
346
- {
347
- className: "bg-black h-2 rounded-full transition-all duration-300",
348
- style: { width: `${progress}%` },
349
- id: `${id}-div-3`
350
- }
351
- )));
352
- };
353
-
354
- // src/inputs/Search.jsx
355
- var import_react8 = __toESM(require("react"));
356
- var import_lucide_react2 = require("lucide-react");
357
- var CustomSearch = ({
358
- id = "search",
359
- value,
360
- onChange,
361
- placeholder = "Search Markets..."
362
- }) => {
363
- return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
364
- "input",
365
- {
366
- type: "text",
367
- value,
368
- onChange,
369
- placeholder,
370
- className: "bg-transparent w-full h-full focus:outline-none",
371
- id: `${id}-input-1`
372
- }
373
- ));
374
- };
375
-
376
- // src/inputs/TextArea.jsx
377
- var import_react9 = __toESM(require("react"));
378
- var CustomTextarea = ({
379
- id = "text-area",
380
- label,
381
- isRequired,
382
- value,
383
- onChange,
384
- placeholder,
385
- disabled = false,
386
- error,
387
- heading,
388
- rows = 4
389
- }) => {
390
- return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
391
- "label",
392
- {
393
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
394
- id: `${id}-label-1`
395
- },
396
- label,
397
- " ",
398
- isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
399
- ), /* @__PURE__ */ import_react9.default.createElement(
400
- "textarea",
401
- {
402
- rows,
403
- className: `border rounded-md px-4 py-2 w-full text-[14px]
404
- focus:outline-2 focus:outline-black focus:outline-offset-2
405
- focus:ring-0 focus:shadow-none focus:border-black
406
- ${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%)]"}
407
- `,
408
- value,
409
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
410
- placeholder,
411
- disabled,
412
- readOnly: disabled,
413
- id: `${id}-textarea-1`
414
- }
415
- ));
416
- };
417
-
418
- // src/inputs/Upload.jsx
419
- var import_react10 = __toESM(require("react"));
420
- var import_lucide_react3 = require("lucide-react");
421
- var CustomUpload = ({
422
- id = "upload",
423
- label = "Supporting documents",
424
- description = "Drop items here or Browse Files",
425
- accept = ".pdf,.jpg,.jpeg,.png",
426
- maxSizeMB = 5,
427
- onChange,
428
- error,
429
- value
430
- }) => {
431
- const inputRef = (0, import_react10.useRef)(null);
432
- const handleFileSelect = (files) => {
433
- if (!files || files.length === 0) return;
434
- const selectedFile = files[0];
435
- if (selectedFile.size > maxSizeMB * 1024 * 1024) {
436
- alert(`File size must be less than ${maxSizeMB} MB`);
437
- return;
438
- }
439
- onChange == null ? void 0 : onChange(selectedFile);
440
- };
441
- return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
442
- "div",
443
- {
444
- className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
445
- ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
446
- onClick: () => {
447
- var _a;
448
- return (_a = inputRef.current) == null ? void 0 : _a.click();
449
- },
450
- onDragOver: (e) => e.preventDefault(),
451
- onDrop: (e) => {
452
- e.preventDefault();
453
- handleFileSelect(e.dataTransfer.files);
454
- },
455
- id: `${id}-div-2`
456
- },
457
- /* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
458
- /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
459
- /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
460
- /* @__PURE__ */ import_react10.default.createElement(
461
- "input",
462
- {
463
- ref: inputRef,
464
- type: "file",
465
- accept,
466
- className: "hidden",
467
- onChange: (e) => handleFileSelect(e.target.files),
468
- id: `${id}-input-1`
469
- }
470
- )
471
- ), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
472
- };
473
-
474
- // src/sideBar/SideBar.jsx
475
- var import_lucide_react8 = require("lucide-react");
476
- var import_react14 = __toESM(require("react"));
477
-
478
- // ConstantUI.js
479
- var import_lucide_react4 = require("lucide-react");
480
- var encodedAuthData = localStorage.getItem("encodedAuthData");
481
- var navItemsConstant = [
482
- {
483
- Icon: import_lucide_react4.Home,
484
- label: "Home",
485
- onClick: () => {
486
- window.location.href = "/";
487
- },
488
- isDropDown: false
489
- },
490
- {
491
- Icon: import_lucide_react4.Building,
492
- label: "Consumer Ecosystem",
493
- onClick: () => {
494
- },
495
- options: [
496
- {
497
- label: "Corporate",
498
- onClick: () => {
499
- window.location.href = "/corporate/";
500
- }
501
- },
502
- {
503
- label: "Trips",
504
- onClick: () => {
505
- window.location.href = "/corporate/trips/";
506
- }
507
- },
508
- {
509
- label: "Users",
510
- onClick: () => {
511
- window.location.href = "/users/users";
512
- }
513
- },
514
- {
515
- label: "Tags (Custom Variables)",
516
- onClick: () => {
517
- window.location.href = "/orgselector/?path=tag";
518
- }
519
- },
520
- {
521
- label: "Special Request",
522
- onClick: () => {
523
- window.location.href = "/orgselector/?path=special-requests";
524
- }
525
- },
526
- {
527
- label: "Support Tickets (Coming Soon)",
528
- isDisabled: true
529
- // onClick: () => {},
530
- }
531
- ],
532
- isDropDown: true
533
- },
534
- {
535
- Icon: import_lucide_react4.Banknote,
536
- label: "Finance",
537
- onClick: () => {
538
- },
539
- isDropDown: true,
540
- options: [
541
- {
542
- label: "Credit Management",
543
- onClick: () => {
544
- window.location.href = "/finance/paymentsLedger/";
545
- }
546
- },
547
- {
548
- label: "Booking & Invoices",
549
- onClick: () => {
550
- window.location.href = "/finance/bookingHistory/";
551
- }
552
- }
553
- ]
554
- },
555
- {
556
- Icon: import_lucide_react4.DollarSign,
557
- label: "Revenue Management",
558
- onClick: () => {
559
- },
560
- isDropDown: true,
561
- options: [
562
- {
563
- label: "Pricing Engine",
564
- onClick: () => {
565
- window.location.href = "/orgselector/?path=pricing-policy";
566
- }
567
- },
568
- {
569
- label: "Offers",
570
- onClick: () => {
571
- window.location.href = "/orgselector/?path=offer";
572
- }
573
- },
574
- {
575
- label: "Vouchers",
576
- onClick: () => {
577
- window.location.href = "/orgselector/?path=voucher";
578
- }
579
- }
580
- ]
581
- },
582
- {
583
- Icon: import_lucide_react4.Handshake,
584
- label: "Supplier Ecosystem",
585
- onClick: () => {
586
- },
587
- isDropDown: true,
588
- options: [
589
- {
590
- label: "Suppliers List",
591
- onClick: () => {
592
- window.location.href = "/orgselector/?path=supplier-list";
593
- }
594
- },
595
- {
596
- label: "Supplier Deals",
597
- onClick: () => {
598
- window.location.href = "/supplierdeals/";
599
- }
600
- }
601
- ]
602
- },
603
- {
604
- Icon: import_lucide_react4.BarChart3,
605
- label: "Reports",
606
- onClick: () => {
607
- },
608
- isDropDown: true,
609
- options: [
610
- {
611
- label: "Reports",
612
- onClick: () => {
613
- window.location.href = "/reports/";
614
- }
615
- }
616
- ]
617
- },
618
- {
619
- Icon: import_lucide_react4.Cog,
620
- label: "Settings",
621
- onClick: () => {
622
- },
623
- isDropDown: true,
624
- options: [
625
- {
626
- label: "Whitelabel",
627
- onClick: () => {
628
- window.location.href = "/whitelabel/";
629
- }
630
- },
631
- {
632
- label: "Markets",
633
- onClick: () => {
634
- window.location.href = "/market/";
635
- }
636
- },
637
- {
638
- label: "Users",
639
- onClick: () => {
640
- window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
641
- }
642
- },
643
- {
644
- label: "Reports Configurations",
645
- onClick: () => {
646
- window.location.href = "/reports/";
647
- }
648
- }
649
- ]
650
- }
651
- ];
652
- var additionalItemsConstant = [
653
- {
654
- Icon: import_lucide_react4.LifeBuoy,
655
- label: "Help",
656
- onClick: () => {
657
- window.location.href = "/help";
658
- }
659
- }
660
- ];
661
-
662
- // src/sideBar/SideBar.jsx
663
- var import_js_cookie = __toESM(require("js-cookie"));
664
-
665
- // src/inputs/CustomSelect.jsx
666
- var import_react11 = __toESM(require("react"));
667
- var import_lucide_react5 = require("lucide-react");
668
- var CustomSelect = ({
669
- id = "custom-select",
670
- label,
671
- value,
672
- onChange,
673
- options,
674
- placeholder = "Select...",
675
- isRequired = false,
676
- error,
677
- heading,
678
- disabled = false
679
- }) => {
680
- const [open, setOpen] = (0, import_react11.useState)(false);
681
- const [search, setSearch] = (0, import_react11.useState)("");
682
- const wrapperRef = (0, import_react11.useRef)(null);
683
- const handleBlur = (e) => {
684
- var _a;
685
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
686
- setOpen(false);
687
- }
688
- };
689
- const filteredOptions = options.filter(
690
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
691
- );
692
- const handleSelect = (val) => {
693
- onChange(val);
694
- setOpen(false);
695
- };
696
- const selectedOption = options.find((opt) => opt.value === value);
697
- return /* @__PURE__ */ import_react11.default.createElement(
698
- "div",
699
- {
700
- className: "flex flex-col w-full relative",
701
- ref: wrapperRef,
702
- tabIndex: disabled ? -1 : 0,
703
- onBlur: handleBlur,
704
- id: `${id}-div-1`
705
- },
706
- heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
707
- label && /* @__PURE__ */ import_react11.default.createElement(
708
- "label",
709
- {
710
- className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
711
- id: `${id}-label-1`
712
- },
713
- label,
714
- " ",
715
- isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
716
- ),
717
- /* @__PURE__ */ import_react11.default.createElement(
718
- "div",
719
- {
720
- onClick: () => !disabled && setOpen((prev) => !prev),
721
- 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
722
- ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
723
- ${error ? "border-red-500" : "border-gray-300"}
724
- `,
725
- id: `${id}-div-2`
726
- },
727
- /* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
728
- /* @__PURE__ */ import_react11.default.createElement(
729
- import_lucide_react5.ChevronDown,
730
- {
731
- className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
732
- }
733
- )
734
- ),
735
- open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
736
- "input",
737
- {
738
- type: "text",
739
- value: search,
740
- onChange: (e) => setSearch(e.target.value),
741
- placeholder: "Search...",
742
- className: "flex-1 text-sm focus:outline-none",
743
- id: `${id}-input-1`
744
- }
745
- )), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
746
- "li",
747
- {
748
- key: opt.value,
749
- onClick: () => handleSelect(opt.value),
750
- 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" : ""}`,
751
- id: `${id}-li-1`
752
- },
753
- opt.label
754
- )) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
755
- );
756
- };
757
-
758
- // src/utils/cookieHelpers.js
759
- var JETT_ID_COOKIE_NAME = "jett-id";
760
- function getCookie(name) {
761
- if (typeof document === "undefined" || !document.cookie) return null;
762
- const match = document.cookie.match(
763
- new RegExp("(^|\\s)" + name + "=([^;]+)")
764
- );
765
- return match ? decodeURIComponent(match[2].trim()) : null;
766
- }
767
- function decodeBase64(value) {
768
- try {
769
- let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
770
- const pad = base64.length % 4;
771
- if (pad) base64 += "=".repeat(4 - pad);
772
- return atob(base64);
773
- } catch {
774
- return "";
775
- }
776
- }
777
- function getJettIdCookieData() {
778
- const raw = getCookie(JETT_ID_COOKIE_NAME);
779
- if (!raw) return null;
780
- try {
781
- const decoded = decodeBase64(raw);
782
- if (!decoded) return null;
783
- const data = JSON.parse(decoded);
784
- return data && typeof data === "object" ? data : null;
785
- } catch {
786
- return null;
787
- }
788
- }
789
- function getLogoFromJettIdCookie() {
790
- const data = getJettIdCookieData();
791
- if (!(data == null ? void 0 : data.CDNBasePath)) return null;
792
- const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
793
- if (!logoPath) return null;
794
- return {
795
- logoPath,
796
- CDNBasePath: data.CDNBasePath
797
- };
798
- }
799
- function getScopeFromJettIdCookie() {
800
- const data = getJettIdCookieData();
801
- return (data == null ? void 0 : data.Scope) ?? null;
802
- }
803
- function getProfilesFromJettIdCookie(all) {
804
- const data = getJettIdCookieData();
805
- if (!(data == null ? void 0 : data.Profiles)) return [];
806
- if (all) return data.Profiles;
807
- return data.Profiles.filter((profile) => {
808
- var _a;
809
- return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
810
- });
811
- }
812
- function buildLogoUrl(CDNBasePath, logoPath) {
813
- const base = (CDNBasePath || "").replace(/\/$/, "");
814
- const path = (logoPath || "").replace(/^\//, "");
815
- if (!base || !path) return "";
816
- return `${base}/${path}`;
817
- }
818
-
819
- // src/utils/switchProfileEncryption.js
820
- var import_node_forge = __toESM(require("node-forge"));
821
- var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
822
- var RSA_EXPONENT_BASE64 = "AQAB";
823
- var convertModulusExponentToPem = (modulus, exponent) => {
824
- const decodedModulus = import_node_forge.default.util.decode64(modulus);
825
- const decodedExponent = import_node_forge.default.util.decode64(exponent);
826
- const publicKey = import_node_forge.default.pki.setRsaPublicKey(
827
- new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
828
- new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
829
- );
830
- return import_node_forge.default.pki.publicKeyToPem(publicKey);
831
- };
832
- var cachedPemKey = null;
833
- var getPemKey = () => {
834
- if (!cachedPemKey) {
835
- cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
836
- }
837
- return cachedPemKey;
838
- };
839
- var encryptForSwitchProfile = (plainText) => {
840
- const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
841
- const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
842
- return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
843
- };
844
-
845
- // src/utils/switchProfileApi.js
846
- var PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
847
- var hasSwitchedProfileThisSession = () => {
848
- try {
849
- return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
850
- } catch {
851
- return false;
852
- }
853
- };
854
- var markProfileSwitched = () => {
855
- try {
856
- if (typeof localStorage !== "undefined") {
857
- localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
858
- }
859
- } catch {
860
- }
861
- };
862
- var clearProfileSwitchFlag = () => {
863
- try {
864
- if (typeof localStorage !== "undefined") {
865
- localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
866
- }
867
- } catch {
868
- }
869
- };
870
- var buildRequestContext = () => ({
871
- UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
872
- TrackingId: crypto.randomUUID(),
873
- TransactionId: crypto.randomUUID(),
874
- CountryCode: "IN",
875
- IpAddress: "127.0.0.1"
876
- // Client IP cannot be retrieved from browser
877
- });
878
- var switchProfile = async (profile) => {
879
- markProfileSwitched();
880
- const encryptedRequest = encryptForSwitchProfile(
881
- JSON.stringify({
882
- ProfileToken: profile.ProfileToken,
883
- ProfileId: profile.ProfileId
884
- })
885
- );
886
- return fetch(`${window.location.origin}/auth/switch/profile`, {
887
- method: "POST",
888
- credentials: "include",
889
- headers: { "Content-Type": "application/json" },
890
- body: JSON.stringify({
891
- Context: buildRequestContext(),
892
- Request: encryptedRequest
893
- })
894
- }).then((res) => res.json());
895
- };
896
-
897
- // src/sideBar/SwitchProfileSection.jsx
898
- var import_react13 = __toESM(require("react"));
899
- var import_react_dom2 = require("react-dom");
900
- var import_lucide_react7 = require("lucide-react");
901
-
902
- // src/sideBar/LogoutConfirmModal.jsx
903
- var import_react12 = __toESM(require("react"));
904
- var import_react_dom = require("react-dom");
905
- var import_lucide_react6 = require("lucide-react");
906
- var LogoutConfirmModal = ({
907
- id = "logout-confirm",
908
- open,
909
- onConfirm,
910
- onCancel,
911
- loading = false
912
- }) => {
913
- if (!open || typeof document === "undefined") return null;
914
- const handleOverlayClick = (e) => {
915
- if (e.target === e.currentTarget && !loading) onCancel();
916
- };
917
- return (0, import_react_dom.createPortal)(
918
- /* @__PURE__ */ import_react12.default.createElement(
919
- "div",
920
- {
921
- className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
922
- onClick: handleOverlayClick,
923
- id: `${id}-overlay`
924
- },
925
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react12.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react12.default.createElement(
926
- "button",
927
- {
928
- type: "button",
929
- onClick: onCancel,
930
- disabled: loading,
931
- className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
932
- id: `${id}-cancel-button`
933
- },
934
- "No, Keep me in"
935
- ), /* @__PURE__ */ import_react12.default.createElement(
936
- "button",
937
- {
938
- type: "button",
939
- onClick: onConfirm,
940
- disabled: loading,
941
- className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
942
- id: `${id}-confirm-button`
943
- },
944
- loading ? "Logging out..." : "Yes, logout"
945
- )))
946
- ),
947
- document.body
948
- );
949
- };
950
-
951
- // src/sideBar/SwitchProfileSection.jsx
952
- var SwitchProfileSection = ({
953
- id = "switch-profile",
954
- open,
955
- anchorRef,
956
- onClose,
957
- onManageProfile,
958
- onProfileSwitch,
959
- onTmcSettings,
960
- onLogout
961
- }) => {
962
- const [position, setPosition] = (0, import_react13.useState)(null);
963
- const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react13.useState)(false);
964
- const [switchingProfileId, setSwitchingProfileId] = (0, import_react13.useState)(null);
965
- const [switchError, setSwitchError] = (0, import_react13.useState)(null);
966
- const jettIdData = getJettIdCookieData();
967
- const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
968
- const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
969
- const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
970
- const allMarkets = getProfilesFromJettIdCookie(true);
971
- const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
972
- const handleProfileSwitch = async (profile) => {
973
- var _a, _b, _c;
974
- if (switchingProfileId) return;
975
- setSwitchingProfileId(profile.ProfileId);
976
- setSwitchError(null);
977
- try {
978
- const response = await switchProfile(profile);
979
- const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
980
- const isSuccess = !statusCode || statusCode === 200;
981
- if (!isSuccess) {
982
- setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
983
- setSwitchingProfileId(null);
984
- return;
985
- }
986
- if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
987
- window.location.href = response.Response.RedirectUrl;
988
- return;
989
- }
990
- setSwitchingProfileId(null);
991
- onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
992
- } catch (error) {
993
- console.error("Switch profile request failed:", error);
994
- setSwitchError("Something went wrong while switching profile. Please try again.");
995
- setSwitchingProfileId(null);
996
- }
997
- };
998
- (0, import_react13.useLayoutEffect)(() => {
999
- if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
1000
- const updatePosition = () => {
1001
- const rect = anchorRef.current.getBoundingClientRect();
1002
- setPosition({
1003
- left: rect.right + 2,
1004
- bottom: window.innerHeight - rect.bottom
1005
- });
1006
- };
1007
- updatePosition();
1008
- window.addEventListener("resize", updatePosition);
1009
- window.addEventListener("scroll", updatePosition, true);
1010
- return () => {
1011
- window.removeEventListener("resize", updatePosition);
1012
- window.removeEventListener("scroll", updatePosition, true);
1013
- };
1014
- }, [open, anchorRef]);
1015
- (0, import_react13.useEffect)(() => {
1016
- if (!open) setSwitchError(null);
1017
- }, [open]);
1018
- (0, import_react13.useEffect)(() => {
1019
- if (!switchError) return;
1020
- const timer = setTimeout(() => setSwitchError(null), 5e3);
1021
- return () => clearTimeout(timer);
1022
- }, [switchError]);
1023
- if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
1024
- const handleConfirmLogout = () => {
1025
- setShowLogoutConfirm(false);
1026
- onLogout == null ? void 0 : onLogout();
1027
- };
1028
- return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
1029
- /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ import_react13.default.createElement(
1030
- "div",
1031
- {
1032
- className: "fixed w-[320px] max-h-[75vh] flex p-4 flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
1033
- style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
1034
- id: `${id}-panel`
1035
- },
1036
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between gap-3 pb-4", id: `${id}-header` }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border-2 border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "40 * 40")), /* @__PURE__ */ import_react13.default.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "!font-semibold dark:text-white !text-[14px] truncate" }, userName || "Admin"), /* @__PURE__ */ import_react13.default.createElement("p", { className: "!text-[10px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ import_react13.default.createElement(
1037
- "button",
1038
- {
1039
- type: "button",
1040
- onClick: onManageProfile,
1041
- className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[10px] font-bold uppercase tracking-wide text-[#0A0A0A] dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
1042
- id: `${id}-manage-profile-button`
1043
- },
1044
- "Manage Profile"
1045
- )),
1046
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
1047
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ import_react13.default.createElement(
1048
- "div",
1049
- {
1050
- className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
1051
- id: `${id}-switch-error`
1052
- },
1053
- switchError
1054
- ), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
1055
- const isCurrent = profile.ProfileId === currentProfileId;
1056
- const isSwitching = switchingProfileId === profile.ProfileId;
1057
- return /* @__PURE__ */ import_react13.default.createElement(
1058
- "div",
1059
- {
1060
- key: profile.ProfileId,
1061
- onClick: () => !isCurrent && handleProfileSwitch(profile),
1062
- "aria-disabled": isSwitching,
1063
- className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white bg-[#f4f4f5] text-[#0A0A0A]" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
1064
- id: `${id}-market-${profile.ProfileId}`
1065
- },
1066
- /* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px] text-gray-900 dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
1067
- isCurrent && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 border-2 border-white text-[9px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
1068
- isSwitching && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
1069
- );
1070
- }))),
1071
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
1072
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "", id: `${id}-footer` }, /* @__PURE__ */ import_react13.default.createElement(
1073
- "div",
1074
- {
1075
- onClick: () => {
1076
- onClose == null ? void 0 : onClose();
1077
- setShowLogoutConfirm(true);
1078
- },
1079
- className: "flex items-center gap-3 p-3 rounded-lg cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
1080
- id: `${id}-logout`
1081
- },
1082
- /* @__PURE__ */ import_react13.default.createElement(import_lucide_react7.LogOut, { width: 18, height: 18 }),
1083
- /* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px]" }, "Logout")
1084
- ))
1085
- )),
1086
- document.body
1087
- ), /* @__PURE__ */ import_react13.default.createElement(
1088
- LogoutConfirmModal,
1089
- {
1090
- id: `${id}-logout-confirm`,
1091
- open: showLogoutConfirm,
1092
- onCancel: () => setShowLogoutConfirm(false),
1093
- onConfirm: handleConfirmLogout
1094
- }
1095
- ));
1096
- };
1097
-
1098
- // src/sideBar/SideBar.jsx
1099
- var SCOPE_LABELS = {
1100
- TMC: "TMC Manager",
1101
- TMC_ENTITY: "TMC Entity Manager"
1102
- };
1103
- var AppSideBar = ({
1104
- id = "side-bar",
1105
- username,
1106
- navItems,
1107
- additionalItems,
1108
- sideBarLogo,
1109
- onManageProfile,
1110
- onProfileSwitch,
1111
- onTmcSettings,
1112
- onLogout
1113
- }) => {
1114
- var _a, _b;
1115
- const profileCardRef = (0, import_react14.useRef)(null);
1116
- const [authData, setAuthData] = (0, import_react14.useState)(null);
1117
- const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
1118
- const [scope, setScope] = (0, import_react14.useState)(null);
1119
- const [selectedCountry, setSelectedCountry] = (0, import_react14.useState)("dubai");
1120
- const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
1121
- const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
1122
- const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
1123
- const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
1124
- const [currAppearance, setCurrAppearance] = (0, import_react14.useState)("light");
1125
- (0, import_react14.useEffect)(() => {
1126
- setCurrAppearance("light");
1127
- }, []);
1128
- const countryOptions = [
1129
- { label: "India", value: "india" },
1130
- { label: "Dubai", value: "dubai" },
1131
- { label: "Singapore", value: "singapore" },
1132
- { label: "Qatar", value: "qatar" }
1133
- ];
1134
- const toggleMenu = (menuKey) => {
1135
- setOpenMenus((prev) => {
1136
- const newSet = new Set(prev);
1137
- if (newSet.has(menuKey)) {
1138
- newSet.delete(menuKey);
1139
- } else {
1140
- newSet.add(menuKey);
1141
- }
1142
- return newSet;
1143
- });
1144
- };
1145
- const isMenuOpen = (menuKey) => {
1146
- return openMenus.has(menuKey);
1147
- };
1148
- const handleMenuClick = (item, index, e) => {
1149
- if (item.isDropDown) {
1150
- e.preventDefault();
1151
- const menuKey = `menu-${index}`;
1152
- toggleMenu(menuKey);
1153
- setActiveMenuPath(`menu-${index}`);
1154
- } else {
1155
- setActiveMenuPath(`menu-${index}`);
1156
- if (item.onClick) {
1157
- item.onClick(e);
1158
- }
1159
- closeMobileMenu();
1160
- }
1161
- };
1162
- const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
1163
- const parentMenuKey = `menu-${parentIndex}`;
1164
- setOpenMenus((prev) => {
1165
- const newSet = new Set(prev);
1166
- newSet.add(parentMenuKey);
1167
- return newSet;
1168
- });
1169
- if (option.isDropDown) {
1170
- e.preventDefault();
1171
- const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1172
- toggleMenu(menuKey);
1173
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1174
- } else {
1175
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1176
- if (option.onClick) {
1177
- option.onClick();
1178
- }
1179
- closeMobileMenu();
1180
- }
1181
- };
1182
- const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
1183
- const parentMenuKey = `menu-${parentIndex}`;
1184
- const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1185
- setOpenMenus((prev) => {
1186
- const newSet = new Set(prev);
1187
- newSet.add(parentMenuKey);
1188
- newSet.add(subMenuKey);
1189
- return newSet;
1190
- });
1191
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
1192
- if (subOption.onClick) {
1193
- subOption.onClick();
1194
- }
1195
- closeMobileMenu();
1196
- };
1197
- (0, import_react14.useEffect)(() => {
1198
- const storedAuthData = localStorage.getItem("authData");
1199
- if (storedAuthData) {
1200
- let parseData = JSON.parse(storedAuthData);
1201
- setAuthData(parseData);
1202
- }
1203
- }, [localStorage.getItem("authData")]);
1204
- (0, import_react14.useEffect)(() => {
1205
- const jettIdData = getJettIdCookieData();
1206
- if (jettIdData == null ? void 0 : jettIdData.UserName) {
1207
- setCookieUserName(jettIdData.UserName);
1208
- }
1209
- const cookieScope = getScopeFromJettIdCookie();
1210
- if (cookieScope) {
1211
- setScope(cookieScope);
1212
- }
1213
- }, []);
1214
- (0, import_react14.useEffect)(() => {
1215
- if (hasSwitchedProfileThisSession()) return;
1216
- const jettIdData = getJettIdCookieData();
1217
- const allProfiles = getProfilesFromJettIdCookie(true);
1218
- if (allProfiles.length <= 1) return;
1219
- const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
1220
- if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
1221
- switchProfile(tmcProfile).then((response) => {
1222
- var _a2;
1223
- if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
1224
- window.location.href = response.Response.RedirectUrl;
1225
- }
1226
- }).catch((error) => {
1227
- console.error("Auto TMC profile switch failed:", error);
1228
- });
1229
- }, []);
1230
- const extractUrlFromOnClick = (onClick) => {
1231
- if (!onClick || typeof onClick !== "function") return null;
1232
- const funcString = onClick.toString();
1233
- let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
1234
- if (!match) {
1235
- match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
1236
- }
1237
- if (match && match[1]) {
1238
- try {
1239
- if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
1240
- const url = new URL(match[1]);
1241
- return {
1242
- pathname: url.pathname,
1243
- search: url.search,
1244
- fullPath: url.pathname + url.search
1245
- };
1246
- }
1247
- if (match[1].startsWith("/")) {
1248
- const url = new URL(match[1], window.location.origin);
1249
- return {
1250
- pathname: url.pathname,
1251
- search: url.search,
1252
- fullPath: url.pathname + url.search
1253
- };
1254
- }
1255
- return null;
1256
- } catch {
1257
- const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
1258
- if (pathMatch) {
1259
- return {
1260
- pathname: pathMatch[1],
1261
- search: pathMatch[2] || "",
1262
- fullPath: match[1]
1263
- };
1264
- }
1265
- return null;
1266
- }
1267
- }
1268
- return null;
1269
- };
1270
- const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
1271
- if (!menuUrlData || !currentPath) return false;
1272
- const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
1273
- const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
1274
- if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
1275
- const menuParams = new URLSearchParams(menuUrlData.search);
1276
- const currentParams = new URLSearchParams(currentSearch);
1277
- const menuRole = menuParams.get("role");
1278
- const currentRole = currentParams.get("role");
1279
- if (menuRole && currentRole) {
1280
- return menuRole === currentRole;
1281
- }
1282
- if (menuRole && !currentRole || !menuRole && currentRole) {
1283
- return false;
1284
- }
1285
- return true;
1286
- }
1287
- if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
1288
- return true;
1289
- }
1290
- if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
1291
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1292
- if (currentPathParam === "supplier-list") {
1293
- return true;
1294
- }
1295
- }
1296
- if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
1297
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1298
- if (currentPathParam === "supplier-deals") {
1299
- return true;
1300
- }
1301
- }
1302
- if (normalizedMenuPath === "/corporate/trips") {
1303
- if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
1304
- return true;
1305
- }
1306
- }
1307
- if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
1308
- const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
1309
- if (menuPathParam) {
1310
- const pathRouteMap = {
1311
- "offer": "/offer/offer",
1312
- "voucher": "/voucher/voucher",
1313
- "tag": "/tags/tags",
1314
- "special-requests": "/corporate/special-requests",
1315
- "pricing-policy": "/policies/pricing-policy",
1316
- "supplier-list": "/supplier",
1317
- "users": "/users/users"
1318
- // Consumer Ecosystem Users (no role param)
1319
- };
1320
- const expectedRoute = pathRouteMap[menuPathParam];
1321
- if (expectedRoute) {
1322
- if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1323
- if (menuPathParam === "users") {
1324
- const currentParams = new URLSearchParams(currentSearch);
1325
- const currentRole = currentParams.get("role");
1326
- return currentRole !== "admin";
1327
- }
1328
- return true;
1329
- }
1330
- }
1331
- }
1332
- if (normalizedCurrentPath === "/orgselector") {
1333
- const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1334
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1335
- if (menuPathParam2 && currentPathParam) {
1336
- return menuPathParam2 === currentPathParam;
1337
- }
1338
- }
1339
- }
1340
- if (normalizedMenuPath === normalizedCurrentPath) {
1341
- if (menuUrlData.search) {
1342
- const menuParams = new URLSearchParams(menuUrlData.search);
1343
- const currentParams = new URLSearchParams(currentSearch);
1344
- for (const [key, value] of menuParams.entries()) {
1345
- if (key === "auth") {
1346
- continue;
1347
- }
1348
- if (currentParams.get(key) !== value) {
1349
- return false;
1350
- }
1351
- }
1352
- return true;
1353
- }
1354
- return true;
1355
- }
1356
- if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1357
- return true;
1358
- }
1359
- return false;
1360
- };
1361
- const navItemsLocal = navItems ?? navItemsConstant;
1362
- const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
1363
- const logoFromCookie = getLogoFromJettIdCookie();
1364
- const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1365
- const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
1366
- authData.userInfo.CDNBasePath,
1367
- authData.userInfo.OrgLogo
1368
- ) : null;
1369
- const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1370
- const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
1371
- const currentPath = window.location.pathname;
1372
- const currentSearch = window.location.search;
1373
- const newOpenMenus = /* @__PURE__ */ new Set();
1374
- let foundActivePath = null;
1375
- navItemsLocal.forEach((item, index) => {
1376
- if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1377
- const itemUrlData = extractUrlFromOnClick(item.onClick);
1378
- if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1379
- foundActivePath = `menu-${index}`;
1380
- }
1381
- }
1382
- if (item.options && item.options.length > 0) {
1383
- item.options.forEach((option, optionsIndex) => {
1384
- if (option.onClick && typeof option.onClick === "function") {
1385
- const optionUrlData = extractUrlFromOnClick(option.onClick);
1386
- if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1387
- const menuKey = `menu-${index}`;
1388
- newOpenMenus.add(menuKey);
1389
- foundActivePath = `menu-${index}-option-${optionsIndex}`;
1390
- if (option.options && option.options.length > 0) {
1391
- option.options.forEach((subOption, subIndex) => {
1392
- const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1393
- if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1394
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1395
- newOpenMenus.add(subMenuKey);
1396
- foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1397
- }
1398
- });
1399
- }
1400
- }
1401
- }
1402
- });
1403
- }
1404
- });
1405
- if (foundActivePath) {
1406
- setOpenMenus(newOpenMenus);
1407
- setActiveMenuPath(foundActivePath);
1408
- }
1409
- }, [navItemsLocal]);
1410
- const [currentUrl, setCurrentUrl] = (0, import_react14.useState)(
1411
- () => window.location.pathname + window.location.search
1412
- );
1413
- (0, import_react14.useEffect)(() => {
1414
- detectAndSetActiveMenu();
1415
- setCurrentUrl(window.location.pathname + window.location.search);
1416
- }, [detectAndSetActiveMenu]);
1417
- (0, import_react14.useEffect)(() => {
1418
- let lastUrl = window.location.pathname + window.location.search;
1419
- const handleLocationChange = () => {
1420
- const newUrl = window.location.pathname + window.location.search;
1421
- if (newUrl !== lastUrl) {
1422
- lastUrl = newUrl;
1423
- setCurrentUrl(newUrl);
1424
- detectAndSetActiveMenu();
1425
- }
1426
- };
1427
- window.addEventListener("popstate", handleLocationChange);
1428
- const checkInterval = setInterval(() => {
1429
- const newUrl = window.location.pathname + window.location.search;
1430
- if (newUrl !== lastUrl) {
1431
- handleLocationChange();
1432
- }
1433
- }, 250);
1434
- return () => {
1435
- window.removeEventListener("popstate", handleLocationChange);
1436
- clearInterval(checkInterval);
1437
- };
1438
- }, [detectAndSetActiveMenu]);
1439
- (0, import_react14.useEffect)(() => {
1440
- detectAndSetActiveMenu();
1441
- }, [currentUrl, detectAndSetActiveMenu]);
1442
- const toggleMobileMenu = () => {
1443
- setIsMobileMenuOpen(!isMobileMenuOpen);
1444
- };
1445
- const closeMobileMenu = () => {
1446
- setIsMobileMenuOpen(false);
1447
- };
1448
- return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
1449
- "button",
1450
- {
1451
- onClick: toggleMobileMenu,
1452
- className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
1453
- "aria-label": "Toggle menu",
1454
- id: `${id}-button-1`
1455
- },
1456
- isMobileMenuOpen ? /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
1457
- ), /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
1458
- "img",
1459
- {
1460
- src: sideBarLogoLocal,
1461
- alt: "sidebarLogo",
1462
- width: 208,
1463
- height: 40,
1464
- className: "object-contain",
1465
- id: `${id}-img-1`
1466
- }
1467
- )), /* @__PURE__ */ import_react14.default.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement(
1468
- "div",
1469
- {
1470
- className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1471
- onClick: closeMobileMenu,
1472
- id: `${id}-div-4`
1473
- }
1474
- ), /* @__PURE__ */ import_react14.default.createElement(
1475
- "div",
1476
- {
1477
- 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"}`,
1478
- id: `${id}-div-5`
1479
- },
1480
- /* @__PURE__ */ import_react14.default.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
1481
- "img",
1482
- {
1483
- src: sideBarLogoLocal,
1484
- alt: "sidebarLogo",
1485
- width: 108,
1486
- height: 40,
1487
- className: "object-contain",
1488
- id: `${id}-img-2`
1489
- }
1490
- ))),
1491
- /* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
1492
- /* @__PURE__ */ import_react14.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1493
- const menuKey = `menu-${index}`;
1494
- const isOpen = isMenuOpen(menuKey);
1495
- const isActive = activeMenuPath === menuKey;
1496
- return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ import_react14.default.createElement(
1497
- "div",
1498
- {
1499
- 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]" : ""}`,
1500
- onClick: (e) => handleMenuClick(item, index, e),
1501
- id: `${id}-div-12`
1502
- },
1503
- /* @__PURE__ */ import_react14.default.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ import_react14.default.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
1504
- /* @__PURE__ */ import_react14.default.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
1505
- item.isDropDown && /* @__PURE__ */ import_react14.default.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1506
- ), item.options && item.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
1507
- "div",
1508
- {
1509
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1510
- id: `${id}-div-15`
1511
- },
1512
- item.options.map((options, optionsIndex) => {
1513
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1514
- const isSubMenuOpen = isMenuOpen(subMenuKey);
1515
- const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1516
- const isDisabled = options.isDisabled;
1517
- return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
1518
- "div",
1519
- {
1520
- className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
1521
- onClick: (e) => {
1522
- if (isDisabled) {
1523
- e.preventDefault();
1524
- return;
1525
- }
1526
- handleSubMenuClick(options, optionsIndex, index, e);
1527
- },
1528
- id: `${id}-div-17-${optionsIndex}`
1529
- },
1530
- /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
1531
- /* @__PURE__ */ import_react14.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
1532
- options.isDropDown && /* @__PURE__ */ import_react14.default.createElement(
1533
- "div",
1534
- {
1535
- className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
1536
- id: `${id}-div-19-${optionsIndex}`
1537
- },
1538
- /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1539
- )
1540
- ), options.options && options.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
1541
- "div",
1542
- {
1543
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1544
- id: `${id}-div-20-${optionsIndex}`
1545
- },
1546
- options.options.map((subOption, subIndex) => {
1547
- const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1548
- return /* @__PURE__ */ import_react14.default.createElement(
1549
- "div",
1550
- {
1551
- key: subIndex,
1552
- 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]" : ""}`,
1553
- onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
1554
- id: `${id}-div-21-${subIndex}`
1555
- },
1556
- subOption.label
1557
- );
1558
- })
1559
- ));
1560
- })
1561
- ));
1562
- }))),
1563
- /* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
1564
- "div",
1565
- {
1566
- className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1567
- onClick: () => setIsSwitchProfileOpen((prev) => !prev),
1568
- id: `${id}-div-23`
1569
- },
1570
- /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ import_react14.default.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ import_react14.default.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
1571
- /* @__PURE__ */ import_react14.default.createElement(
1572
- "span",
1573
- {
1574
- className: "text-gray-600 dark:text-gray-400",
1575
- id: `${id}-span-switch`
1576
- },
1577
- /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronRight, { width: 20, height: 22 })
1578
- )
1579
- ), /* @__PURE__ */ import_react14.default.createElement(
1580
- SwitchProfileSection,
1581
- {
1582
- id: `${id}-switch-profile`,
1583
- open: isSwitchProfileOpen,
1584
- anchorRef: profileCardRef,
1585
- onClose: () => setIsSwitchProfileOpen(false),
1586
- onManageProfile: () => {
1587
- setIsSwitchProfileOpen(false);
1588
- window.location.href = "/profile";
1589
- },
1590
- onProfileSwitch: (profile) => {
1591
- setIsSwitchProfileOpen(false);
1592
- onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
1593
- },
1594
- onTmcSettings: () => {
1595
- setIsSwitchProfileOpen(false);
1596
- onTmcSettings == null ? void 0 : onTmcSettings();
1597
- },
1598
- onLogout: () => {
1599
- setIsSwitchProfileOpen(false);
1600
- clearProfileSwitchFlag();
1601
- if (onLogout) {
1602
- onLogout();
1603
- } else {
1604
- window.location.href = `${window.location.origin}/login/logout`;
1605
- }
1606
- }
1607
- }
1608
- ))
1609
- ));
1610
- };
1611
-
1612
- // src/RightSheet/RightSheet.jsx
1613
- var import_react15 = __toESM(require("react"));
1614
- var RightSheet = ({
1615
- id = "right-sheet",
1616
- open,
1617
- setOpen,
1618
- children,
1619
- callBack,
1620
- actionLabel = "Save",
1621
- onAction = () => {
1622
- },
1623
- showFooter = true
1624
- }) => {
1625
- const [visible, setVisible] = (0, import_react15.useState)(open);
1626
- (0, import_react15.useEffect)(() => {
1627
- if (open) {
1628
- document.body.style.overflow = "hidden";
1629
- setVisible(true);
1630
- }
1631
- return () => {
1632
- document.body.style.overflow = "auto";
1633
- };
1634
- }, [open]);
1635
- const handleClose = () => {
1636
- setVisible(false);
1637
- setTimeout(() => {
1638
- setOpen(false);
1639
- callBack();
1640
- }, 200);
1641
- };
1642
- const handleAction = () => {
1643
- onAction();
1644
- handleClose();
1645
- };
1646
- if (!visible) return null;
1647
- return /* @__PURE__ */ import_react15.default.createElement(
1648
- "div",
1649
- {
1650
- className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1651
- onClick: handleClose,
1652
- id: `${id}-div-1`
1653
- },
1654
- /* @__PURE__ */ import_react15.default.createElement(
1655
- "div",
1656
- {
1657
- className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1658
- ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1659
- onClick: (e) => e.stopPropagation(),
1660
- id: `${id}-div-2`
1661
- },
1662
- /* @__PURE__ */ import_react15.default.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1663
- showFooter && /* @__PURE__ */ import_react15.default.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1664
- )
1665
- );
1666
- };
1667
-
1668
- // src/Table/CustomTable.jsx
1669
- var import_react16 = __toESM(require("react"));
1670
- var CustomTable = ({
1671
- id = "custom-table",
1672
- tableHeader,
1673
- setIsAllChecked,
1674
- isAllChecked,
1675
- children,
1676
- isHideCheckbox = "false"
1677
- }) => {
1678
- return /* @__PURE__ */ import_react16.default.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ import_react16.default.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ import_react16.default.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ import_react16.default.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ import_react16.default.createElement(
1679
- "tr",
1680
- {
1681
- className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1682
- id: `${id}-tr-1`
1683
- },
1684
- !isHideCheckbox && /* @__PURE__ */ import_react16.default.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ import_react16.default.createElement(
1685
- CustomCheckbox,
1686
- {
1687
- checked: isAllChecked,
1688
- onChange: () => {
1689
- setIsAllChecked(!isAllChecked);
1690
- },
1691
- id: `${id}-custom-checkbox-1`
1692
- }
1693
- )),
1694
- tableHeader.map((header, index) => {
1695
- return /* @__PURE__ */ import_react16.default.createElement(
1696
- "th",
1697
- {
1698
- className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1699
- key: header + index,
1700
- id: `${id}-th-2-${index}`
1701
- },
1702
- header
1703
- );
1704
- })
1705
- )), /* @__PURE__ */ import_react16.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1706
- };
1707
-
1708
- // src/inputs/Dropdown.jsx
1709
- var import_react17 = __toESM(require("react"));
1710
- var import_react_select = __toESM(require("react-select"));
1711
- var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
1712
- function buildStyles(isDark, error) {
1713
- return {
1714
- control: (base, state) => ({
1715
- ...base,
1716
- minHeight: "40px !important",
1717
- fontSize: 14,
1718
- borderRadius: "6px",
1719
- boxShadow: "none",
1720
- backgroundColor: state.isDisabled ? "#f3f4f6" : error ? "#fef2f2" : isDark ? "#18181b" : "#ffffff",
1721
- borderColor: state.isDisabled ? "#d1d5db" : error ? "#ef4444" : isDark ? "#303036" : "#e5e5e5",
1722
- outline: state.isFocused ? "2px solid #000" : "none",
1723
- outlineOffset: "2px",
1724
- "&:hover": {
1725
- borderColor: error ? "#ef4444" : "none"
1726
- }
1727
- }),
1728
- menu: (base) => ({
1729
- ...base,
1730
- backgroundColor: isDark ? "#18181b" : "#ffffff",
1731
- zIndex: 9999
1732
- }),
1733
- menuPortal: (base) => ({ ...base, zIndex: 9999 }),
1734
- option: (base, state) => ({
1735
- ...base,
1736
- fontSize: 14,
1737
- cursor: "pointer",
1738
- backgroundColor: state.isSelected ? "#0087FA" : state.isFocused ? isDark ? "#303036" : "#EBF5FF" : "transparent",
1739
- color: state.isSelected ? "#ffffff" : isDark ? "#f3f4f6" : "#111827",
1740
- "&:active": { backgroundColor: "#0087FA", color: "#ffffff" }
1741
- }),
1742
- singleValue: (base, state) => ({
1743
- ...base,
1744
- fontSize: 14,
1745
- fontWeight: 400,
1746
- color: state.isDisabled ? "#6b7280" : isDark ? "#f3f4f6" : "#111827"
1747
- }),
1748
- multiValue: (base) => ({
1749
- ...base,
1750
- backgroundColor: isDark ? "#303036" : "#EBF5FF"
1751
- }),
1752
- multiValueLabel: (base) => ({
1753
- ...base,
1754
- fontSize: 12,
1755
- color: isDark ? "#f3f4f6" : "#0087FA"
1756
- }),
1757
- multiValueRemove: (base) => ({
1758
- ...base,
1759
- color: isDark ? "#9ca3af" : "#0087FA",
1760
- "&:hover": { backgroundColor: "#0087FA", color: "#ffffff" }
1761
- }),
1762
- placeholder: (base) => ({
1763
- ...base,
1764
- fontSize: 14,
1765
- fontWeight: 400,
1766
- color: "#6b7280"
1767
- }),
1768
- input: (base) => ({
1769
- ...base,
1770
- fontSize: 14,
1771
- fontWeight: 400,
1772
- color: isDark ? "#f3f4f6" : "#111827"
1773
- }),
1774
- indicatorSeparator: () => ({ display: "none" }),
1775
- dropdownIndicator: (base) => ({
1776
- ...base,
1777
- padding: "0 6px",
1778
- color: isDark ? "#9ca3af" : "#6b7280"
1779
- }),
1780
- clearIndicator: (base) => ({
1781
- ...base,
1782
- padding: "0 4px",
1783
- color: isDark ? "#9ca3af" : "#6b7280",
1784
- cursor: "pointer",
1785
- "&:hover": { color: "#0087FA" }
1786
- }),
1787
- valueContainer: (base) => ({ ...base, padding: "2px 16px" })
1788
- };
1789
- }
1790
- var Dropdown = import_react17.default.forwardRef(
1791
- ({
1792
- id = "dropdown",
1793
- options,
1794
- placeholder = "Select...",
1795
- isDisabled = false,
1796
- isClearable = true,
1797
- isLoading = false,
1798
- error = false,
1799
- label,
1800
- heading,
1801
- isRequired = false,
1802
- name,
1803
- menuPortalTarget,
1804
- menuPosition = "absolute",
1805
- className,
1806
- style,
1807
- isMulti = false,
1808
- value,
1809
- onChange
1810
- }, ref) => {
1811
- const reactId = (0, import_react17.useId)();
1812
- const isDark = isDarkMode();
1813
- const styles = (0, import_react17.useMemo)(() => buildStyles(isDark, !!error), [isDark, error]);
1814
- const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
1815
- const handleChange = (selected) => {
1816
- if (isMulti) {
1817
- onChange((selected ?? []).map((o) => o.value));
1818
- } else {
1819
- onChange((selected == null ? void 0 : selected.value) ?? null);
1820
- }
1821
- };
1822
- return /* @__PURE__ */ import_react17.default.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react17.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ import_react17.default.createElement(
1823
- "label",
1824
- {
1825
- htmlFor: reactId,
1826
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
1827
- id: `${id}-label-1`
1828
- },
1829
- label,
1830
- isRequired && /* @__PURE__ */ import_react17.default.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
1831
- ), /* @__PURE__ */ import_react17.default.createElement(
1832
- import_react_select.default,
1833
- {
1834
- ref,
1835
- inputId: reactId,
1836
- name,
1837
- options,
1838
- value: selectedValue,
1839
- onChange: handleChange,
1840
- placeholder,
1841
- isDisabled,
1842
- isClearable,
1843
- isLoading,
1844
- isMulti,
1845
- styles,
1846
- menuPortalTarget,
1847
- menuPosition,
1848
- classNamePrefix: "jett-dropdown"
1849
- }
1850
- ));
1851
- }
1852
- );
1853
- Dropdown.displayName = "Dropdown";
1854
-
1855
- // src/Calendar/Calendar.tsx
1856
- var import_react18 = __toESM(require("react"));
1857
- var import_dates = require("@mantine/dates");
1858
- var Calendar = (props) => {
1859
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1860
- const {
1861
- minDate,
1862
- maxDate,
1863
- excludeDate,
1864
- firstDayOfWeek = 1,
1865
- locale,
1866
- size,
1867
- className,
1868
- error
1869
- } = props;
1870
- const isRange = props.mode === "range";
1871
- const isDateTime = props.mode === "datetime";
1872
- const datesProviderSettings = {
1873
- firstDayOfWeek,
1874
- consistentWeeks: true
1875
- };
1876
- if (locale) {
1877
- datesProviderSettings.locale = locale;
1878
- }
1879
- const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
1880
- const [displayDate, setDisplayDate] = (0, import_react18.useState)(anchorDate ?? void 0);
1881
- const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
1882
- (0, import_react18.useEffect)(() => {
1883
- if (anchorTime !== void 0) {
1884
- setDisplayDate(new Date(anchorTime));
1885
- }
1886
- }, [anchorTime]);
1887
- const weekendColorStyle = {
1888
- "--mantine-color-red-6": "var(--mantine-color-text)"
1889
- };
1890
- if (isRange) {
1891
- const datePickerProps2 = {
1892
- type: "range",
1893
- value: props.value,
1894
- defaultValue: props.defaultValue,
1895
- onChange: props.onChange,
1896
- minDate,
1897
- maxDate,
1898
- excludeDate,
1899
- size,
1900
- className,
1901
- date: displayDate,
1902
- onDateChange: setDisplayDate,
1903
- style: weekendColorStyle
1904
- };
1905
- return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DatePicker, { ...datePickerProps2 }));
1906
- }
1907
- if (isDateTime) {
1908
- const dateTimePickerProps = {
1909
- value: props.value,
1910
- defaultValue: props.defaultValue,
1911
- onChange: props.onChange,
1912
- minDate,
1913
- maxDate,
1914
- excludeDate,
1915
- size,
1916
- className,
1917
- error,
1918
- style: weekendColorStyle
1919
- };
1920
- return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DateTimePicker, { ...dateTimePickerProps }));
1921
- }
1922
- const datePickerProps = {
1923
- value: props.value,
1924
- defaultValue: props.defaultValue,
1925
- onChange: props.onChange,
1926
- minDate,
1927
- maxDate,
1928
- excludeDate,
1929
- size,
1930
- className,
1931
- date: displayDate,
1932
- onDateChange: setDisplayDate,
1933
- style: weekendColorStyle
1934
- };
1935
- return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DatePicker, { ...datePickerProps }));
1936
- };
1937
-
1938
- // src/Pagination/Pagination.jsx
1939
- var import_react19 = __toESM(require("react"));
1940
- var import_lucide_react9 = require("lucide-react");
1941
- var Pagination = ({
1942
- id = "pagination",
1943
- data = [],
1944
- component: Component,
1945
- itemsPerPage = 6,
1946
- itemsPerPageOptions = [5, 10, 20, 50, 100],
1947
- // Controlled props (optional)
1948
- currentPage: controlledCurrentPage,
1949
- onPageChange: controlledOnPageChange,
1950
- onItemsPerPageChange: controlledOnItemsPerPageChange,
1951
- // Legacy props for backward compatibility
1952
- totalPages,
1953
- totalItems: legacyTotalItems,
1954
- onPageChange: legacyOnPageChange,
1955
- onItemsPerPageChange: legacyOnItemsPerPageChange,
1956
- tableHeader,
1957
- isHideCheckbox,
1958
- callback,
1959
- isTable = false,
1960
- // Component props - any additional props to pass to the component
1961
- componentProps = {},
1962
- ...restProps
1963
- }) => {
1964
- const [internalCurrentPage, setInternalCurrentPage] = (0, import_react19.useState)(1);
1965
- const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react19.useState)(itemsPerPage);
1966
- const isControlled = controlledCurrentPage !== void 0;
1967
- const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1968
- const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1969
- const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1970
- const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1971
- const calculatedTotalPages = (0, import_react19.useMemo)(() => {
1972
- if (totalItems > 0 && activeItemsPerPage > 0) {
1973
- return Math.ceil(totalItems / activeItemsPerPage);
1974
- }
1975
- return 1;
1976
- }, [totalItems, activeItemsPerPage]);
1977
- const paginatedData = (0, import_react19.useMemo)(() => {
1978
- if (!data || data.length === 0) return [];
1979
- const startIndex = (currentPage - 1) * activeItemsPerPage;
1980
- const endIndex = startIndex + activeItemsPerPage;
1981
- return data.slice(startIndex, endIndex);
1982
- }, [data, currentPage, activeItemsPerPage]);
1983
- (0, import_react19.useEffect)(() => {
1984
- if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1985
- setInternalCurrentPage(1);
1986
- }
1987
- }, [calculatedTotalPages, isControlled, currentPage]);
1988
- const getPageNumbers = () => {
1989
- const pages = [];
1990
- const maxVisible = 5;
1991
- let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1992
- let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1993
- if (endPage - startPage < maxVisible - 1) {
1994
- startPage = Math.max(1, endPage - maxVisible + 1);
1995
- }
1996
- for (let i = startPage; i <= endPage; i++) {
1997
- pages.push(i);
1998
- }
1999
- return pages;
2000
- };
2001
- const handlePageChange = (page) => {
2002
- if (page >= 1 && page <= calculatedTotalPages) {
2003
- if (isControlled && controlledOnPageChange) {
2004
- controlledOnPageChange(page);
2005
- } else if (legacyOnPageChange) {
2006
- legacyOnPageChange(page);
2007
- } else {
2008
- setInternalCurrentPage(page);
2009
- }
2010
- }
2011
- };
2012
- const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
2013
- const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
2014
- const renderContent = () => {
2015
- if (Component) {
2016
- if (import_react19.default.isValidElement(Component)) {
2017
- const ComponentType = Component.type;
2018
- const elementProps = Component.props;
2019
- if (isTable) {
2020
- return /* @__PURE__ */ import_react19.default.createElement(
2021
- CustomTable,
2022
- {
2023
- tableHeader,
2024
- isHideCheckbox,
2025
- id: `${id}-custom-table-1`
2026
- },
2027
- data.map((item, index) => {
2028
- return /* @__PURE__ */ import_react19.default.createElement(
2029
- ComponentType,
2030
- {
2031
- key: item.id || item._id || index,
2032
- data: item,
2033
- ...elementProps,
2034
- ...componentProps,
2035
- ...restProps,
2036
- id: `${id}-component-type-1-${index}`
2037
- }
2038
- );
2039
- })
2040
- );
2041
- } else {
2042
- if (isTable) {
2043
- return /* @__PURE__ */ import_react19.default.createElement(
2044
- CustomTable,
2045
- {
2046
- tableHeader,
2047
- isHideCheckbox,
2048
- id: `${id}-custom-table-2`
2049
- },
2050
- paginatedData.map((item, index) => {
2051
- return /* @__PURE__ */ import_react19.default.createElement(
2052
- ComponentType,
2053
- {
2054
- key: item.id || item._id || index,
2055
- data: item,
2056
- ...elementProps,
2057
- ...componentProps,
2058
- ...restProps,
2059
- id: `${id}-component-type-2-${index}`
2060
- }
2061
- );
2062
- })
2063
- );
2064
- }
2065
- }
2066
- } else {
2067
- return /* @__PURE__ */ import_react19.default.createElement(
2068
- CustomTable,
2069
- {
2070
- tableHeader,
2071
- isHideCheckbox,
2072
- id: `${id}-custom-table-3`
2073
- },
2074
- paginatedData.map((item, index) => {
2075
- return /* @__PURE__ */ import_react19.default.createElement(
2076
- Component,
2077
- {
2078
- key: item.id || item._id || index,
2079
- data: item,
2080
- ...componentProps,
2081
- ...restProps,
2082
- id: `${id}-component-1-${index}`
2083
- }
2084
- );
2085
- })
2086
- );
2087
- }
2088
- }
2089
- return null;
2090
- };
2091
- return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react19.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react19.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react19.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react19.default.createElement(
2092
- "button",
2093
- {
2094
- onClick: () => handlePageChange(1),
2095
- disabled: currentPage === 1,
2096
- 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]"}`,
2097
- title: "First page",
2098
- id: `${id}-button-1`
2099
- },
2100
- /* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronsLeft, { size: 16 })
2101
- ), /* @__PURE__ */ import_react19.default.createElement(
2102
- "button",
2103
- {
2104
- onClick: () => handlePageChange(currentPage - 1),
2105
- disabled: currentPage === 1,
2106
- 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]"}`,
2107
- title: "Previous page",
2108
- id: `${id}-button-2`
2109
- },
2110
- /* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronLeft, { size: 16 })
2111
- ), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react19.default.createElement(
2112
- "button",
2113
- {
2114
- key: pageNum,
2115
- onClick: () => handlePageChange(pageNum),
2116
- 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]"}`,
2117
- id: `${id}-button-3`
2118
- },
2119
- pageNum
2120
- )), /* @__PURE__ */ import_react19.default.createElement(
2121
- "button",
2122
- {
2123
- onClick: () => handlePageChange(currentPage + 1),
2124
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2125
- 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]"}`,
2126
- title: "Next page",
2127
- id: `${id}-button-4`
2128
- },
2129
- /* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronRight, { size: 16 })
2130
- ), /* @__PURE__ */ import_react19.default.createElement(
2131
- "button",
2132
- {
2133
- onClick: () => handlePageChange(calculatedTotalPages),
2134
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2135
- 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]"}`,
2136
- title: "Last page",
2137
- id: `${id}-button-5`
2138
- },
2139
- /* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronsRight, { size: 16 })
2140
- ))));
2141
- };
2142
- // Annotate the CommonJS export names for ESM import in node:
2143
- 0 && (module.exports = {
2144
- AppSideBar,
2145
- Calendar,
2146
- Chip,
2147
- CustomAutocomplete,
2148
- CustomButton,
2149
- CustomCheckbox,
2150
- CustomInput,
2151
- CustomSearch,
2152
- CustomSelect,
2153
- CustomSwitch,
2154
- CustomTable,
2155
- CustomTextarea,
2156
- CustomUpload,
2157
- Dropdown,
2158
- Pagination,
2159
- ProgressBar,
2160
- RightSheet
2161
- });
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.js
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ AppSideBar: () => AppSideBar,
33
+ Calendar: () => Calendar,
34
+ Chip: () => Chip,
35
+ CustomAutocomplete: () => CustomAutocomplete,
36
+ CustomButton: () => CustomButton,
37
+ CustomCheckbox: () => CustomCheckbox,
38
+ CustomInput: () => CustomInput,
39
+ CustomSearch: () => CustomSearch,
40
+ CustomSelect: () => CustomSelect,
41
+ CustomSwitch: () => CustomSwitch,
42
+ CustomTable: () => CustomTable,
43
+ CustomTextarea: () => CustomTextarea,
44
+ CustomUpload: () => CustomUpload,
45
+ Dropdown: () => Dropdown,
46
+ Pagination: () => Pagination,
47
+ ProgressBar: () => ProgressBar,
48
+ RightSheet: () => RightSheet
49
+ });
50
+ module.exports = __toCommonJS(index_exports);
51
+
52
+ // src/utils/cn.ts
53
+ var import_clsx = require("clsx");
54
+ var import_tailwind_merge = require("tailwind-merge");
55
+ function cn(...inputs) {
56
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
57
+ }
58
+
59
+ // src/Button.jsx
60
+ var import_react = __toESM(require("react"));
61
+ var variantStyles = {
62
+ PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
63
+ SECONDARY: "bg-primary text-white dark:text-white",
64
+ DEFAULT: "bg-white text-black dark:text-white",
65
+ DANGER: "bg-[#ef4444] text-white dark:text-white"
66
+ };
67
+ var CustomButton = ({
68
+ id = "button",
69
+ variant = "DEFAULT",
70
+ children,
71
+ className,
72
+ onClick,
73
+ disabled = false,
74
+ icon
75
+ }) => {
76
+ return /* @__PURE__ */ import_react.default.createElement(
77
+ "div",
78
+ {
79
+ className: cn(
80
+ `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`,
81
+ variantStyles[variant],
82
+ className
83
+ ),
84
+ onClick,
85
+ id: `${id}-div-1`
86
+ },
87
+ icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
88
+ children
89
+ );
90
+ };
91
+
92
+ // src/inputs/Autocomplete.jsx
93
+ var import_react2 = __toESM(require("react"));
94
+ var import_lucide_react = require("lucide-react");
95
+ var CustomAutocomplete = ({
96
+ id = "autocomplete",
97
+ label,
98
+ value,
99
+ onChange,
100
+ options,
101
+ placeholder = "Search & select...",
102
+ isRequired = false,
103
+ error,
104
+ heading,
105
+ disabled = false
106
+ }) => {
107
+ const [open, setOpen] = (0, import_react2.useState)(false);
108
+ const [search, setSearch] = (0, import_react2.useState)("");
109
+ const wrapperRef = (0, import_react2.useRef)(null);
110
+ const selectedOptions = options.filter((opt) => value.includes(opt.value));
111
+ const handleBlur = (e) => {
112
+ var _a;
113
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
114
+ setOpen(false);
115
+ }
116
+ };
117
+ const filteredOptions = options.filter(
118
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
119
+ );
120
+ const toggleValue = (val) => {
121
+ if (value.includes(val)) {
122
+ onChange(value.filter((v) => v !== val));
123
+ } else {
124
+ onChange([...value, val]);
125
+ }
126
+ };
127
+ return /* @__PURE__ */ import_react2.default.createElement(
128
+ "div",
129
+ {
130
+ className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
131
+ ref: wrapperRef,
132
+ tabIndex: disabled ? -1 : 0,
133
+ onBlur: handleBlur,
134
+ id: `${id}-div-1`
135
+ },
136
+ heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
137
+ label && /* @__PURE__ */ import_react2.default.createElement(
138
+ "label",
139
+ {
140
+ className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
141
+ id: `${id}-label-1`
142
+ },
143
+ label,
144
+ " ",
145
+ isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
146
+ ),
147
+ /* @__PURE__ */ import_react2.default.createElement(
148
+ "div",
149
+ {
150
+ onClick: () => {
151
+ if (!disabled) setOpen((prev) => !prev);
152
+ },
153
+ 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
154
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
155
+ ${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"}
156
+ `,
157
+ id: `${id}-div-2`
158
+ },
159
+ /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
160
+ "span",
161
+ {
162
+ key: opt.value,
163
+ 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",
164
+ id: `${id}-span-2`
165
+ },
166
+ opt.label,
167
+ /* @__PURE__ */ import_react2.default.createElement(
168
+ "button",
169
+ {
170
+ onClick: (e) => {
171
+ e.stopPropagation();
172
+ toggleValue(opt.value);
173
+ },
174
+ className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
175
+ id: `${id}-button-1`
176
+ },
177
+ "\u2715"
178
+ )
179
+ )) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
180
+ /* @__PURE__ */ import_react2.default.createElement(
181
+ import_lucide_react.ChevronDown,
182
+ {
183
+ className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
184
+ }
185
+ )
186
+ ),
187
+ !disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
188
+ "input",
189
+ {
190
+ type: "text",
191
+ value: search,
192
+ onChange: (e) => setSearch(e.target.value),
193
+ placeholder: "Search...",
194
+ className: "flex-1 text-sm focus:outline-none",
195
+ id: `${id}-input-1`
196
+ }
197
+ )), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
198
+ const selected = value.includes(opt.value);
199
+ return /* @__PURE__ */ import_react2.default.createElement(
200
+ "li",
201
+ {
202
+ key: opt.value,
203
+ onClick: () => toggleValue(opt.value),
204
+ 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" : ""}`,
205
+ id: `${id}-li-1`
206
+ },
207
+ /* @__PURE__ */ import_react2.default.createElement(
208
+ "span",
209
+ {
210
+ 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"}`,
211
+ id: `${id}-span-4`
212
+ },
213
+ selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
214
+ ),
215
+ opt.label
216
+ );
217
+ }) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
218
+ );
219
+ };
220
+
221
+ // src/inputs/Checkbox.jsx
222
+ var import_react3 = __toESM(require("react"));
223
+ var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
224
+ const handleChange = (e) => {
225
+ onChange(e.target.checked);
226
+ };
227
+ return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
228
+ "input",
229
+ {
230
+ type: "checkbox",
231
+ checked,
232
+ onChange: handleChange,
233
+ className: "peer hidden",
234
+ id: `${id}-input-1`
235
+ }
236
+ ), /* @__PURE__ */ import_react3.default.createElement(
237
+ "span",
238
+ {
239
+ 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 ",
240
+ id: `${id}-span-1`
241
+ },
242
+ checked && /* @__PURE__ */ import_react3.default.createElement(
243
+ "svg",
244
+ {
245
+ className: "w-4 h-4 text-white",
246
+ fill: "none",
247
+ stroke: "currentColor",
248
+ strokeWidth: "3",
249
+ viewBox: "0 0 24 24",
250
+ id: `${id}-svg-1`
251
+ },
252
+ /* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
253
+ )
254
+ ));
255
+ };
256
+
257
+ // src/inputs/Chip.jsx
258
+ var import_react4 = __toESM(require("react"));
259
+ var VARIANTS = {
260
+ PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
261
+ GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
262
+ RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
263
+ YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
264
+ };
265
+ var Chip = ({ id = "chip", label, variant }) => {
266
+ return /* @__PURE__ */ import_react4.default.createElement(
267
+ "div",
268
+ {
269
+ className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
270
+ id: `${id}-div-1`
271
+ },
272
+ label
273
+ );
274
+ };
275
+
276
+ // src/inputs/CustomSwitch.jsx
277
+ var import_react5 = __toESM(require("react"));
278
+ var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
279
+ return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
280
+ "button",
281
+ {
282
+ type: "button",
283
+ role: "switch",
284
+ "aria-checked": checked,
285
+ onClick: () => onChange(!checked),
286
+ className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
287
+ id: `${id}-button-1`
288
+ },
289
+ /* @__PURE__ */ import_react5.default.createElement(
290
+ "span",
291
+ {
292
+ className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
293
+ id: `${id}-span-1`
294
+ }
295
+ )
296
+ ), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
297
+ };
298
+
299
+ // src/inputs/Input.jsx
300
+ var import_react6 = __toESM(require("react"));
301
+ var CustomInput = ({
302
+ id = "input",
303
+ label,
304
+ isRequired,
305
+ value,
306
+ onChange,
307
+ placeholder,
308
+ disabled = false,
309
+ error,
310
+ heading
311
+ }) => {
312
+ return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
313
+ "label",
314
+ {
315
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
316
+ id: `${id}-label-1`
317
+ },
318
+ label,
319
+ " ",
320
+ isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
321
+ ), /* @__PURE__ */ import_react6.default.createElement(
322
+ "input",
323
+ {
324
+ className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
325
+ placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
326
+ focus:outline-2 outline-black dark:outline-white outline-offset-2
327
+ dark:bg-transparent dark:text-white dark:border-[#303036]
328
+ ${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%)]"}
329
+ `,
330
+ value,
331
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
332
+ placeholder,
333
+ disabled,
334
+ readOnly: disabled,
335
+ id: `${id}-input-1`
336
+ }
337
+ ));
338
+ };
339
+
340
+ // src/inputs/ProgressBar.jsx
341
+ var import_react7 = __toESM(require("react"));
342
+ var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
343
+ const progress = step / totalSteps * 100;
344
+ return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
345
+ "div",
346
+ {
347
+ className: "bg-black h-2 rounded-full transition-all duration-300",
348
+ style: { width: `${progress}%` },
349
+ id: `${id}-div-3`
350
+ }
351
+ )));
352
+ };
353
+
354
+ // src/inputs/Search.jsx
355
+ var import_react8 = __toESM(require("react"));
356
+ var import_lucide_react2 = require("lucide-react");
357
+ var CustomSearch = ({
358
+ id = "search",
359
+ value,
360
+ onChange,
361
+ placeholder = "Search Markets..."
362
+ }) => {
363
+ return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
364
+ "input",
365
+ {
366
+ type: "text",
367
+ value,
368
+ onChange,
369
+ placeholder,
370
+ className: "bg-transparent w-full h-full focus:outline-none",
371
+ id: `${id}-input-1`
372
+ }
373
+ ));
374
+ };
375
+
376
+ // src/inputs/TextArea.jsx
377
+ var import_react9 = __toESM(require("react"));
378
+ var CustomTextarea = ({
379
+ id = "text-area",
380
+ label,
381
+ isRequired,
382
+ value,
383
+ onChange,
384
+ placeholder,
385
+ disabled = false,
386
+ error,
387
+ heading,
388
+ rows = 4
389
+ }) => {
390
+ return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
391
+ "label",
392
+ {
393
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
394
+ id: `${id}-label-1`
395
+ },
396
+ label,
397
+ " ",
398
+ isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
399
+ ), /* @__PURE__ */ import_react9.default.createElement(
400
+ "textarea",
401
+ {
402
+ rows,
403
+ className: `border rounded-md px-4 py-2 w-full text-[14px]
404
+ focus:outline-2 focus:outline-black focus:outline-offset-2
405
+ focus:ring-0 focus:shadow-none focus:border-black
406
+ ${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%)]"}
407
+ `,
408
+ value,
409
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
410
+ placeholder,
411
+ disabled,
412
+ readOnly: disabled,
413
+ id: `${id}-textarea-1`
414
+ }
415
+ ));
416
+ };
417
+
418
+ // src/inputs/Upload.jsx
419
+ var import_react10 = __toESM(require("react"));
420
+ var import_lucide_react3 = require("lucide-react");
421
+ var CustomUpload = ({
422
+ id = "upload",
423
+ label = "Supporting documents",
424
+ description = "Drop items here or Browse Files",
425
+ accept = ".pdf,.jpg,.jpeg,.png",
426
+ maxSizeMB = 5,
427
+ onChange,
428
+ error,
429
+ value
430
+ }) => {
431
+ const inputRef = (0, import_react10.useRef)(null);
432
+ const handleFileSelect = (files) => {
433
+ if (!files || files.length === 0) return;
434
+ const selectedFile = files[0];
435
+ if (selectedFile.size > maxSizeMB * 1024 * 1024) {
436
+ alert(`File size must be less than ${maxSizeMB} MB`);
437
+ return;
438
+ }
439
+ onChange == null ? void 0 : onChange(selectedFile);
440
+ };
441
+ return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
442
+ "div",
443
+ {
444
+ className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
445
+ ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
446
+ onClick: () => {
447
+ var _a;
448
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
449
+ },
450
+ onDragOver: (e) => e.preventDefault(),
451
+ onDrop: (e) => {
452
+ e.preventDefault();
453
+ handleFileSelect(e.dataTransfer.files);
454
+ },
455
+ id: `${id}-div-2`
456
+ },
457
+ /* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
458
+ /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
459
+ /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
460
+ /* @__PURE__ */ import_react10.default.createElement(
461
+ "input",
462
+ {
463
+ ref: inputRef,
464
+ type: "file",
465
+ accept,
466
+ className: "hidden",
467
+ onChange: (e) => handleFileSelect(e.target.files),
468
+ id: `${id}-input-1`
469
+ }
470
+ )
471
+ ), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
472
+ };
473
+
474
+ // src/sideBar/SideBar.jsx
475
+ var import_react14 = __toESM(require("react"));
476
+
477
+ // ConstantUI.js
478
+ var import_lucide_react4 = require("lucide-react");
479
+ var encodedAuthData = localStorage.getItem("encodedAuthData");
480
+ var navItemsConstant = [
481
+ {
482
+ Icon: import_lucide_react4.Home,
483
+ label: "Home",
484
+ onClick: () => {
485
+ window.location.href = "/";
486
+ },
487
+ isDropDown: false
488
+ },
489
+ {
490
+ Icon: import_lucide_react4.Building,
491
+ label: "Consumer Ecosystem",
492
+ onClick: () => {
493
+ },
494
+ options: [
495
+ {
496
+ label: "Corporate",
497
+ onClick: () => {
498
+ window.location.href = "/corporate/";
499
+ }
500
+ },
501
+ {
502
+ label: "Trips",
503
+ onClick: () => {
504
+ window.location.href = "/corporate/trips/";
505
+ }
506
+ },
507
+ {
508
+ label: "Users",
509
+ onClick: () => {
510
+ window.location.href = "/users/users";
511
+ }
512
+ },
513
+ {
514
+ label: "Tags (Custom Variables)",
515
+ onClick: () => {
516
+ window.location.href = "/orgselector/?path=tag";
517
+ }
518
+ },
519
+ {
520
+ label: "Special Request",
521
+ onClick: () => {
522
+ window.location.href = "/orgselector/?path=special-requests";
523
+ }
524
+ },
525
+ {
526
+ label: "Support Tickets (Coming Soon)",
527
+ isDisabled: true
528
+ // onClick: () => {},
529
+ }
530
+ ],
531
+ isDropDown: true
532
+ },
533
+ {
534
+ Icon: import_lucide_react4.Banknote,
535
+ label: "Finance",
536
+ onClick: () => {
537
+ },
538
+ isDropDown: true,
539
+ options: [
540
+ {
541
+ label: "Credit Management",
542
+ onClick: () => {
543
+ window.location.href = "/finance/paymentsLedger/";
544
+ }
545
+ },
546
+ {
547
+ label: "Booking & Invoices",
548
+ onClick: () => {
549
+ window.location.href = "/finance/bookingHistory/";
550
+ }
551
+ }
552
+ ]
553
+ },
554
+ {
555
+ Icon: import_lucide_react4.DollarSign,
556
+ label: "Revenue Management",
557
+ onClick: () => {
558
+ },
559
+ isDropDown: true,
560
+ options: [
561
+ {
562
+ label: "Pricing Engine",
563
+ onClick: () => {
564
+ window.location.href = "/orgselector/?path=pricing-policy";
565
+ }
566
+ },
567
+ {
568
+ label: "Offers",
569
+ onClick: () => {
570
+ window.location.href = "/orgselector/?path=offer";
571
+ }
572
+ },
573
+ {
574
+ label: "Vouchers",
575
+ onClick: () => {
576
+ window.location.href = "/orgselector/?path=voucher";
577
+ }
578
+ }
579
+ ]
580
+ },
581
+ {
582
+ Icon: import_lucide_react4.Handshake,
583
+ label: "Supplier Ecosystem",
584
+ onClick: () => {
585
+ },
586
+ isDropDown: true,
587
+ options: [
588
+ {
589
+ label: "Suppliers List",
590
+ onClick: () => {
591
+ window.location.href = "/orgselector/?path=supplier-list";
592
+ }
593
+ },
594
+ {
595
+ label: "Supplier Deals",
596
+ onClick: () => {
597
+ window.location.href = "/supplierdeals/";
598
+ }
599
+ }
600
+ ]
601
+ },
602
+ {
603
+ Icon: import_lucide_react4.BarChart3,
604
+ label: "Reports",
605
+ onClick: () => {
606
+ },
607
+ isDropDown: true,
608
+ options: [
609
+ {
610
+ label: "Reports",
611
+ onClick: () => {
612
+ window.location.href = "/reports/";
613
+ }
614
+ }
615
+ ]
616
+ },
617
+ {
618
+ Icon: import_lucide_react4.Cog,
619
+ label: "Settings",
620
+ onClick: () => {
621
+ },
622
+ isDropDown: true,
623
+ options: [
624
+ {
625
+ label: "Whitelabel",
626
+ onClick: () => {
627
+ window.location.href = "/whitelabel/";
628
+ }
629
+ },
630
+ {
631
+ label: "Markets",
632
+ onClick: () => {
633
+ window.location.href = "/market/";
634
+ }
635
+ },
636
+ {
637
+ label: "AuthMesh",
638
+ onClick: () => {
639
+ window.location.href = "/settings/authmesh";
640
+ }
641
+ },
642
+ {
643
+ label: "Audit",
644
+ onClick: () => {
645
+ window.location.href = "/market/audit";
646
+ }
647
+ },
648
+ {
649
+ label: "Users",
650
+ onClick: () => {
651
+ window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
652
+ }
653
+ },
654
+ {
655
+ label: "Reports Configurations",
656
+ onClick: () => {
657
+ window.location.href = "/reports/";
658
+ }
659
+ }
660
+ ]
661
+ }
662
+ ];
663
+ var additionalItemsConstant = [
664
+ {
665
+ Icon: import_lucide_react4.LifeBuoy,
666
+ label: "Help",
667
+ onClick: () => {
668
+ window.location.href = "/help";
669
+ }
670
+ }
671
+ ];
672
+
673
+ // src/utils/cookieHelpers.js
674
+ var JETT_ID_COOKIE_NAME = "jett-id";
675
+ function getCookie(name) {
676
+ if (typeof document === "undefined" || !document.cookie) return null;
677
+ const match = document.cookie.match(
678
+ new RegExp("(^|\\s)" + name + "=([^;]+)")
679
+ );
680
+ return match ? decodeURIComponent(match[2].trim()) : null;
681
+ }
682
+ function decodeBase64(value) {
683
+ try {
684
+ let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
685
+ const pad = base64.length % 4;
686
+ if (pad) base64 += "=".repeat(4 - pad);
687
+ return atob(base64);
688
+ } catch {
689
+ return "";
690
+ }
691
+ }
692
+ function getJettIdCookieData() {
693
+ const raw = getCookie(JETT_ID_COOKIE_NAME);
694
+ if (!raw) return null;
695
+ try {
696
+ const decoded = decodeBase64(raw);
697
+ if (!decoded) return null;
698
+ const data = JSON.parse(decoded);
699
+ return data && typeof data === "object" ? data : null;
700
+ } catch {
701
+ return null;
702
+ }
703
+ }
704
+ function getLogoFromJettIdCookie() {
705
+ const data = getJettIdCookieData();
706
+ if (!(data == null ? void 0 : data.CDNBasePath)) return null;
707
+ const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
708
+ if (!logoPath) return null;
709
+ return {
710
+ logoPath,
711
+ CDNBasePath: data.CDNBasePath
712
+ };
713
+ }
714
+ function getScopeFromJettIdCookie() {
715
+ const data = getJettIdCookieData();
716
+ return (data == null ? void 0 : data.Scope) ?? null;
717
+ }
718
+ function getProfilesFromJettIdCookie(all) {
719
+ const data = getJettIdCookieData();
720
+ if (!(data == null ? void 0 : data.Profiles)) return [];
721
+ if (all) return data.Profiles;
722
+ return data.Profiles.filter((profile) => {
723
+ var _a;
724
+ return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
725
+ });
726
+ }
727
+ function buildLogoUrl(CDNBasePath, logoPath) {
728
+ const base = (CDNBasePath || "").replace(/\/$/, "");
729
+ const path = (logoPath || "").replace(/^\//, "");
730
+ if (!base || !path) return "";
731
+ return `${base}/${path}`;
732
+ }
733
+
734
+ // src/utils/switchProfileEncryption.js
735
+ var import_node_forge = __toESM(require("node-forge"));
736
+ var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
737
+ var RSA_EXPONENT_BASE64 = "AQAB";
738
+ var convertModulusExponentToPem = (modulus, exponent) => {
739
+ const decodedModulus = import_node_forge.default.util.decode64(modulus);
740
+ const decodedExponent = import_node_forge.default.util.decode64(exponent);
741
+ const publicKey = import_node_forge.default.pki.setRsaPublicKey(
742
+ new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
743
+ new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
744
+ );
745
+ return import_node_forge.default.pki.publicKeyToPem(publicKey);
746
+ };
747
+ var cachedPemKey = null;
748
+ var getPemKey = () => {
749
+ if (!cachedPemKey) {
750
+ cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
751
+ }
752
+ return cachedPemKey;
753
+ };
754
+ var encryptForSwitchProfile = (plainText) => {
755
+ const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
756
+ const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
757
+ return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
758
+ };
759
+
760
+ // src/utils/switchProfileApi.js
761
+ var PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
762
+ var hasSwitchedProfileThisSession = () => {
763
+ try {
764
+ return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
765
+ } catch {
766
+ return false;
767
+ }
768
+ };
769
+ var markProfileSwitched = () => {
770
+ try {
771
+ if (typeof localStorage !== "undefined") {
772
+ localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
773
+ }
774
+ } catch {
775
+ }
776
+ };
777
+ var clearProfileSwitchFlag = () => {
778
+ try {
779
+ if (typeof localStorage !== "undefined") {
780
+ localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
781
+ }
782
+ } catch {
783
+ }
784
+ };
785
+ var buildRequestContext = () => ({
786
+ UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
787
+ TrackingId: crypto.randomUUID(),
788
+ TransactionId: crypto.randomUUID(),
789
+ CountryCode: "IN",
790
+ IpAddress: "127.0.0.1"
791
+ // Client IP cannot be retrieved from browser
792
+ });
793
+ var switchProfile = async (profile) => {
794
+ markProfileSwitched();
795
+ const encryptedRequest = encryptForSwitchProfile(
796
+ JSON.stringify({
797
+ ProfileToken: profile.ProfileToken,
798
+ ProfileId: profile.ProfileId
799
+ })
800
+ );
801
+ return fetch(`${window.location.origin}/auth/switch/profile`, {
802
+ method: "POST",
803
+ credentials: "include",
804
+ headers: { "Content-Type": "application/json" },
805
+ body: JSON.stringify({
806
+ Context: buildRequestContext(),
807
+ Request: encryptedRequest
808
+ })
809
+ }).then((res) => res.json());
810
+ };
811
+
812
+ // src/sideBar/SwitchProfileSection.jsx
813
+ var import_react12 = __toESM(require("react"));
814
+ var import_react_dom2 = require("react-dom");
815
+ var import_lucide_react6 = require("lucide-react");
816
+
817
+ // src/sideBar/LogoutConfirmModal.jsx
818
+ var import_react11 = __toESM(require("react"));
819
+ var import_react_dom = require("react-dom");
820
+ var import_lucide_react5 = require("lucide-react");
821
+ var LogoutConfirmModal = ({
822
+ id = "logout-confirm",
823
+ open,
824
+ onConfirm,
825
+ onCancel,
826
+ loading = false
827
+ }) => {
828
+ if (!open || typeof document === "undefined") return null;
829
+ const handleOverlayClick = (e) => {
830
+ if (e.target === e.currentTarget && !loading) onCancel();
831
+ };
832
+ return (0, import_react_dom.createPortal)(
833
+ /* @__PURE__ */ import_react11.default.createElement(
834
+ "div",
835
+ {
836
+ className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
837
+ onClick: handleOverlayClick,
838
+ id: `${id}-overlay`
839
+ },
840
+ /* @__PURE__ */ import_react11.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react11.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react11.default.createElement(
841
+ "button",
842
+ {
843
+ type: "button",
844
+ onClick: onCancel,
845
+ disabled: loading,
846
+ className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
847
+ id: `${id}-cancel-button`
848
+ },
849
+ "No, Keep me in"
850
+ ), /* @__PURE__ */ import_react11.default.createElement(
851
+ "button",
852
+ {
853
+ type: "button",
854
+ onClick: onConfirm,
855
+ disabled: loading,
856
+ className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
857
+ id: `${id}-confirm-button`
858
+ },
859
+ loading ? "Logging out..." : "Yes, logout"
860
+ )))
861
+ ),
862
+ document.body
863
+ );
864
+ };
865
+
866
+ // src/sideBar/SwitchProfileSection.jsx
867
+ var SwitchProfileSection = ({
868
+ id = "switch-profile",
869
+ open,
870
+ anchorRef,
871
+ onClose,
872
+ onManageProfile,
873
+ onProfileSwitch,
874
+ onTmcSettings,
875
+ onLogout,
876
+ collapsed = false,
877
+ scopeLabel = ""
878
+ }) => {
879
+ const [position, setPosition] = (0, import_react12.useState)(null);
880
+ const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react12.useState)(false);
881
+ const [switchingProfileId, setSwitchingProfileId] = (0, import_react12.useState)(null);
882
+ const [switchError, setSwitchError] = (0, import_react12.useState)(null);
883
+ const jettIdData = getJettIdCookieData();
884
+ const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
885
+ const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
886
+ const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
887
+ const allMarkets = getProfilesFromJettIdCookie(true);
888
+ const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
889
+ const handleProfileSwitch = async (profile) => {
890
+ var _a, _b, _c;
891
+ if (switchingProfileId) return;
892
+ setSwitchingProfileId(profile.ProfileId);
893
+ setSwitchError(null);
894
+ try {
895
+ const response = await switchProfile(profile);
896
+ const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
897
+ const isSuccess = !statusCode || statusCode === 200;
898
+ if (!isSuccess) {
899
+ setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
900
+ setSwitchingProfileId(null);
901
+ return;
902
+ }
903
+ if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
904
+ window.location.href = response.Response.RedirectUrl;
905
+ return;
906
+ }
907
+ setSwitchingProfileId(null);
908
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
909
+ } catch (error) {
910
+ console.error("Switch profile request failed:", error);
911
+ setSwitchError("Something went wrong while switching profile. Please try again.");
912
+ setSwitchingProfileId(null);
913
+ }
914
+ };
915
+ (0, import_react12.useLayoutEffect)(() => {
916
+ if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
917
+ const updatePosition = () => {
918
+ const rect = anchorRef.current.getBoundingClientRect();
919
+ const width = Math.min(296, window.innerWidth - 16);
920
+ setPosition(
921
+ collapsed ? { left: rect.right + 8, bottom: Math.max(8, window.innerHeight - rect.bottom) } : { left: Math.max(8, Math.min(rect.left + 12, window.innerWidth - width - 8)), bottom: window.innerHeight - rect.top - 4 }
922
+ );
923
+ };
924
+ updatePosition();
925
+ window.addEventListener("resize", updatePosition);
926
+ window.addEventListener("scroll", updatePosition, true);
927
+ return () => {
928
+ window.removeEventListener("resize", updatePosition);
929
+ window.removeEventListener("scroll", updatePosition, true);
930
+ };
931
+ }, [open, anchorRef, collapsed]);
932
+ (0, import_react12.useEffect)(() => {
933
+ if (!open) setSwitchError(null);
934
+ }, [open]);
935
+ (0, import_react12.useEffect)(() => {
936
+ if (!switchError) return;
937
+ const timer = setTimeout(() => setSwitchError(null), 5e3);
938
+ return () => clearTimeout(timer);
939
+ }, [switchError]);
940
+ if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
941
+ const handleConfirmLogout = () => {
942
+ setShowLogoutConfirm(false);
943
+ onLogout == null ? void 0 : onLogout();
944
+ };
945
+ return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
946
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "font-jett", "data-jett-shell": true }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop`, "aria-hidden": "true" }), /* @__PURE__ */ import_react12.default.createElement(
947
+ "div",
948
+ {
949
+ role: "dialog",
950
+ "aria-label": "Account",
951
+ className: "fixed z-[9999] flex max-h-[75vh] w-[296px] max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-[10px] border border-jett-line bg-jett-surface text-jett-ink shadow-jett-pop",
952
+ style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
953
+ id: `${id}-panel`
954
+ },
955
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center gap-3 p-4", id: `${id}-header` }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-jett-ink-800 text-[15px] font-semibold text-white", id: `${id}-avatar` }, userName ? userName.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase() : "A"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "min-w-0 flex-1", id: `${id}-header-text` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "truncate text-[14px] font-medium text-jett-ink-800" }, userName || "Admin"), userEmail && /* @__PURE__ */ import_react12.default.createElement("div", { className: "truncate text-[13px] text-jett-ink-500" }, userEmail), scopeLabel && /* @__PURE__ */ import_react12.default.createElement("span", { className: "mt-1.5 inline-flex rounded-full border border-jett-line bg-jett-fill px-[7px] py-px text-[11px] font-semibold text-jett-ink-600" }, scopeLabel))),
956
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex flex-col gap-0.5 px-2 pb-2" }, /* @__PURE__ */ import_react12.default.createElement(
957
+ "button",
958
+ {
959
+ type: "button",
960
+ onClick: onManageProfile,
961
+ className: "flex w-full cursor-pointer items-center gap-2.5 rounded-[6px] border-0 bg-transparent p-2 text-left text-[14px] text-jett-ink-700 hover:bg-jett-canvas hover:text-jett-ink",
962
+ id: `${id}-manage-profile-button`
963
+ },
964
+ /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.UserRound, { width: 16, height: 16, strokeWidth: 1.8, className: "text-jett-ink-400", "aria-hidden": "true" }),
965
+ "Manage profile"
966
+ )),
967
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "min-h-0 overflow-y-auto border-t border-jett-line-row px-4 py-3 scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400", id: `${id}-markets-label` }, "Your markets"), switchError && /* @__PURE__ */ import_react12.default.createElement("div", { role: "alert", className: "mt-2 rounded-[6px] border border-[#fca5a5] bg-jett-danger-soft px-3 py-2 text-[12px] font-medium text-jett-danger", id: `${id}-switch-error` }, switchError), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-2 flex flex-col gap-1", role: "list", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react12.default.createElement("p", { className: "!m-0 py-1 text-[13px] text-jett-ink-500", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
968
+ const isCurrent = profile.ProfileId === currentProfileId;
969
+ const isSwitching = switchingProfileId === profile.ProfileId;
970
+ return /* @__PURE__ */ import_react12.default.createElement(
971
+ "button",
972
+ {
973
+ key: profile.ProfileId,
974
+ type: "button",
975
+ role: "listitem",
976
+ onClick: () => !isCurrent && handleProfileSwitch(profile),
977
+ disabled: isSwitching || !!switchingProfileId,
978
+ "aria-current": isCurrent || void 0,
979
+ className: `flex w-full items-center justify-between gap-2 rounded-[6px] border px-2.5 py-2 text-left transition-colors ${isCurrent ? "cursor-default border-jett-line bg-jett-fill" : "cursor-pointer border-transparent bg-transparent hover:bg-jett-canvas"} ${isSwitching ? "opacity-60" : ""}`,
980
+ id: `${id}-market-${profile.ProfileId}`
981
+ },
982
+ /* @__PURE__ */ import_react12.default.createElement("span", { className: `truncate text-[13px] text-jett-ink ${isCurrent ? "font-semibold" : "font-medium"}` }, profile.EntityName),
983
+ isCurrent && /* @__PURE__ */ import_react12.default.createElement("span", { className: "shrink-0 rounded-full bg-jett-brand-soft px-2 py-px text-[11px] font-semibold text-jett-brand-hover" }, "Signed in"),
984
+ isSwitching && /* @__PURE__ */ import_react12.default.createElement("span", { className: "shrink-0 text-[11px] text-jett-ink-400" }, "Switching\u2026")
985
+ );
986
+ }))),
987
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "border-t border-jett-line-row p-2", id: `${id}-footer` }, /* @__PURE__ */ import_react12.default.createElement(
988
+ "button",
989
+ {
990
+ type: "button",
991
+ onClick: () => {
992
+ onClose == null ? void 0 : onClose();
993
+ setShowLogoutConfirm(true);
994
+ },
995
+ className: "flex w-full cursor-pointer items-center gap-2.5 rounded-[6px] border-0 bg-transparent p-2 text-left text-[14px] font-semibold text-jett-danger hover:bg-jett-danger-soft",
996
+ id: `${id}-logout`
997
+ },
998
+ /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { width: 16, height: 16, strokeWidth: 1.8, "aria-hidden": "true" }),
999
+ "Log out"
1000
+ ))
1001
+ )),
1002
+ document.body
1003
+ ), /* @__PURE__ */ import_react12.default.createElement(
1004
+ LogoutConfirmModal,
1005
+ {
1006
+ id: `${id}-logout-confirm`,
1007
+ open: showLogoutConfirm,
1008
+ onCancel: () => setShowLogoutConfirm(false),
1009
+ onConfirm: handleConfirmLogout
1010
+ }
1011
+ ));
1012
+ };
1013
+
1014
+ // src/sideBar/CommandPalette.jsx
1015
+ var import_react13 = __toESM(require("react"));
1016
+ var import_react_dom3 = require("react-dom");
1017
+ var Kbd = ({ children, raised }) => /* @__PURE__ */ import_react13.default.createElement(
1018
+ "span",
1019
+ {
1020
+ className: `inline-block min-w-[20px] rounded-[4px] border border-jett-line-soft bg-jett-surface px-[5px] text-center text-[11px] leading-[18px] font-medium text-jett-ink-500 ${raised ? "border-b-2 !text-[12px] text-jett-ink-700" : ""}`
1021
+ },
1022
+ children
1023
+ );
1024
+ var CommandPalette = ({ id = "command-palette", open, onClose, commands }) => {
1025
+ const [q, setQ] = (0, import_react13.useState)("");
1026
+ const [idx, setIdx] = (0, import_react13.useState)(0);
1027
+ const inputRef = (0, import_react13.useRef)(null);
1028
+ const listRef = (0, import_react13.useRef)(null);
1029
+ (0, import_react13.useEffect)(() => {
1030
+ if (!open) return;
1031
+ setQ("");
1032
+ setIdx(0);
1033
+ const opener = document.activeElement;
1034
+ const t = setTimeout(() => {
1035
+ var _a;
1036
+ return (_a = inputRef.current) == null ? void 0 : _a.focus();
1037
+ }, 0);
1038
+ return () => {
1039
+ clearTimeout(t);
1040
+ if (opener && opener.focus && document.contains(opener)) opener.focus({ preventScroll: true });
1041
+ };
1042
+ }, [open]);
1043
+ const list = (0, import_react13.useMemo)(() => {
1044
+ const s = q.trim().toLowerCase();
1045
+ return s ? commands.filter((c) => (c.label + " " + (c.sub || "")).toLowerCase().includes(s)) : commands;
1046
+ }, [q, commands]);
1047
+ const cur = Math.min(idx, Math.max(0, list.length - 1));
1048
+ (0, import_react13.useEffect)(() => {
1049
+ var _a, _b;
1050
+ (_b = (_a = listRef.current) == null ? void 0 : _a.querySelector(`[data-idx="${cur}"]`)) == null ? void 0 : _b.scrollIntoView({ block: "nearest" });
1051
+ }, [cur]);
1052
+ if (!open || typeof document === "undefined") return null;
1053
+ const run = (c) => {
1054
+ var _a;
1055
+ onClose();
1056
+ (_a = c == null ? void 0 : c.run) == null ? void 0 : _a.call(c);
1057
+ };
1058
+ const onKey = (e) => {
1059
+ if (e.key === "ArrowDown") {
1060
+ e.preventDefault();
1061
+ setIdx((cur + 1) % Math.max(1, list.length));
1062
+ } else if (e.key === "ArrowUp") {
1063
+ e.preventDefault();
1064
+ setIdx((cur - 1 + list.length) % Math.max(1, list.length));
1065
+ } else if (e.key === "Enter") {
1066
+ e.preventDefault();
1067
+ run(list[cur]);
1068
+ } else if (e.key === "Tab") {
1069
+ e.preventDefault();
1070
+ }
1071
+ };
1072
+ return (0, import_react_dom3.createPortal)(
1073
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "font-jett", id }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[95] bg-[rgba(17,24,39,0.4)]", onClick: onClose, "aria-hidden": "true" }), /* @__PURE__ */ import_react13.default.createElement(
1074
+ "div",
1075
+ {
1076
+ role: "dialog",
1077
+ "aria-modal": "true",
1078
+ "aria-label": "Command palette",
1079
+ className: "fixed left-1/2 top-[12vh] z-[96] flex w-[calc(100%-32px)] max-w-[560px] -translate-x-1/2 flex-col overflow-hidden rounded-[12px] border border-jett-line bg-jett-surface shadow-jett-pop"
1080
+ },
1081
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex h-[52px] items-center gap-2.5 border-b border-jett-line-row px-4" }, /* @__PURE__ */ import_react13.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react13.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react13.default.createElement("path", { d: "m20 20-3.5-3.5" })), /* @__PURE__ */ import_react13.default.createElement(
1082
+ "input",
1083
+ {
1084
+ ref: inputRef,
1085
+ type: "text",
1086
+ role: "combobox",
1087
+ "aria-expanded": "true",
1088
+ "aria-controls": `${id}-list`,
1089
+ "aria-activedescendant": list[cur] ? `${id}-opt-${cur}` : void 0,
1090
+ value: q,
1091
+ onChange: (e) => {
1092
+ setQ(e.target.value);
1093
+ setIdx(0);
1094
+ },
1095
+ onKeyDown: onKey,
1096
+ placeholder: "Search screens and actions",
1097
+ className: "h-full flex-1 border-0 bg-transparent p-0 text-[15px] text-jett-ink outline-none placeholder:text-jett-ink-400"
1098
+ }
1099
+ ), /* @__PURE__ */ import_react13.default.createElement(Kbd, null, "Esc")),
1100
+ /* @__PURE__ */ import_react13.default.createElement("div", { ref: listRef, id: `${id}-list`, role: "listbox", className: "flex max-h-[360px] flex-col gap-0.5 overflow-y-auto p-1.5" }, list.map((c, i) => /* @__PURE__ */ import_react13.default.createElement(
1101
+ "button",
1102
+ {
1103
+ key: c.label + (c.sub || ""),
1104
+ id: `${id}-opt-${i}`,
1105
+ "data-idx": i,
1106
+ role: "option",
1107
+ "aria-selected": i === cur,
1108
+ type: "button",
1109
+ tabIndex: -1,
1110
+ onClick: () => run(c),
1111
+ onMouseEnter: () => setIdx(i),
1112
+ className: `flex cursor-pointer items-center gap-3 rounded-[6px] border-0 px-2.5 py-[9px] text-left ${i === cur ? "bg-jett-fill" : "bg-transparent"}`
1113
+ },
1114
+ /* @__PURE__ */ import_react13.default.createElement("span", { className: "min-w-0 flex-1 truncate text-[14px] font-medium text-jett-ink" }, c.label),
1115
+ /* @__PURE__ */ import_react13.default.createElement("span", { className: "text-[12px] text-jett-ink-500" }, c.sub),
1116
+ /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex min-w-[44px] justify-end gap-[3px]" }, (c.keys || []).map((k) => /* @__PURE__ */ import_react13.default.createElement(Kbd, { key: k }, k)))
1117
+ )), !list.length && /* @__PURE__ */ import_react13.default.createElement("div", { className: "px-2.5 py-6 text-center text-[14px] text-jett-ink-500" }, "No matches")),
1118
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex gap-4 border-t border-jett-line-row px-4 py-2.5 text-[12px] text-jett-ink-500" }, /* @__PURE__ */ import_react13.default.createElement("span", null, "\u2191 \u2193 to move"), /* @__PURE__ */ import_react13.default.createElement("span", null, "\u21B5 to open"), /* @__PURE__ */ import_react13.default.createElement("span", null, "? for all shortcuts"))
1119
+ )),
1120
+ document.body
1121
+ );
1122
+ };
1123
+ var ShortcutsSheet = ({ id = "shortcuts-sheet", open, onClose, sections }) => {
1124
+ const closeRef = (0, import_react13.useRef)(null);
1125
+ (0, import_react13.useEffect)(() => {
1126
+ if (!open) return;
1127
+ const opener = document.activeElement;
1128
+ const t = setTimeout(() => {
1129
+ var _a;
1130
+ return (_a = closeRef.current) == null ? void 0 : _a.focus();
1131
+ }, 0);
1132
+ return () => {
1133
+ clearTimeout(t);
1134
+ if (opener && opener.focus && document.contains(opener)) opener.focus({ preventScroll: true });
1135
+ };
1136
+ }, [open]);
1137
+ if (!open || typeof document === "undefined") return null;
1138
+ return (0, import_react_dom3.createPortal)(
1139
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "font-jett", id }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[95] bg-[rgba(17,24,39,0.4)]", onClick: onClose, "aria-hidden": "true" }), /* @__PURE__ */ import_react13.default.createElement(
1140
+ "div",
1141
+ {
1142
+ role: "dialog",
1143
+ "aria-modal": "true",
1144
+ "aria-label": "Keyboard shortcuts",
1145
+ className: "fixed left-1/2 top-1/2 z-[96] max-h-[calc(100vh-64px)] w-[calc(100%-32px)] max-w-[640px] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-[12px] border border-jett-line bg-jett-surface shadow-jett-pop"
1146
+ },
1147
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between border-b border-jett-line-row px-5 py-4" }, /* @__PURE__ */ import_react13.default.createElement("h2", { className: "!m-0 !text-[16px] !font-semibold text-jett-ink" }, "Keyboard shortcuts"), /* @__PURE__ */ import_react13.default.createElement(
1148
+ "button",
1149
+ {
1150
+ ref: closeRef,
1151
+ type: "button",
1152
+ onClick: onClose,
1153
+ title: "Close",
1154
+ "aria-label": "Close",
1155
+ className: "flex h-8 w-8 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent text-jett-ink-500 hover:bg-jett-fill"
1156
+ },
1157
+ /* @__PURE__ */ import_react13.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react13.default.createElement("path", { d: "M18 6 6 18M6 6l12 12" }))
1158
+ )),
1159
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-x-8 gap-y-2 px-5 pb-5 pt-2" }, sections.map((sec) => /* @__PURE__ */ import_react13.default.createElement("div", { key: sec.title, className: "flex flex-col" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "pb-1.5 pt-3 text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400" }, sec.title), sec.rows.map((r) => /* @__PURE__ */ import_react13.default.createElement("div", { key: r.label, className: "flex items-center justify-between gap-3 border-b border-jett-line-row py-[7px]" }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "text-[14px] text-jett-ink-700" }, r.label), /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex items-center gap-1" }, r.keys.map((k) => /* @__PURE__ */ import_react13.default.createElement(Kbd, { key: k, raised: true }, k))))))))
1160
+ )),
1161
+ document.body
1162
+ );
1163
+ };
1164
+
1165
+ // src/sideBar/navMatch.js
1166
+ var extractUrlFromOnClick = (onClick) => {
1167
+ if (!onClick || typeof onClick !== "function") return null;
1168
+ const funcString = onClick.toString();
1169
+ let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
1170
+ if (!match) {
1171
+ match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
1172
+ }
1173
+ if (match && match[1]) {
1174
+ try {
1175
+ if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
1176
+ const url = new URL(match[1]);
1177
+ return {
1178
+ pathname: url.pathname,
1179
+ search: url.search,
1180
+ fullPath: url.pathname + url.search
1181
+ };
1182
+ }
1183
+ if (match[1].startsWith("/")) {
1184
+ const url = new URL(match[1], window.location.origin);
1185
+ return {
1186
+ pathname: url.pathname,
1187
+ search: url.search,
1188
+ fullPath: url.pathname + url.search
1189
+ };
1190
+ }
1191
+ return null;
1192
+ } catch {
1193
+ const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
1194
+ if (pathMatch) {
1195
+ return {
1196
+ pathname: pathMatch[1],
1197
+ search: pathMatch[2] || "",
1198
+ fullPath: match[1]
1199
+ };
1200
+ }
1201
+ return null;
1202
+ }
1203
+ }
1204
+ return null;
1205
+ };
1206
+ var currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
1207
+ if (!menuUrlData || !currentPath) return false;
1208
+ const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
1209
+ const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
1210
+ if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
1211
+ const menuParams = new URLSearchParams(menuUrlData.search);
1212
+ const currentParams = new URLSearchParams(currentSearch);
1213
+ const menuRole = menuParams.get("role");
1214
+ const currentRole = currentParams.get("role");
1215
+ if (menuRole && currentRole) {
1216
+ return menuRole === currentRole;
1217
+ }
1218
+ if (menuRole && !currentRole || !menuRole && currentRole) {
1219
+ return false;
1220
+ }
1221
+ return true;
1222
+ }
1223
+ if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
1224
+ return true;
1225
+ }
1226
+ if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
1227
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1228
+ if (currentPathParam === "supplier-list") {
1229
+ return true;
1230
+ }
1231
+ }
1232
+ if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
1233
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1234
+ if (currentPathParam === "supplier-deals") {
1235
+ return true;
1236
+ }
1237
+ }
1238
+ if (normalizedMenuPath === "/corporate/trips") {
1239
+ if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
1240
+ return true;
1241
+ }
1242
+ }
1243
+ if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
1244
+ const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
1245
+ if (menuPathParam) {
1246
+ const pathRouteMap = {
1247
+ "offer": "/offer/offer",
1248
+ "voucher": "/voucher/voucher",
1249
+ "tag": "/tags/tags",
1250
+ "special-requests": "/corporate/special-requests",
1251
+ "pricing-policy": "/policies/pricing-policy",
1252
+ "supplier-list": "/supplier",
1253
+ "users": "/users/users"
1254
+ // Consumer Ecosystem Users (no role param)
1255
+ };
1256
+ const expectedRoute = pathRouteMap[menuPathParam];
1257
+ if (expectedRoute) {
1258
+ if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1259
+ if (menuPathParam === "users") {
1260
+ const currentParams = new URLSearchParams(currentSearch);
1261
+ const currentRole = currentParams.get("role");
1262
+ return currentRole !== "admin";
1263
+ }
1264
+ return true;
1265
+ }
1266
+ }
1267
+ }
1268
+ if (normalizedCurrentPath === "/orgselector") {
1269
+ const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1270
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1271
+ if (menuPathParam2 && currentPathParam) {
1272
+ return menuPathParam2 === currentPathParam;
1273
+ }
1274
+ }
1275
+ }
1276
+ if (normalizedMenuPath === normalizedCurrentPath) {
1277
+ if (menuUrlData.search) {
1278
+ const menuParams = new URLSearchParams(menuUrlData.search);
1279
+ const currentParams = new URLSearchParams(currentSearch);
1280
+ for (const [key, value] of menuParams.entries()) {
1281
+ if (key === "auth") {
1282
+ continue;
1283
+ }
1284
+ if (currentParams.get(key) !== value) {
1285
+ return false;
1286
+ }
1287
+ }
1288
+ return true;
1289
+ }
1290
+ return true;
1291
+ }
1292
+ if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1293
+ return true;
1294
+ }
1295
+ return false;
1296
+ };
1297
+
1298
+ // src/sideBar/SideBar.jsx
1299
+ var SCOPE_LABELS = {
1300
+ TMC: "TMC Manager",
1301
+ TMC_ENTITY: "TMC Entity Manager"
1302
+ };
1303
+ var LS_COLLAPSED = "jett.sidebar.collapsed";
1304
+ var PHONE_MAX = 768;
1305
+ var AUTO_EXPAND = 1280;
1306
+ var GOTO = [
1307
+ ["h", "Home"],
1308
+ ["c", "Corporate"],
1309
+ ["t", "Trips"],
1310
+ ["r", "Special Request"],
1311
+ ["b", "Booking & Invoices"],
1312
+ ["e", "Pricing Engine"],
1313
+ ["l", "Credit Management"],
1314
+ ["s", "Suppliers List"],
1315
+ ["d", "Supplier Deals"],
1316
+ ["w", "Whitelabel"],
1317
+ ["m", "Markets"],
1318
+ ["p", "Users", "Settings"],
1319
+ ["i", "AuthMesh"],
1320
+ ["a", "Audit"]
1321
+ ];
1322
+ var norm = (s) => String(s || "").trim().toLowerCase();
1323
+ var SOON_RX = /\s*\((coming )?soon\)\s*$/i;
1324
+ var cleanLabel = (s) => String(s || "").replace(SOON_RX, "");
1325
+ var isSoon = (o) => !!o.isDisabled || SOON_RX.test(o.label || "");
1326
+ var MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent || "");
1327
+ var MOD = MAC ? "\u2318" : "Ctrl";
1328
+ var readPref = () => {
1329
+ try {
1330
+ const v = localStorage.getItem(LS_COLLAPSED);
1331
+ return v === null ? null : v === "1";
1332
+ } catch {
1333
+ return null;
1334
+ }
1335
+ };
1336
+ var initials = (name) => String(name || "A").split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase() || "A";
1337
+ var Chevron = ({ open }) => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "shrink-0 transition-transform duration-150", style: { transform: open ? "rotate(90deg)" : "none" }, "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "m9 18 6-6-6-6" }));
1338
+ var LogoTile = ({ size = 28 }) => /* @__PURE__ */ import_react14.default.createElement(
1339
+ "div",
1340
+ {
1341
+ className: "flex shrink-0 items-center justify-center rounded-[6px] bg-jett-brand font-bold text-white",
1342
+ style: { width: size, height: size, fontSize: size >= 28 ? 13 : 12 },
1343
+ "aria-hidden": "true"
1344
+ },
1345
+ "J"
1346
+ );
1347
+ var AppSideBar = ({
1348
+ id = "side-bar",
1349
+ username,
1350
+ navItems,
1351
+ additionalItems,
1352
+ sideBarLogo,
1353
+ onManageProfile,
1354
+ onProfileSwitch,
1355
+ onTmcSettings,
1356
+ onLogout
1357
+ }) => {
1358
+ var _a, _b;
1359
+ const profileCardRef = (0, import_react14.useRef)(null);
1360
+ const [authData, setAuthData] = (0, import_react14.useState)(null);
1361
+ const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
1362
+ const [scope, setScope] = (0, import_react14.useState)(null);
1363
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
1364
+ const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
1365
+ const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
1366
+ const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
1367
+ const [width, setWidth] = (0, import_react14.useState)(() => typeof window === "undefined" ? 1440 : window.innerWidth);
1368
+ const [pref, setPref] = (0, import_react14.useState)(readPref);
1369
+ const [fly, setFly] = (0, import_react14.useState)(null);
1370
+ const [palOpen, setPalOpen] = (0, import_react14.useState)(false);
1371
+ const [helpOpen, setHelpOpen] = (0, import_react14.useState)(false);
1372
+ const [ready, setReady] = (0, import_react14.useState)(false);
1373
+ const gPending = (0, import_react14.useRef)(false);
1374
+ const gTimer = (0, import_react14.useRef)(null);
1375
+ const phone = width < PHONE_MAX;
1376
+ const collapsed = !phone && (pref === null ? width < AUTO_EXPAND : pref);
1377
+ const toggleMenu = (menuKey) => {
1378
+ setOpenMenus((prev) => {
1379
+ const next = new Set(prev);
1380
+ if (next.has(menuKey)) next.delete(menuKey);
1381
+ else next.add(menuKey);
1382
+ return next;
1383
+ });
1384
+ };
1385
+ const isMenuOpen = (menuKey) => openMenus.has(menuKey);
1386
+ const closeMobileMenu = () => setIsMobileMenuOpen(false);
1387
+ const handleMenuClick = (item, index, e) => {
1388
+ if (item.isDropDown || item.options && item.options.length) {
1389
+ e.preventDefault();
1390
+ toggleMenu(`menu-${index}`);
1391
+ } else {
1392
+ setActiveMenuPath(`menu-${index}`);
1393
+ if (item.onClick) item.onClick(e);
1394
+ closeMobileMenu();
1395
+ }
1396
+ };
1397
+ const handleSubMenuClick = (option, optionsIndex, parentIndex2, e) => {
1398
+ const parentMenuKey = `menu-${parentIndex2}`;
1399
+ setOpenMenus((prev) => new Set(prev).add(parentMenuKey));
1400
+ if (option.isDropDown) {
1401
+ e.preventDefault();
1402
+ toggleMenu(`menu-${parentIndex2}-option-${optionsIndex}`);
1403
+ return;
1404
+ }
1405
+ setActiveMenuPath(`menu-${parentIndex2}-option-${optionsIndex}`);
1406
+ setFly(null);
1407
+ if (option.onClick) option.onClick();
1408
+ closeMobileMenu();
1409
+ };
1410
+ const handleSubSubMenuClick = (subOption, parentIndex2, optionsIndex) => {
1411
+ setOpenMenus((prev) => {
1412
+ const next = new Set(prev);
1413
+ next.add(`menu-${parentIndex2}`);
1414
+ next.add(`menu-${parentIndex2}-option-${optionsIndex}`);
1415
+ return next;
1416
+ });
1417
+ setActiveMenuPath(`menu-${parentIndex2}-option-${optionsIndex}-sub-${subOption.label}`);
1418
+ setFly(null);
1419
+ if (subOption.onClick) subOption.onClick();
1420
+ closeMobileMenu();
1421
+ };
1422
+ (0, import_react14.useEffect)(() => {
1423
+ const storedAuthData = localStorage.getItem("authData");
1424
+ if (storedAuthData) {
1425
+ try {
1426
+ setAuthData(JSON.parse(storedAuthData));
1427
+ } catch {
1428
+ setAuthData(null);
1429
+ }
1430
+ }
1431
+ }, []);
1432
+ (0, import_react14.useEffect)(() => {
1433
+ const jettIdData = getJettIdCookieData();
1434
+ if (jettIdData == null ? void 0 : jettIdData.UserName) setCookieUserName(jettIdData.UserName);
1435
+ const cookieScope = getScopeFromJettIdCookie();
1436
+ if (cookieScope) setScope(cookieScope);
1437
+ }, []);
1438
+ (0, import_react14.useEffect)(() => {
1439
+ if (hasSwitchedProfileThisSession()) return;
1440
+ const jettIdData = getJettIdCookieData();
1441
+ const allProfiles = getProfilesFromJettIdCookie(true);
1442
+ if (allProfiles.length <= 1) return;
1443
+ const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
1444
+ if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
1445
+ switchProfile(tmcProfile).then((response) => {
1446
+ var _a2;
1447
+ if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
1448
+ window.location.href = response.Response.RedirectUrl;
1449
+ }
1450
+ }).catch((error) => {
1451
+ console.error("Auto TMC profile switch failed:", error);
1452
+ });
1453
+ }, []);
1454
+ const navItemsLocal = navItems ?? navItemsConstant;
1455
+ void (additionalItems ?? additionalItemsConstant);
1456
+ const logoFromCookie = getLogoFromJettIdCookie();
1457
+ const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1458
+ const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(authData.userInfo.CDNBasePath, authData.userInfo.OrgLogo) : null;
1459
+ const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1460
+ const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
1461
+ const currentPath = window.location.pathname;
1462
+ const currentSearch = window.location.search;
1463
+ const newOpenMenus = /* @__PURE__ */ new Set();
1464
+ let foundActivePath = null;
1465
+ navItemsLocal.forEach((item, index) => {
1466
+ if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1467
+ const itemUrlData = extractUrlFromOnClick(item.onClick);
1468
+ if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1469
+ foundActivePath = `menu-${index}`;
1470
+ }
1471
+ }
1472
+ if (item.options && item.options.length > 0) {
1473
+ item.options.forEach((option, optionsIndex) => {
1474
+ if (option.onClick && typeof option.onClick === "function") {
1475
+ const optionUrlData = extractUrlFromOnClick(option.onClick);
1476
+ if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1477
+ newOpenMenus.add(`menu-${index}`);
1478
+ foundActivePath = `menu-${index}-option-${optionsIndex}`;
1479
+ if (option.options && option.options.length > 0) {
1480
+ option.options.forEach((subOption) => {
1481
+ const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1482
+ if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1483
+ newOpenMenus.add(`menu-${index}-option-${optionsIndex}`);
1484
+ foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1485
+ }
1486
+ });
1487
+ }
1488
+ }
1489
+ }
1490
+ });
1491
+ }
1492
+ });
1493
+ if (foundActivePath) {
1494
+ setOpenMenus(newOpenMenus);
1495
+ setActiveMenuPath(foundActivePath);
1496
+ }
1497
+ }, [navItemsLocal]);
1498
+ (0, import_react14.useEffect)(() => {
1499
+ detectAndSetActiveMenu();
1500
+ let lastUrl = window.location.pathname + window.location.search;
1501
+ const check = () => {
1502
+ const newUrl = window.location.pathname + window.location.search;
1503
+ if (newUrl !== lastUrl) {
1504
+ lastUrl = newUrl;
1505
+ detectAndSetActiveMenu();
1506
+ }
1507
+ };
1508
+ window.addEventListener("popstate", check);
1509
+ const interval = setInterval(check, 250);
1510
+ return () => {
1511
+ window.removeEventListener("popstate", check);
1512
+ clearInterval(interval);
1513
+ };
1514
+ }, [detectAndSetActiveMenu]);
1515
+ (0, import_react14.useEffect)(() => {
1516
+ const onResize = () => {
1517
+ setWidth(window.innerWidth);
1518
+ setFly(null);
1519
+ };
1520
+ window.addEventListener("resize", onResize);
1521
+ const r = requestAnimationFrame(() => requestAnimationFrame(() => setReady(true)));
1522
+ return () => {
1523
+ window.removeEventListener("resize", onResize);
1524
+ cancelAnimationFrame(r);
1525
+ };
1526
+ }, []);
1527
+ (0, import_react14.useEffect)(() => {
1528
+ if (!phone) setIsMobileMenuOpen(false);
1529
+ }, [phone]);
1530
+ const toggleCollapsed = (0, import_react14.useCallback)(() => {
1531
+ if (phone) return;
1532
+ const next = !collapsed;
1533
+ try {
1534
+ localStorage.setItem(LS_COLLAPSED, next ? "1" : "0");
1535
+ } catch {
1536
+ }
1537
+ setPref(next);
1538
+ setFly(null);
1539
+ setIsSwitchProfileOpen(false);
1540
+ }, [phone, collapsed]);
1541
+ const screens = (0, import_react14.useMemo)(() => {
1542
+ const out = [];
1543
+ navItemsLocal.forEach((item) => {
1544
+ if (item.options && item.options.length) {
1545
+ item.options.forEach((o) => {
1546
+ if (!isSoon(o) && o.onClick) out.push({ label: cleanLabel(o.label), group: item.label, run: () => o.onClick() });
1547
+ });
1548
+ } else if (item.onClick) {
1549
+ out.push({ label: cleanLabel(item.label), group: "", run: () => item.onClick() });
1550
+ }
1551
+ });
1552
+ return out;
1553
+ }, [navItemsLocal]);
1554
+ const gotoMap = (0, import_react14.useMemo)(() => {
1555
+ const m = {};
1556
+ GOTO.forEach(([key, label, group]) => {
1557
+ const s = screens.find((x) => norm(x.label) === norm(label) && (!group || norm(x.group) === norm(group)));
1558
+ if (s) m[key] = s;
1559
+ });
1560
+ return m;
1561
+ }, [screens]);
1562
+ const commands = (0, import_react14.useMemo)(() => {
1563
+ const keyOf = new Map(Object.entries(gotoMap).map(([k, s]) => [s, k.toUpperCase()]));
1564
+ const cmds = screens.map((s) => ({ label: s.label, sub: s.group, keys: keyOf.has(s) ? ["G", keyOf.get(s)] : [], run: s.run }));
1565
+ if (!phone) cmds.push({ label: collapsed ? "Expand sidebar" : "Collapse sidebar", sub: "Action", keys: ["["], run: toggleCollapsed });
1566
+ cmds.push({ label: "Keyboard shortcuts", sub: "Help", keys: ["?"], run: () => setHelpOpen(true) });
1567
+ return cmds;
1568
+ }, [screens, gotoMap, phone, collapsed, toggleCollapsed]);
1569
+ const helpSections = (0, import_react14.useMemo)(
1570
+ () => [
1571
+ {
1572
+ title: "Global",
1573
+ rows: [
1574
+ { label: "Focus search on this page", keys: [MOD, "K"] },
1575
+ { label: "Focus search (alternative)", keys: ["/"] },
1576
+ { label: "Jump to any screen or action", keys: [MOD, "\u21E7", "K"] },
1577
+ { label: "Collapse or expand sidebar", keys: ["["] },
1578
+ { label: "Close menu, drawer or dialog", keys: ["Esc"] },
1579
+ { label: "Show this list", keys: ["?"] }
1580
+ ]
1581
+ },
1582
+ { title: "Go to", rows: GOTO.filter(([k]) => gotoMap[k]).map(([k]) => ({ label: gotoMap[k].label, keys: ["G", k.toUpperCase()] })) },
1583
+ {
1584
+ title: "In the palette",
1585
+ rows: [
1586
+ { label: "Move selection", keys: ["\u2191", "\u2193"] },
1587
+ { label: "Open selected", keys: ["\u21B5"] }
1588
+ ]
1589
+ }
1590
+ ],
1591
+ [gotoMap]
1592
+ );
1593
+ const stateRef = (0, import_react14.useRef)({});
1594
+ stateRef.current = { palOpen, helpOpen, fly, isSwitchProfileOpen, isMobileMenuOpen, phone, gotoMap, toggleCollapsed };
1595
+ (0, import_react14.useEffect)(() => {
1596
+ const findSearch = () => Array.from(document.querySelectorAll('main input[type="search"], main input[placeholder^="Search"], input[type="search"], input[placeholder^="Search"]')).find(
1597
+ (el) => el.offsetParent !== null && !el.closest("[data-jett-shell]")
1598
+ );
1599
+ const onKey = (e) => {
1600
+ const s = stateRef.current;
1601
+ const t = e.target;
1602
+ const typing = t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));
1603
+ const mod = e.metaKey || e.ctrlKey;
1604
+ const key = (e.key || "").toLowerCase();
1605
+ if (mod && key === "k") {
1606
+ e.preventDefault();
1607
+ const el = !e.shiftKey && !s.palOpen ? findSearch() : null;
1608
+ if (el && document.activeElement !== el) {
1609
+ setHelpOpen(false);
1610
+ el.focus();
1611
+ if (el.select) el.select();
1612
+ return;
1613
+ }
1614
+ setHelpOpen(false);
1615
+ setFly(null);
1616
+ setIsSwitchProfileOpen(false);
1617
+ setPalOpen((o) => !o);
1618
+ return;
1619
+ }
1620
+ if (e.key === "Escape") {
1621
+ const close = () => {
1622
+ e.preventDefault();
1623
+ e.stopImmediatePropagation();
1624
+ };
1625
+ if (s.palOpen) return close(), setPalOpen(false);
1626
+ if (s.helpOpen) return close(), setHelpOpen(false);
1627
+ if (s.fly) return close(), setFly(null);
1628
+ if (s.isSwitchProfileOpen) return close(), setIsSwitchProfileOpen(false);
1629
+ if (s.isMobileMenuOpen) return close(), setIsMobileMenuOpen(false);
1630
+ return;
1631
+ }
1632
+ if (typing || mod || e.altKey || s.palOpen) return;
1633
+ if (gPending.current) {
1634
+ gPending.current = false;
1635
+ clearTimeout(gTimer.current);
1636
+ const target = s.gotoMap[key];
1637
+ if (target) {
1638
+ e.preventDefault();
1639
+ target.run();
1640
+ }
1641
+ return;
1642
+ }
1643
+ if (key === "g" && !e.shiftKey) {
1644
+ gPending.current = true;
1645
+ gTimer.current = setTimeout(() => gPending.current = false, 1200);
1646
+ return;
1647
+ }
1648
+ if (e.key === "/") {
1649
+ const el = findSearch();
1650
+ if (el) {
1651
+ e.preventDefault();
1652
+ el.focus();
1653
+ if (el.select) el.select();
1654
+ }
1655
+ return;
1656
+ }
1657
+ if (e.key === "?") {
1658
+ e.preventDefault();
1659
+ setHelpOpen((o) => !o);
1660
+ return;
1661
+ }
1662
+ if (e.key === "[" && !s.phone) {
1663
+ e.preventDefault();
1664
+ s.toggleCollapsed();
1665
+ }
1666
+ };
1667
+ window.addEventListener("keydown", onKey, true);
1668
+ return () => {
1669
+ window.removeEventListener("keydown", onKey, true);
1670
+ clearTimeout(gTimer.current);
1671
+ };
1672
+ }, []);
1673
+ const parentIndex = activeMenuPath ? Number((/^menu-(\d+)/.exec(activeMenuPath) || [])[1]) : -1;
1674
+ const activeLabel = (() => {
1675
+ var _a2, _b2;
1676
+ if (!activeMenuPath) return "JETT Admin";
1677
+ const m = /^menu-(\d+)(?:-option-(\d+))?/.exec(activeMenuPath);
1678
+ const item = navItemsLocal[Number(m == null ? void 0 : m[1])];
1679
+ if (!item) return "JETT Admin";
1680
+ return cleanLabel(m[2] !== void 0 ? (_b2 = (_a2 = item.options) == null ? void 0 : _a2[Number(m[2])]) == null ? void 0 : _b2.label : item.label) || "JETT Admin";
1681
+ })();
1682
+ const displayName = username || cookieUserName || "Admin";
1683
+ const scopeLabel = SCOPE_LABELS[scope] ?? scope ?? "";
1684
+ const expanded = !collapsed;
1685
+ const openFly = (index, e) => {
1686
+ var _a2, _b2;
1687
+ const r = e.currentTarget.getBoundingClientRect();
1688
+ const n = ((_b2 = (_a2 = navItemsLocal[index]) == null ? void 0 : _a2.options) == null ? void 0 : _b2.length) || 1;
1689
+ const top = Math.max(8, Math.min(r.top - 6, window.innerHeight - (n * 36 + 60)));
1690
+ setIsSwitchProfileOpen(false);
1691
+ setFly((f) => f && f.index === index ? null : { index, top });
1692
+ };
1693
+ const subItemClass = (active, soon) => `flex items-center justify-between gap-2 rounded-[6px] border-0 px-3 text-left !text-[14px] whitespace-nowrap w-full ${phone ? "py-[11px]" : "py-[6px]"} ${soon ? "cursor-default bg-transparent text-jett-ink-400" : active ? "cursor-pointer bg-jett-fill !font-semibold text-jett-ink" : "cursor-pointer bg-transparent !font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink"}`;
1694
+ const renderOptions = (item, index, inFlyout) => item.options.map((option, optionsIndex) => {
1695
+ const subKey = `menu-${index}-option-${optionsIndex}`;
1696
+ const active = activeMenuPath === subKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subKey}-`));
1697
+ const soon = isSoon(option);
1698
+ const hasKids = option.options && option.options.length > 0;
1699
+ return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, id: `${id}-opt-${index}-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
1700
+ "button",
1701
+ {
1702
+ type: "button",
1703
+ disabled: soon,
1704
+ "aria-disabled": soon || void 0,
1705
+ "aria-current": active && !hasKids ? "page" : void 0,
1706
+ "aria-expanded": hasKids ? isMenuOpen(subKey) : void 0,
1707
+ title: soon ? "Not available yet" : void 0,
1708
+ onClick: (e) => soon ? e.preventDefault() : handleSubMenuClick(option, optionsIndex, index, e),
1709
+ className: `${subItemClass(active, soon)} ${inFlyout ? "!py-[7px] !px-2.5" : ""}`
1710
+ },
1711
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: "truncate" }, cleanLabel(option.label)),
1712
+ soon && /* @__PURE__ */ import_react14.default.createElement("span", { className: "text-[11px] font-semibold text-jett-ink-400" }, "Soon"),
1713
+ hasKids && /* @__PURE__ */ import_react14.default.createElement(Chevron, { open: isMenuOpen(subKey) })
1714
+ ), hasKids && isMenuOpen(subKey) && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ml-3 flex flex-col gap-0.5 border-l border-jett-line pl-2" }, option.options.map((sub, subIndex) => {
1715
+ const subActive = activeMenuPath === `${subKey}-sub-${sub.label}`;
1716
+ return /* @__PURE__ */ import_react14.default.createElement("button", { key: subIndex, type: "button", "aria-current": subActive ? "page" : void 0, onClick: () => handleSubSubMenuClick(sub, index, optionsIndex), className: subItemClass(subActive, false) }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "truncate" }, cleanLabel(sub.label)));
1717
+ })));
1718
+ });
1719
+ const flyItem = fly ? navItemsLocal[fly.index] : null;
1720
+ return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, phone && /* @__PURE__ */ import_react14.default.createElement("div", { "data-jett-shell": true, className: "font-jett fixed left-0 top-0 z-50 flex h-14 w-full items-center gap-2.5 border-b border-jett-line bg-jett-surface pl-1 pr-2", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
1721
+ "button",
1722
+ {
1723
+ type: "button",
1724
+ onClick: () => setIsMobileMenuOpen(true),
1725
+ "aria-label": "Open menu",
1726
+ title: "Open menu",
1727
+ className: "flex h-11 w-11 cursor-pointer items-center justify-center rounded-[8px] border-0 bg-transparent text-jett-ink-700 hover:bg-jett-fill",
1728
+ id: `${id}-button-1`
1729
+ },
1730
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M4 6h16M4 12h16M4 18h16" }))
1731
+ ), sideBarLogoLocal ? /* @__PURE__ */ import_react14.default.createElement("img", { src: sideBarLogoLocal, alt: "Logo", className: "h-[26px] max-w-[96px] object-contain", id: `${id}-img-1` }) : /* @__PURE__ */ import_react14.default.createElement(LogoTile, { size: 26 }), /* @__PURE__ */ import_react14.default.createElement("span", { className: "min-w-0 flex-1 truncate text-[15px] font-semibold text-jett-ink" }, activeLabel), /* @__PURE__ */ import_react14.default.createElement("button", { type: "button", onClick: () => setIsMobileMenuOpen(true), "aria-label": "Account", title: "Account", className: "flex h-11 w-11 cursor-pointer items-center justify-center border-0 bg-transparent" }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-jett-ink-800 text-[12px] font-semibold text-white" }, initials(displayName)))), phone && isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed inset-0 z-[69] bg-[rgba(17,24,39,0.5)]", onClick: closeMobileMenu, "aria-hidden": "true", id: `${id}-div-4` }), /* @__PURE__ */ import_react14.default.createElement(
1732
+ "aside",
1733
+ {
1734
+ "data-jett-shell": true,
1735
+ "aria-label": "Main navigation",
1736
+ className: `font-jett flex h-screen flex-col border-r border-jett-line bg-jett-surface text-jett-ink ${phone ? "fixed left-0 top-0 z-[70] max-w-[86vw]" : "relative"} ${ready ? "transition-[width,transform] duration-200 ease-in-out" : ""}`,
1737
+ style: {
1738
+ width: phone ? 280 : collapsed ? 64 : 256,
1739
+ transform: phone && !isMobileMenuOpen ? "translateX(-100%)" : "none",
1740
+ boxShadow: phone && isMobileMenuOpen ? "var(--shadow-jett-drawer)" : "none"
1741
+ },
1742
+ id: `${id}-div-5`
1743
+ },
1744
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: `flex h-16 shrink-0 items-center gap-2.5 border-b border-jett-line-row ${collapsed ? "justify-center px-0" : "px-6"}`, id: `${id}-div-6` }, expanded && sideBarLogoLocal ? /* @__PURE__ */ import_react14.default.createElement("img", { src: sideBarLogoLocal, alt: "Logo", className: "h-8 max-w-[168px] object-contain", id: `${id}-img-2` }) : /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement(LogoTile, null), expanded && /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 whitespace-nowrap text-[15px] font-semibold tracking-[-0.01em] text-jett-ink" }, "JETT Admin")), phone && /* @__PURE__ */ import_react14.default.createElement(
1745
+ "button",
1746
+ {
1747
+ type: "button",
1748
+ onClick: closeMobileMenu,
1749
+ "aria-label": "Close menu",
1750
+ title: "Close menu",
1751
+ className: "-mr-3 ml-auto flex h-11 w-11 cursor-pointer items-center justify-center rounded-[8px] border-0 bg-transparent text-jett-ink-500 hover:bg-jett-fill"
1752
+ },
1753
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M18 6 6 18M6 6l12 12" }))
1754
+ )),
1755
+ /* @__PURE__ */ import_react14.default.createElement("nav", { className: "flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overflow-x-hidden px-3 py-4 scrollbar-hide", id: `${id}-div-9` }, expanded ? /* @__PURE__ */ import_react14.default.createElement(
1756
+ "button",
1757
+ {
1758
+ type: "button",
1759
+ onClick: () => {
1760
+ closeMobileMenu();
1761
+ setPalOpen(true);
1762
+ },
1763
+ className: "mb-2.5 flex h-[34px] w-full shrink-0 cursor-pointer items-center gap-2.5 whitespace-nowrap rounded-[6px] border border-jett-line-soft bg-jett-canvas pl-3 pr-2 text-left text-[13px] text-jett-ink-500 hover:border-jett-line-control hover:text-jett-ink-700"
1764
+ },
1765
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "shrink-0", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "m20 20-3.5-3.5" })),
1766
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1" }, "Jump to\u2026"),
1767
+ !phone && /* @__PURE__ */ import_react14.default.createElement(Kbd, null, MAC ? "\u21E7\u2318K" : "Ctrl \u21E7 K")
1768
+ ) : /* @__PURE__ */ import_react14.default.createElement(
1769
+ "button",
1770
+ {
1771
+ type: "button",
1772
+ onClick: () => setPalOpen(true),
1773
+ title: `Jump to ${MAC ? "\u21E7\u2318K" : "Ctrl \u21E7 K"}`,
1774
+ "aria-label": "Search or jump to",
1775
+ className: "mx-auto mb-2 flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-[8px] border border-jett-line-soft bg-jett-canvas text-jett-ink-500 hover:border-jett-line-control hover:text-jett-ink-700"
1776
+ },
1777
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "m20 20-3.5-3.5" }))
1778
+ ), navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1779
+ const menuKey = `menu-${index}`;
1780
+ const hasOptions = !!(item.options && item.options.length);
1781
+ const isOpen = isMenuOpen(menuKey);
1782
+ const isParent = index === parentIndex;
1783
+ const Icon = item.Icon;
1784
+ const iconEl = Icon ? /* @__PURE__ */ import_react14.default.createElement(Icon, { width: 18, height: 18, strokeWidth: 1.8, className: `shrink-0 ${isParent ? "text-jett-brand" : "text-jett-ink-400"}`, "aria-hidden": "true" }) : null;
1785
+ if (collapsed) {
1786
+ const flying = fly && fly.index === index;
1787
+ return /* @__PURE__ */ import_react14.default.createElement(
1788
+ "button",
1789
+ {
1790
+ key: index,
1791
+ type: "button",
1792
+ title: item.label,
1793
+ "aria-label": item.label,
1794
+ "aria-haspopup": hasOptions ? "menu" : void 0,
1795
+ "aria-expanded": hasOptions ? !!flying : void 0,
1796
+ onClick: (e) => hasOptions ? openFly(index, e) : handleMenuClick(item, index, e),
1797
+ className: `mx-auto flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-[8px] border-0 ${isParent ? "bg-jett-brand-soft" : flying ? "bg-jett-fill" : "bg-transparent hover:bg-jett-fill"}`,
1798
+ id: `${id}-div-12-${index}`
1799
+ },
1800
+ iconEl
1801
+ );
1802
+ }
1803
+ return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "flex flex-col gap-0.5", id: `${id}-div-11-${index}` }, /* @__PURE__ */ import_react14.default.createElement(
1804
+ "button",
1805
+ {
1806
+ type: "button",
1807
+ "aria-expanded": hasOptions ? isOpen : void 0,
1808
+ "aria-current": !hasOptions && isParent ? "page" : void 0,
1809
+ onClick: (e) => handleMenuClick(item, index, e),
1810
+ className: `flex w-full cursor-pointer items-center gap-3 whitespace-nowrap rounded-[6px] border-0 px-3 text-left !text-[14px] ${phone ? "py-3" : "py-2"} ${isParent ? "bg-jett-brand-soft !font-semibold text-jett-brand" : "bg-transparent !font-medium text-jett-ink-700 hover:bg-jett-fill"}`,
1811
+ id: `${id}-div-12-${index}`
1812
+ },
1813
+ iconEl,
1814
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 truncate" }, item.label),
1815
+ hasOptions && /* @__PURE__ */ import_react14.default.createElement("span", { className: isParent ? "text-jett-brand" : "text-jett-ink-400" }, /* @__PURE__ */ import_react14.default.createElement(Chevron, { open: isOpen }))
1816
+ ), hasOptions && isOpen && /* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-1 ml-[27px] mt-0.5 flex flex-col gap-0.5 border-l border-jett-line pl-[13px]", id: `${id}-div-15-${index}` }, renderOptions(item, index, false)));
1817
+ })),
1818
+ !phone && /* @__PURE__ */ import_react14.default.createElement("div", { className: `flex shrink-0 flex-wrap gap-1 border-t border-jett-line-row px-3 py-2 ${collapsed ? "justify-center" : ""}` }, /* @__PURE__ */ import_react14.default.createElement(
1819
+ "button",
1820
+ {
1821
+ type: "button",
1822
+ onClick: () => setHelpOpen(true),
1823
+ title: "Keyboard shortcuts ?",
1824
+ "aria-label": "Keyboard shortcuts",
1825
+ className: `flex h-9 min-w-10 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[6px] border-0 bg-transparent text-[13px] font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink ${collapsed ? "px-0" : "px-3"}`
1826
+ },
1827
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "M6 10h.01M10 10h.01M14 10h.01M18 10h.01M7 14h10" })),
1828
+ expanded && /* @__PURE__ */ import_react14.default.createElement(Kbd, null, "?")
1829
+ ), /* @__PURE__ */ import_react14.default.createElement(
1830
+ "button",
1831
+ {
1832
+ type: "button",
1833
+ onClick: toggleCollapsed,
1834
+ title: collapsed ? "Expand sidebar [" : "Collapse sidebar [",
1835
+ "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
1836
+ "aria-pressed": collapsed,
1837
+ className: `flex h-9 min-w-10 cursor-pointer items-center justify-center gap-2.5 whitespace-nowrap rounded-[6px] border-0 bg-transparent text-[13px] font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink ${collapsed ? "px-0" : "flex-1 px-3"}`
1838
+ },
1839
+ /* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", style: { transform: collapsed ? "scaleX(-1)" : "none" }, "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "M9 4v16M16 10l-2 2 2 2" })),
1840
+ expanded && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 text-left" }, "Collapse"), /* @__PURE__ */ import_react14.default.createElement(Kbd, null, "["))
1841
+ )),
1842
+ /* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative shrink-0 border-t border-jett-line-row px-3 py-3", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
1843
+ "button",
1844
+ {
1845
+ type: "button",
1846
+ onClick: () => {
1847
+ setFly(null);
1848
+ setIsSwitchProfileOpen((prev) => !prev);
1849
+ },
1850
+ title: displayName,
1851
+ "aria-haspopup": "dialog",
1852
+ "aria-expanded": isSwitchProfileOpen,
1853
+ className: `flex w-full cursor-pointer items-center gap-3 rounded-[8px] border border-transparent text-left ${collapsed ? "justify-center p-0" : "p-2.5"} ${isSwitchProfileOpen ? "bg-jett-fill" : "bg-transparent hover:bg-jett-fill"}`,
1854
+ id: `${id}-div-23`
1855
+ },
1856
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-jett-ink-800 text-[13px] font-semibold text-white", id: `${id}-span-3` }, initials(displayName)),
1857
+ expanded && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("span", { className: "min-w-0 flex-1 whitespace-nowrap" }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "block truncate text-[14px] font-medium text-jett-ink-800", id: `${id}-p-1` }, displayName), scopeLabel && /* @__PURE__ */ import_react14.default.createElement("span", { className: "block truncate text-[12px] text-jett-ink-500", id: `${id}-p-2` }, scopeLabel)), /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "m7 15 5 5 5-5M7 9l5-5 5 5" })))
1858
+ ), /* @__PURE__ */ import_react14.default.createElement(
1859
+ SwitchProfileSection,
1860
+ {
1861
+ id: `${id}-switch-profile`,
1862
+ open: isSwitchProfileOpen,
1863
+ anchorRef: profileCardRef,
1864
+ collapsed,
1865
+ scopeLabel,
1866
+ onClose: () => setIsSwitchProfileOpen(false),
1867
+ onManageProfile: () => {
1868
+ setIsSwitchProfileOpen(false);
1869
+ if (onManageProfile) onManageProfile();
1870
+ else window.location.href = "/profile";
1871
+ },
1872
+ onProfileSwitch: (profile) => {
1873
+ setIsSwitchProfileOpen(false);
1874
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
1875
+ },
1876
+ onTmcSettings: () => {
1877
+ setIsSwitchProfileOpen(false);
1878
+ onTmcSettings == null ? void 0 : onTmcSettings();
1879
+ },
1880
+ onLogout: () => {
1881
+ setIsSwitchProfileOpen(false);
1882
+ clearProfileSwitchFlag();
1883
+ if (onLogout) {
1884
+ onLogout();
1885
+ } else {
1886
+ window.location.href = `${window.location.origin}/login/logout`;
1887
+ }
1888
+ }
1889
+ }
1890
+ ))
1891
+ ), collapsed && flyItem && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed inset-0 z-[79]", onClick: () => setFly(null), "aria-hidden": "true" }), /* @__PURE__ */ import_react14.default.createElement(
1892
+ "div",
1893
+ {
1894
+ "data-jett-shell": true,
1895
+ role: "menu",
1896
+ "aria-label": flyItem.label,
1897
+ className: "font-jett fixed z-[80] flex w-[220px] flex-col gap-0.5 rounded-[10px] border border-jett-line bg-jett-surface p-1.5 shadow-jett-pop",
1898
+ style: { left: 72, top: fly.top }
1899
+ },
1900
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "px-2.5 pb-2 pt-1.5 text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400" }, flyItem.label),
1901
+ renderOptions(flyItem, fly.index, true)
1902
+ )), /* @__PURE__ */ import_react14.default.createElement(CommandPalette, { id: `${id}-palette`, open: palOpen, onClose: () => setPalOpen(false), commands }), /* @__PURE__ */ import_react14.default.createElement(ShortcutsSheet, { id: `${id}-shortcuts`, open: helpOpen, onClose: () => setHelpOpen(false), sections: helpSections }));
1903
+ };
1904
+
1905
+ // src/RightSheet/RightSheet.jsx
1906
+ var import_react15 = __toESM(require("react"));
1907
+ var RightSheet = ({
1908
+ id = "right-sheet",
1909
+ open,
1910
+ setOpen,
1911
+ children,
1912
+ callBack,
1913
+ actionLabel = "Save",
1914
+ onAction = () => {
1915
+ },
1916
+ showFooter = true
1917
+ }) => {
1918
+ const [visible, setVisible] = (0, import_react15.useState)(open);
1919
+ (0, import_react15.useEffect)(() => {
1920
+ if (open) {
1921
+ document.body.style.overflow = "hidden";
1922
+ setVisible(true);
1923
+ }
1924
+ return () => {
1925
+ document.body.style.overflow = "auto";
1926
+ };
1927
+ }, [open]);
1928
+ const handleClose = () => {
1929
+ setVisible(false);
1930
+ setTimeout(() => {
1931
+ setOpen(false);
1932
+ callBack();
1933
+ }, 200);
1934
+ };
1935
+ const handleAction = () => {
1936
+ onAction();
1937
+ handleClose();
1938
+ };
1939
+ if (!visible) return null;
1940
+ return /* @__PURE__ */ import_react15.default.createElement(
1941
+ "div",
1942
+ {
1943
+ className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1944
+ onClick: handleClose,
1945
+ id: `${id}-div-1`
1946
+ },
1947
+ /* @__PURE__ */ import_react15.default.createElement(
1948
+ "div",
1949
+ {
1950
+ className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1951
+ ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1952
+ onClick: (e) => e.stopPropagation(),
1953
+ id: `${id}-div-2`
1954
+ },
1955
+ /* @__PURE__ */ import_react15.default.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1956
+ showFooter && /* @__PURE__ */ import_react15.default.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1957
+ )
1958
+ );
1959
+ };
1960
+
1961
+ // src/Table/CustomTable.jsx
1962
+ var import_react16 = __toESM(require("react"));
1963
+ var CustomTable = ({
1964
+ id = "custom-table",
1965
+ tableHeader,
1966
+ setIsAllChecked,
1967
+ isAllChecked,
1968
+ children,
1969
+ isHideCheckbox = "false"
1970
+ }) => {
1971
+ return /* @__PURE__ */ import_react16.default.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ import_react16.default.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ import_react16.default.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ import_react16.default.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ import_react16.default.createElement(
1972
+ "tr",
1973
+ {
1974
+ className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1975
+ id: `${id}-tr-1`
1976
+ },
1977
+ !isHideCheckbox && /* @__PURE__ */ import_react16.default.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ import_react16.default.createElement(
1978
+ CustomCheckbox,
1979
+ {
1980
+ checked: isAllChecked,
1981
+ onChange: () => {
1982
+ setIsAllChecked(!isAllChecked);
1983
+ },
1984
+ id: `${id}-custom-checkbox-1`
1985
+ }
1986
+ )),
1987
+ tableHeader.map((header, index) => {
1988
+ return /* @__PURE__ */ import_react16.default.createElement(
1989
+ "th",
1990
+ {
1991
+ className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1992
+ key: header + index,
1993
+ id: `${id}-th-2-${index}`
1994
+ },
1995
+ header
1996
+ );
1997
+ })
1998
+ )), /* @__PURE__ */ import_react16.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1999
+ };
2000
+
2001
+ // src/inputs/CustomSelect.jsx
2002
+ var import_react17 = __toESM(require("react"));
2003
+ var import_lucide_react7 = require("lucide-react");
2004
+ var CustomSelect = ({
2005
+ id = "custom-select",
2006
+ label,
2007
+ value,
2008
+ onChange,
2009
+ options,
2010
+ placeholder = "Select...",
2011
+ isRequired = false,
2012
+ error,
2013
+ heading,
2014
+ disabled = false
2015
+ }) => {
2016
+ const [open, setOpen] = (0, import_react17.useState)(false);
2017
+ const [search, setSearch] = (0, import_react17.useState)("");
2018
+ const wrapperRef = (0, import_react17.useRef)(null);
2019
+ const handleBlur = (e) => {
2020
+ var _a;
2021
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
2022
+ setOpen(false);
2023
+ }
2024
+ };
2025
+ const filteredOptions = options.filter(
2026
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
2027
+ );
2028
+ const handleSelect = (val) => {
2029
+ onChange(val);
2030
+ setOpen(false);
2031
+ };
2032
+ const selectedOption = options.find((opt) => opt.value === value);
2033
+ return /* @__PURE__ */ import_react17.default.createElement(
2034
+ "div",
2035
+ {
2036
+ className: "flex flex-col w-full relative",
2037
+ ref: wrapperRef,
2038
+ tabIndex: disabled ? -1 : 0,
2039
+ onBlur: handleBlur,
2040
+ id: `${id}-div-1`
2041
+ },
2042
+ heading && /* @__PURE__ */ import_react17.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
2043
+ label && /* @__PURE__ */ import_react17.default.createElement(
2044
+ "label",
2045
+ {
2046
+ className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
2047
+ id: `${id}-label-1`
2048
+ },
2049
+ label,
2050
+ " ",
2051
+ isRequired && /* @__PURE__ */ import_react17.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
2052
+ ),
2053
+ /* @__PURE__ */ import_react17.default.createElement(
2054
+ "div",
2055
+ {
2056
+ onClick: () => !disabled && setOpen((prev) => !prev),
2057
+ 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
2058
+ ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
2059
+ ${error ? "border-red-500" : "border-gray-300"}
2060
+ `,
2061
+ id: `${id}-div-2`
2062
+ },
2063
+ /* @__PURE__ */ import_react17.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
2064
+ /* @__PURE__ */ import_react17.default.createElement(
2065
+ import_lucide_react7.ChevronDown,
2066
+ {
2067
+ className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
2068
+ }
2069
+ )
2070
+ ),
2071
+ open && !disabled && /* @__PURE__ */ import_react17.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react17.default.createElement(import_lucide_react7.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react17.default.createElement(
2072
+ "input",
2073
+ {
2074
+ type: "text",
2075
+ value: search,
2076
+ onChange: (e) => setSearch(e.target.value),
2077
+ placeholder: "Search...",
2078
+ className: "flex-1 text-sm focus:outline-none",
2079
+ id: `${id}-input-1`
2080
+ }
2081
+ )), /* @__PURE__ */ import_react17.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react17.default.createElement(
2082
+ "li",
2083
+ {
2084
+ key: opt.value,
2085
+ onClick: () => handleSelect(opt.value),
2086
+ 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" : ""}`,
2087
+ id: `${id}-li-1`
2088
+ },
2089
+ opt.label
2090
+ )) : /* @__PURE__ */ import_react17.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
2091
+ );
2092
+ };
2093
+
2094
+ // src/inputs/Dropdown.jsx
2095
+ var import_react18 = __toESM(require("react"));
2096
+ var import_react_select = __toESM(require("react-select"));
2097
+ var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
2098
+ function buildStyles(isDark, error) {
2099
+ return {
2100
+ control: (base, state) => ({
2101
+ ...base,
2102
+ minHeight: "40px !important",
2103
+ fontSize: 14,
2104
+ borderRadius: "6px",
2105
+ boxShadow: "none",
2106
+ backgroundColor: state.isDisabled ? "#f3f4f6" : error ? "#fef2f2" : isDark ? "#18181b" : "#ffffff",
2107
+ borderColor: state.isDisabled ? "#d1d5db" : error ? "#ef4444" : isDark ? "#303036" : "#e5e5e5",
2108
+ outline: state.isFocused ? "2px solid #000" : "none",
2109
+ outlineOffset: "2px",
2110
+ "&:hover": {
2111
+ borderColor: error ? "#ef4444" : "none"
2112
+ }
2113
+ }),
2114
+ menu: (base) => ({
2115
+ ...base,
2116
+ backgroundColor: isDark ? "#18181b" : "#ffffff",
2117
+ zIndex: 9999
2118
+ }),
2119
+ menuPortal: (base) => ({ ...base, zIndex: 9999 }),
2120
+ option: (base, state) => ({
2121
+ ...base,
2122
+ fontSize: 14,
2123
+ cursor: "pointer",
2124
+ backgroundColor: state.isSelected ? "#0087FA" : state.isFocused ? isDark ? "#303036" : "#EBF5FF" : "transparent",
2125
+ color: state.isSelected ? "#ffffff" : isDark ? "#f3f4f6" : "#111827",
2126
+ "&:active": { backgroundColor: "#0087FA", color: "#ffffff" }
2127
+ }),
2128
+ singleValue: (base, state) => ({
2129
+ ...base,
2130
+ fontSize: 14,
2131
+ fontWeight: 400,
2132
+ color: state.isDisabled ? "#6b7280" : isDark ? "#f3f4f6" : "#111827"
2133
+ }),
2134
+ multiValue: (base) => ({
2135
+ ...base,
2136
+ backgroundColor: isDark ? "#303036" : "#EBF5FF"
2137
+ }),
2138
+ multiValueLabel: (base) => ({
2139
+ ...base,
2140
+ fontSize: 12,
2141
+ color: isDark ? "#f3f4f6" : "#0087FA"
2142
+ }),
2143
+ multiValueRemove: (base) => ({
2144
+ ...base,
2145
+ color: isDark ? "#9ca3af" : "#0087FA",
2146
+ "&:hover": { backgroundColor: "#0087FA", color: "#ffffff" }
2147
+ }),
2148
+ placeholder: (base) => ({
2149
+ ...base,
2150
+ fontSize: 14,
2151
+ fontWeight: 400,
2152
+ color: "#6b7280"
2153
+ }),
2154
+ input: (base) => ({
2155
+ ...base,
2156
+ fontSize: 14,
2157
+ fontWeight: 400,
2158
+ color: isDark ? "#f3f4f6" : "#111827"
2159
+ }),
2160
+ indicatorSeparator: () => ({ display: "none" }),
2161
+ dropdownIndicator: (base) => ({
2162
+ ...base,
2163
+ padding: "0 6px",
2164
+ color: isDark ? "#9ca3af" : "#6b7280"
2165
+ }),
2166
+ clearIndicator: (base) => ({
2167
+ ...base,
2168
+ padding: "0 4px",
2169
+ color: isDark ? "#9ca3af" : "#6b7280",
2170
+ cursor: "pointer",
2171
+ "&:hover": { color: "#0087FA" }
2172
+ }),
2173
+ valueContainer: (base) => ({ ...base, padding: "2px 16px" })
2174
+ };
2175
+ }
2176
+ var Dropdown = import_react18.default.forwardRef(
2177
+ ({
2178
+ id = "dropdown",
2179
+ options,
2180
+ placeholder = "Select...",
2181
+ isDisabled = false,
2182
+ isClearable = true,
2183
+ isLoading = false,
2184
+ error = false,
2185
+ label,
2186
+ heading,
2187
+ isRequired = false,
2188
+ name,
2189
+ menuPortalTarget,
2190
+ menuPosition = "absolute",
2191
+ className,
2192
+ style,
2193
+ isMulti = false,
2194
+ value,
2195
+ onChange
2196
+ }, ref) => {
2197
+ const reactId = (0, import_react18.useId)();
2198
+ const isDark = isDarkMode();
2199
+ const styles = (0, import_react18.useMemo)(() => buildStyles(isDark, !!error), [isDark, error]);
2200
+ const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
2201
+ const handleChange = (selected) => {
2202
+ if (isMulti) {
2203
+ onChange((selected ?? []).map((o) => o.value));
2204
+ } else {
2205
+ onChange((selected == null ? void 0 : selected.value) ?? null);
2206
+ }
2207
+ };
2208
+ return /* @__PURE__ */ import_react18.default.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react18.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ import_react18.default.createElement(
2209
+ "label",
2210
+ {
2211
+ htmlFor: reactId,
2212
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
2213
+ id: `${id}-label-1`
2214
+ },
2215
+ label,
2216
+ isRequired && /* @__PURE__ */ import_react18.default.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
2217
+ ), /* @__PURE__ */ import_react18.default.createElement(
2218
+ import_react_select.default,
2219
+ {
2220
+ ref,
2221
+ inputId: reactId,
2222
+ name,
2223
+ options,
2224
+ value: selectedValue,
2225
+ onChange: handleChange,
2226
+ placeholder,
2227
+ isDisabled,
2228
+ isClearable,
2229
+ isLoading,
2230
+ isMulti,
2231
+ styles,
2232
+ menuPortalTarget,
2233
+ menuPosition,
2234
+ classNamePrefix: "jett-dropdown"
2235
+ }
2236
+ ));
2237
+ }
2238
+ );
2239
+ Dropdown.displayName = "Dropdown";
2240
+
2241
+ // src/Calendar/Calendar.tsx
2242
+ var import_react19 = __toESM(require("react"));
2243
+ var import_dates = require("@mantine/dates");
2244
+ var Calendar = (props) => {
2245
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2246
+ const {
2247
+ minDate,
2248
+ maxDate,
2249
+ excludeDate,
2250
+ firstDayOfWeek = 1,
2251
+ locale,
2252
+ size,
2253
+ className,
2254
+ error
2255
+ } = props;
2256
+ const isRange = props.mode === "range";
2257
+ const isDateTime = props.mode === "datetime";
2258
+ const datesProviderSettings = {
2259
+ firstDayOfWeek,
2260
+ consistentWeeks: true
2261
+ };
2262
+ if (locale) {
2263
+ datesProviderSettings.locale = locale;
2264
+ }
2265
+ const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
2266
+ const [displayDate, setDisplayDate] = (0, import_react19.useState)(anchorDate ?? void 0);
2267
+ const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
2268
+ (0, import_react19.useEffect)(() => {
2269
+ if (anchorTime !== void 0) {
2270
+ setDisplayDate(new Date(anchorTime));
2271
+ }
2272
+ }, [anchorTime]);
2273
+ const weekendColorStyle = {
2274
+ "--mantine-color-red-6": "var(--mantine-color-text)"
2275
+ };
2276
+ if (isRange) {
2277
+ const datePickerProps2 = {
2278
+ type: "range",
2279
+ value: props.value,
2280
+ defaultValue: props.defaultValue,
2281
+ onChange: props.onChange,
2282
+ minDate,
2283
+ maxDate,
2284
+ excludeDate,
2285
+ size,
2286
+ className,
2287
+ date: displayDate,
2288
+ onDateChange: setDisplayDate,
2289
+ style: weekendColorStyle
2290
+ };
2291
+ return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DatePicker, { ...datePickerProps2 }));
2292
+ }
2293
+ if (isDateTime) {
2294
+ const dateTimePickerProps = {
2295
+ value: props.value,
2296
+ defaultValue: props.defaultValue,
2297
+ onChange: props.onChange,
2298
+ minDate,
2299
+ maxDate,
2300
+ excludeDate,
2301
+ size,
2302
+ className,
2303
+ error,
2304
+ style: weekendColorStyle
2305
+ };
2306
+ return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DateTimePicker, { ...dateTimePickerProps }));
2307
+ }
2308
+ const datePickerProps = {
2309
+ value: props.value,
2310
+ defaultValue: props.defaultValue,
2311
+ onChange: props.onChange,
2312
+ minDate,
2313
+ maxDate,
2314
+ excludeDate,
2315
+ size,
2316
+ className,
2317
+ date: displayDate,
2318
+ onDateChange: setDisplayDate,
2319
+ style: weekendColorStyle
2320
+ };
2321
+ return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DatePicker, { ...datePickerProps }));
2322
+ };
2323
+
2324
+ // src/Pagination/Pagination.jsx
2325
+ var import_react20 = __toESM(require("react"));
2326
+ var import_lucide_react8 = require("lucide-react");
2327
+ var Pagination = ({
2328
+ id = "pagination",
2329
+ data = [],
2330
+ component: Component,
2331
+ itemsPerPage = 6,
2332
+ itemsPerPageOptions = [5, 10, 20, 50, 100],
2333
+ // Controlled props (optional)
2334
+ currentPage: controlledCurrentPage,
2335
+ onPageChange: controlledOnPageChange,
2336
+ onItemsPerPageChange: controlledOnItemsPerPageChange,
2337
+ // Legacy props for backward compatibility
2338
+ totalPages,
2339
+ totalItems: legacyTotalItems,
2340
+ onPageChange: legacyOnPageChange,
2341
+ onItemsPerPageChange: legacyOnItemsPerPageChange,
2342
+ tableHeader,
2343
+ isHideCheckbox,
2344
+ callback,
2345
+ isTable = false,
2346
+ // Component props - any additional props to pass to the component
2347
+ componentProps = {},
2348
+ ...restProps
2349
+ }) => {
2350
+ const [internalCurrentPage, setInternalCurrentPage] = (0, import_react20.useState)(1);
2351
+ const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react20.useState)(itemsPerPage);
2352
+ const isControlled = controlledCurrentPage !== void 0;
2353
+ const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
2354
+ const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
2355
+ const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
2356
+ const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
2357
+ const calculatedTotalPages = (0, import_react20.useMemo)(() => {
2358
+ if (totalItems > 0 && activeItemsPerPage > 0) {
2359
+ return Math.ceil(totalItems / activeItemsPerPage);
2360
+ }
2361
+ return 1;
2362
+ }, [totalItems, activeItemsPerPage]);
2363
+ const paginatedData = (0, import_react20.useMemo)(() => {
2364
+ if (!data || data.length === 0) return [];
2365
+ const startIndex = (currentPage - 1) * activeItemsPerPage;
2366
+ const endIndex = startIndex + activeItemsPerPage;
2367
+ return data.slice(startIndex, endIndex);
2368
+ }, [data, currentPage, activeItemsPerPage]);
2369
+ (0, import_react20.useEffect)(() => {
2370
+ if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
2371
+ setInternalCurrentPage(1);
2372
+ }
2373
+ }, [calculatedTotalPages, isControlled, currentPage]);
2374
+ const getPageNumbers = () => {
2375
+ const pages = [];
2376
+ const maxVisible = 5;
2377
+ let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
2378
+ let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
2379
+ if (endPage - startPage < maxVisible - 1) {
2380
+ startPage = Math.max(1, endPage - maxVisible + 1);
2381
+ }
2382
+ for (let i = startPage; i <= endPage; i++) {
2383
+ pages.push(i);
2384
+ }
2385
+ return pages;
2386
+ };
2387
+ const handlePageChange = (page) => {
2388
+ if (page >= 1 && page <= calculatedTotalPages) {
2389
+ if (isControlled && controlledOnPageChange) {
2390
+ controlledOnPageChange(page);
2391
+ } else if (legacyOnPageChange) {
2392
+ legacyOnPageChange(page);
2393
+ } else {
2394
+ setInternalCurrentPage(page);
2395
+ }
2396
+ }
2397
+ };
2398
+ const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
2399
+ const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
2400
+ const renderContent = () => {
2401
+ if (Component) {
2402
+ if (import_react20.default.isValidElement(Component)) {
2403
+ const ComponentType = Component.type;
2404
+ const elementProps = Component.props;
2405
+ if (isTable) {
2406
+ return /* @__PURE__ */ import_react20.default.createElement(
2407
+ CustomTable,
2408
+ {
2409
+ tableHeader,
2410
+ isHideCheckbox,
2411
+ id: `${id}-custom-table-1`
2412
+ },
2413
+ data.map((item, index) => {
2414
+ return /* @__PURE__ */ import_react20.default.createElement(
2415
+ ComponentType,
2416
+ {
2417
+ key: item.id || item._id || index,
2418
+ data: item,
2419
+ ...elementProps,
2420
+ ...componentProps,
2421
+ ...restProps,
2422
+ id: `${id}-component-type-1-${index}`
2423
+ }
2424
+ );
2425
+ })
2426
+ );
2427
+ } else {
2428
+ if (isTable) {
2429
+ return /* @__PURE__ */ import_react20.default.createElement(
2430
+ CustomTable,
2431
+ {
2432
+ tableHeader,
2433
+ isHideCheckbox,
2434
+ id: `${id}-custom-table-2`
2435
+ },
2436
+ paginatedData.map((item, index) => {
2437
+ return /* @__PURE__ */ import_react20.default.createElement(
2438
+ ComponentType,
2439
+ {
2440
+ key: item.id || item._id || index,
2441
+ data: item,
2442
+ ...elementProps,
2443
+ ...componentProps,
2444
+ ...restProps,
2445
+ id: `${id}-component-type-2-${index}`
2446
+ }
2447
+ );
2448
+ })
2449
+ );
2450
+ }
2451
+ }
2452
+ } else {
2453
+ return /* @__PURE__ */ import_react20.default.createElement(
2454
+ CustomTable,
2455
+ {
2456
+ tableHeader,
2457
+ isHideCheckbox,
2458
+ id: `${id}-custom-table-3`
2459
+ },
2460
+ paginatedData.map((item, index) => {
2461
+ return /* @__PURE__ */ import_react20.default.createElement(
2462
+ Component,
2463
+ {
2464
+ key: item.id || item._id || index,
2465
+ data: item,
2466
+ ...componentProps,
2467
+ ...restProps,
2468
+ id: `${id}-component-1-${index}`
2469
+ }
2470
+ );
2471
+ })
2472
+ );
2473
+ }
2474
+ }
2475
+ return null;
2476
+ };
2477
+ return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react20.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react20.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react20.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react20.default.createElement(
2478
+ "button",
2479
+ {
2480
+ onClick: () => handlePageChange(1),
2481
+ disabled: currentPage === 1,
2482
+ 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]"}`,
2483
+ title: "First page",
2484
+ id: `${id}-button-1`
2485
+ },
2486
+ /* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronsLeft, { size: 16 })
2487
+ ), /* @__PURE__ */ import_react20.default.createElement(
2488
+ "button",
2489
+ {
2490
+ onClick: () => handlePageChange(currentPage - 1),
2491
+ disabled: currentPage === 1,
2492
+ 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]"}`,
2493
+ title: "Previous page",
2494
+ id: `${id}-button-2`
2495
+ },
2496
+ /* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronLeft, { size: 16 })
2497
+ ), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react20.default.createElement(
2498
+ "button",
2499
+ {
2500
+ key: pageNum,
2501
+ onClick: () => handlePageChange(pageNum),
2502
+ 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]"}`,
2503
+ id: `${id}-button-3`
2504
+ },
2505
+ pageNum
2506
+ )), /* @__PURE__ */ import_react20.default.createElement(
2507
+ "button",
2508
+ {
2509
+ onClick: () => handlePageChange(currentPage + 1),
2510
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2511
+ 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]"}`,
2512
+ title: "Next page",
2513
+ id: `${id}-button-4`
2514
+ },
2515
+ /* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronRight, { size: 16 })
2516
+ ), /* @__PURE__ */ import_react20.default.createElement(
2517
+ "button",
2518
+ {
2519
+ onClick: () => handlePageChange(calculatedTotalPages),
2520
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
2521
+ 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]"}`,
2522
+ title: "Last page",
2523
+ id: `${id}-button-5`
2524
+ },
2525
+ /* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronsRight, { size: 16 })
2526
+ ))));
2527
+ };
2528
+ // Annotate the CommonJS export names for ESM import in node:
2529
+ 0 && (module.exports = {
2530
+ AppSideBar,
2531
+ Calendar,
2532
+ Chip,
2533
+ CustomAutocomplete,
2534
+ CustomButton,
2535
+ CustomCheckbox,
2536
+ CustomInput,
2537
+ CustomSearch,
2538
+ CustomSelect,
2539
+ CustomSwitch,
2540
+ CustomTable,
2541
+ CustomTextarea,
2542
+ CustomUpload,
2543
+ Dropdown,
2544
+ Pagination,
2545
+ ProgressBar,
2546
+ RightSheet
2547
+ });