chordia-ui 3.8.3 → 3.8.4

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 (45) hide show
  1. package/dist/ConfirmationPopup.cjs.js +2 -0
  2. package/dist/ConfirmationPopup.cjs.js.map +1 -0
  3. package/dist/ConfirmationPopup.es.js +281 -0
  4. package/dist/ConfirmationPopup.es.js.map +1 -0
  5. package/dist/DataTable2.cjs.js +1 -1
  6. package/dist/DataTable2.cjs.js.map +1 -1
  7. package/dist/DataTable2.es.js +211 -209
  8. package/dist/DataTable2.es.js.map +1 -1
  9. package/dist/PerformancePanel.cjs.js +1 -1
  10. package/dist/PerformancePanel.cjs.js.map +1 -1
  11. package/dist/PerformancePanel.es.js +495 -478
  12. package/dist/PerformancePanel.es.js.map +1 -1
  13. package/dist/Toast.cjs.js +2 -2
  14. package/dist/Toast.cjs.js.map +1 -1
  15. package/dist/Toast.es.js +237 -220
  16. package/dist/Toast.es.js.map +1 -1
  17. package/dist/components/UpdatedInteractionDetails.cjs.js +4 -4
  18. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  19. package/dist/components/UpdatedInteractionDetails.es.js +577 -543
  20. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  21. package/dist/components/common.cjs.js +1 -1
  22. package/dist/components/common.es.js +15 -13
  23. package/dist/components/common.es.js.map +1 -1
  24. package/dist/components/reports.cjs.js +11 -0
  25. package/dist/components/reports.cjs.js.map +1 -0
  26. package/dist/components/reports.es.js +1530 -0
  27. package/dist/components/reports.es.js.map +1 -0
  28. package/dist/index.cjs.js +1 -1
  29. package/dist/index.es.js +116 -110
  30. package/dist/index.es.js.map +1 -1
  31. package/dist/style.css +1 -1
  32. package/package.json +5 -1
  33. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +32 -1
  34. package/src/components/UpdatedInteractionDetails/UpdatedInteractionScores.jsx +116 -46
  35. package/src/components/common/AskCompass.jsx +34 -3
  36. package/src/components/common/ConfirmationPopup.jsx +288 -0
  37. package/src/components/common/index.js +1 -0
  38. package/src/components/data/DataTable2.jsx +10 -4
  39. package/src/components/index.js +8 -0
  40. package/src/components/performance/PerformanceDetailsPage.jsx +30 -24
  41. package/src/components/performance/PerformancePanel.jsx +38 -28
  42. package/src/components/reports/ReportsDetails.jsx +1036 -0
  43. package/src/components/reports/ReportsList.jsx +573 -0
  44. package/src/components/reports/index.js +2 -0
  45. package/src/tokens/colors.css +42 -0
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react/jsx-runtime"),j=require("react"),C=require("react-dom"),R=require("lucide-react"),t={ink:"var(--color-text)",border:"var(--grey-absent)",white:"var(--grey-white)",headerBg:"var(--surface-hover)",neutral850:"var(--neutral-850)",neutral50:"var(--neutral-50)"},o="var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)";function I({open:l=!1,title:s="",content:c="",itemName:u="",primaryLabel:f="Cancel",onPrimary:n,secondaryLabel:p="Confirm",onSecondary:a,onClose:d,closeOnOverlayClick:x=!0,className:b="",style:y,container:k,zIndex:w=1e3,inline:r=!1}){if(j.useEffect(()=>{if(!l||r)return;const i=v=>{var h;v.key==="Escape"&&((h=d||n)==null||h())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[l,d,n,r]),!l||!r&&typeof document>"u")return null;const g=e.jsxs("div",{role:"dialog","aria-modal":r?void 0:"true","aria-labelledby":s?"cdr-confirm-title":void 0,className:b,onClick:i=>i.stopPropagation(),style:{background:t.white,borderRadius:8,display:"flex",flexDirection:"column",alignItems:"stretch",width:"100%",maxWidth:360,boxShadow:r?"0 4px 16px rgba(0, 0, 0, 0.08)":"0 10px 32px rgba(0, 0, 0, 0.18)",overflow:"hidden",fontFamily:o,color:t.ink,...y},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:16,background:t.headerBg,borderTopLeftRadius:8,borderTopRightRadius:8},children:[e.jsx("p",{id:"cdr-confirm-title",style:{margin:0,fontFamily:o,fontSize:18,color:t.ink,lineHeight:"normal",wordBreak:"break-word"},children:s}),e.jsx("button",{type:"button","aria-label":"Close",onClick:()=>{var i;return(i=d||n)==null?void 0:i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,border:"none",background:"transparent",cursor:"pointer",color:t.ink,flexShrink:0},children:e.jsx(R.X,{size:20,strokeWidth:1.75})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:16,paddingTop:16,width:"100%",boxSizing:"border-box"},children:[e.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:8,fontFamily:o,fontSize:16,color:t.ink,lineHeight:"normal",wordBreak:"break-word"},children:[u&&e.jsx("p",{style:{margin:0,fontFamily:o,fontSize:16,fontWeight:600,color:t.ink,wordBreak:"break-word"},children:`"${u}"`}),c&&e.jsx("div",{style:{margin:0},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,paddingTop:12,paddingBottom:12,paddingRight:16,borderTop:`1px solid ${t.border}`,width:"100%",boxSizing:"border-box"},children:[f&&e.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:32,padding:"0 16px",borderRadius:10,border:"none",background:t.neutral850,cursor:"pointer",fontFamily:o,fontWeight:600,fontSize:14,color:t.neutral50,whiteSpace:"nowrap"},children:f}),p&&e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:32,padding:"0 16px",borderRadius:10,border:`1px solid ${t.border}`,background:t.white,cursor:"pointer",fontFamily:o,fontWeight:600,fontSize:14,color:t.ink,whiteSpace:"nowrap"},children:p})]})]})]});if(r)return g;const m=e.jsx("div",{role:"presentation",onClick:x?()=>{var i;return(i=d||n)==null?void 0:i()}:void 0,style:{position:"fixed",inset:0,zIndex:w,background:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:g});return C.createPortal(m,k||document.body)}exports.ConfirmationPopup=I;
2
+ //# sourceMappingURL=ConfirmationPopup.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmationPopup.cjs.js","sources":["../src/components/common/ConfirmationPopup.jsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X } from \"lucide-react\";\n\n// Color values resolve to CSS variables declared in `src/tokens/colors.css`.\nconst C = {\n ink: \"var(--color-text)\",\n border: \"var(--grey-absent)\",\n white: \"var(--grey-white)\",\n headerBg: \"var(--surface-hover)\",\n neutral850: \"var(--neutral-850)\",\n neutral50: \"var(--neutral-50)\",\n};\n\nconst FONT_DISPLAY = \"var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)\";\n\n// Generic two-button confirmation dialog (Figma node 6294:4785).\n//\n// Visual layout:\n// ┌──────────────────────────────────┐\n// │ Title [X] │ ← header (surface-hover bg)\n// ├──────────────────────────────────┤\n// │ │\n// │ Content / description… │ ← body\n// │ │\n// ├──────────────────────────────────┤\n// │ [Primary] [Secondary]│ ← actions\n// └──────────────────────────────────┘\n//\n// The \"primary\" button is the dark, bold one on the LEFT — matching the\n// destructive-flow convention in the design where the safe action is given\n// the prominent treatment. The \"secondary\" button is the outlined one on\n// the right. Hosts decide which semantic (Cancel vs Delete) maps to which.\nexport default function ConfirmationPopup({\n // Controls visibility. When false, nothing renders.\n open = false,\n // Header title.\n title = \"\",\n // Body content — string or any ReactNode for richer content.\n content = \"\",\n // Optional name of the item being acted on (e.g. report title). When\n // provided, it's surfaced above `content` as a bold, quoted line so the\n // user sees exactly which record they're confirming.\n itemName = \"\",\n // Left, dark/primary button.\n primaryLabel = \"Cancel\",\n onPrimary,\n // Right, outlined/secondary button.\n secondaryLabel = \"Confirm\",\n onSecondary,\n // Fires when the user clicks the header [X] or presses ESC.\n // Falls back to `onPrimary` (since the dark button is the safe default).\n onClose,\n // Optional: click on the dim overlay also closes. Defaults to true.\n closeOnOverlayClick = true,\n // Optional className applied to the dialog box itself for layout overrides.\n className = \"\",\n // Optional inline style overrides for the dialog box.\n style,\n // Where to mount the portal. Defaults to document.body in the browser.\n container,\n // z-index for the overlay (dialog sits one above).\n zIndex = 1000,\n // When true, renders just the dialog box inline (no overlay, no portal,\n // no ESC handling). Used by the library showcase so the component can be\n // previewed in place alongside other static examples.\n inline = false,\n}) {\n // Close on ESC. Bound only while the dialog is open (skipped in inline mode).\n React.useEffect(() => {\n if (!open || inline) return undefined;\n const handler = (event) => {\n if (event.key === \"Escape\") {\n (onClose || onPrimary)?.();\n }\n };\n window.addEventListener(\"keydown\", handler);\n return () => window.removeEventListener(\"keydown\", handler);\n }, [open, onClose, onPrimary, inline]);\n\n if (!open) return null;\n if (!inline && typeof document === \"undefined\") return null;\n\n const box = (\n <div\n role=\"dialog\"\n aria-modal={inline ? undefined : \"true\"}\n aria-labelledby={title ? \"cdr-confirm-title\" : undefined}\n className={className}\n onClick={(e) => e.stopPropagation()}\n style={{\n background: C.white,\n borderRadius: 8,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n width: \"100%\",\n maxWidth: 360,\n boxShadow: inline ? \"0 4px 16px rgba(0, 0, 0, 0.08)\" : \"0 10px 32px rgba(0, 0, 0, 0.18)\",\n overflow: \"hidden\",\n fontFamily: FONT_DISPLAY,\n color: C.ink,\n ...style,\n }}\n >\n {/* Header */}\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: 16,\n background: C.headerBg,\n borderTopLeftRadius: 8,\n borderTopRightRadius: 8,\n }}\n >\n <p\n id=\"cdr-confirm-title\"\n style={{\n margin: 0,\n fontFamily: FONT_DISPLAY,\n fontSize: 18,\n color: C.ink,\n lineHeight: \"normal\",\n wordBreak: \"break-word\",\n }}\n >\n {title}\n </p>\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={() => (onClose || onPrimary)?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 20,\n height: 20,\n padding: 0,\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n color: C.ink,\n flexShrink: 0,\n }}\n >\n <X size={20} strokeWidth={1.75} />\n </button>\n </div>\n\n {/* Content + actions */}\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n gap: 16,\n paddingTop: 16,\n width: \"100%\",\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n padding: 16,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 8,\n fontFamily: FONT_DISPLAY,\n fontSize: 16,\n color: C.ink,\n lineHeight: \"normal\",\n wordBreak: \"break-word\",\n }}\n >\n {itemName && (\n <p\n style={{\n margin: 0,\n fontFamily: FONT_DISPLAY,\n fontSize: 16,\n fontWeight: 600,\n color: C.ink,\n wordBreak: \"break-word\",\n }}\n >\n {`\"${itemName}\"`}\n </p>\n )}\n {content && (\n <div style={{ margin: 0 }}>{content}</div>\n )}\n </div>\n\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-end\",\n gap: 16,\n paddingTop: 12,\n paddingBottom: 12,\n paddingRight: 16,\n borderTop: `1px solid ${C.border}`,\n width: \"100%\",\n boxSizing: \"border-box\",\n }}\n >\n {primaryLabel && (\n <button\n type=\"button\"\n onClick={() => onPrimary?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: 32,\n padding: \"0 16px\",\n borderRadius: 10,\n border: \"none\",\n background: C.neutral850,\n cursor: \"pointer\",\n fontFamily: FONT_DISPLAY,\n fontWeight: 600,\n fontSize: 14,\n color: C.neutral50,\n whiteSpace: \"nowrap\",\n }}\n >\n {primaryLabel}\n </button>\n )}\n {secondaryLabel && (\n <button\n type=\"button\"\n onClick={() => onSecondary?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: 32,\n padding: \"0 16px\",\n borderRadius: 10,\n border: `1px solid ${C.border}`,\n background: C.white,\n cursor: \"pointer\",\n fontFamily: FONT_DISPLAY,\n fontWeight: 600,\n fontSize: 14,\n color: C.ink,\n whiteSpace: \"nowrap\",\n }}\n >\n {secondaryLabel}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n if (inline) return box;\n\n const dialog = (\n <div\n role=\"presentation\"\n onClick={closeOnOverlayClick ? () => (onClose || onPrimary)?.() : undefined}\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex,\n background: \"rgba(0, 0, 0, 0.4)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 16,\n }}\n >\n {box}\n </div>\n );\n\n return createPortal(dialog, container || document.body);\n}\n"],"names":["C","FONT_DISPLAY","ConfirmationPopup","open","title","content","itemName","primaryLabel","onPrimary","secondaryLabel","onSecondary","onClose","closeOnOverlayClick","className","style","container","zIndex","inline","React","handler","event","_a","box","jsxs","e","jsx","X","dialog","createPortal"],"mappings":"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"}
@@ -0,0 +1,281 @@
1
+ import { jsxs as d, jsx as i } from "react/jsx-runtime";
2
+ import C from "react";
3
+ import { createPortal as I } from "react-dom";
4
+ import { X as j } from "lucide-react";
5
+ const e = {
6
+ ink: "var(--color-text)",
7
+ border: "var(--grey-absent)",
8
+ white: "var(--grey-white)",
9
+ headerBg: "var(--surface-hover)",
10
+ neutral850: "var(--neutral-850)",
11
+ neutral50: "var(--neutral-50)"
12
+ }, o = "var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)";
13
+ function T({
14
+ // Controls visibility. When false, nothing renders.
15
+ open: a = !1,
16
+ // Header title.
17
+ title: c = "",
18
+ // Body content — string or any ReactNode for richer content.
19
+ content: f = "",
20
+ // Optional name of the item being acted on (e.g. report title). When
21
+ // provided, it's surfaced above `content` as a bold, quoted line so the
22
+ // user sees exactly which record they're confirming.
23
+ itemName: p = "",
24
+ // Left, dark/primary button.
25
+ primaryLabel: u = "Cancel",
26
+ onPrimary: r,
27
+ // Right, outlined/secondary button.
28
+ secondaryLabel: g = "Confirm",
29
+ onSecondary: s,
30
+ // Fires when the user clicks the header [X] or presses ESC.
31
+ // Falls back to `onPrimary` (since the dark button is the safe default).
32
+ onClose: l,
33
+ // Optional: click on the dim overlay also closes. Defaults to true.
34
+ closeOnOverlayClick: x = !0,
35
+ // Optional className applied to the dialog box itself for layout overrides.
36
+ className: y = "",
37
+ // Optional inline style overrides for the dialog box.
38
+ style: m,
39
+ // Where to mount the portal. Defaults to document.body in the browser.
40
+ container: k,
41
+ // z-index for the overlay (dialog sits one above).
42
+ zIndex: w = 1e3,
43
+ // When true, renders just the dialog box inline (no overlay, no portal,
44
+ // no ESC handling). Used by the library showcase so the component can be
45
+ // previewed in place alongside other static examples.
46
+ inline: n = !1
47
+ }) {
48
+ if (C.useEffect(() => {
49
+ if (!a || n)
50
+ return;
51
+ const t = (v) => {
52
+ var b;
53
+ v.key === "Escape" && ((b = l || r) == null || b());
54
+ };
55
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
56
+ }, [a, l, r, n]), !a || !n && typeof document > "u")
57
+ return null;
58
+ const h = /* @__PURE__ */ d(
59
+ "div",
60
+ {
61
+ role: "dialog",
62
+ "aria-modal": n ? void 0 : "true",
63
+ "aria-labelledby": c ? "cdr-confirm-title" : void 0,
64
+ className: y,
65
+ onClick: (t) => t.stopPropagation(),
66
+ style: {
67
+ background: e.white,
68
+ borderRadius: 8,
69
+ display: "flex",
70
+ flexDirection: "column",
71
+ alignItems: "stretch",
72
+ width: "100%",
73
+ maxWidth: 360,
74
+ boxShadow: n ? "0 4px 16px rgba(0, 0, 0, 0.08)" : "0 10px 32px rgba(0, 0, 0, 0.18)",
75
+ overflow: "hidden",
76
+ fontFamily: o,
77
+ color: e.ink,
78
+ ...m
79
+ },
80
+ children: [
81
+ /* @__PURE__ */ d(
82
+ "div",
83
+ {
84
+ style: {
85
+ display: "flex",
86
+ alignItems: "center",
87
+ justifyContent: "space-between",
88
+ padding: 16,
89
+ background: e.headerBg,
90
+ borderTopLeftRadius: 8,
91
+ borderTopRightRadius: 8
92
+ },
93
+ children: [
94
+ /* @__PURE__ */ i(
95
+ "p",
96
+ {
97
+ id: "cdr-confirm-title",
98
+ style: {
99
+ margin: 0,
100
+ fontFamily: o,
101
+ fontSize: 18,
102
+ color: e.ink,
103
+ lineHeight: "normal",
104
+ wordBreak: "break-word"
105
+ },
106
+ children: c
107
+ }
108
+ ),
109
+ /* @__PURE__ */ i(
110
+ "button",
111
+ {
112
+ type: "button",
113
+ "aria-label": "Close",
114
+ onClick: () => {
115
+ var t;
116
+ return (t = l || r) == null ? void 0 : t();
117
+ },
118
+ style: {
119
+ display: "inline-flex",
120
+ alignItems: "center",
121
+ justifyContent: "center",
122
+ width: 20,
123
+ height: 20,
124
+ padding: 0,
125
+ border: "none",
126
+ background: "transparent",
127
+ cursor: "pointer",
128
+ color: e.ink,
129
+ flexShrink: 0
130
+ },
131
+ children: /* @__PURE__ */ i(j, { size: 20, strokeWidth: 1.75 })
132
+ }
133
+ )
134
+ ]
135
+ }
136
+ ),
137
+ /* @__PURE__ */ d(
138
+ "div",
139
+ {
140
+ style: {
141
+ display: "flex",
142
+ flexDirection: "column",
143
+ alignItems: "stretch",
144
+ gap: 16,
145
+ paddingTop: 16,
146
+ width: "100%",
147
+ boxSizing: "border-box"
148
+ },
149
+ children: [
150
+ /* @__PURE__ */ d(
151
+ "div",
152
+ {
153
+ style: {
154
+ padding: 16,
155
+ display: "flex",
156
+ flexDirection: "column",
157
+ gap: 8,
158
+ fontFamily: o,
159
+ fontSize: 16,
160
+ color: e.ink,
161
+ lineHeight: "normal",
162
+ wordBreak: "break-word"
163
+ },
164
+ children: [
165
+ p && /* @__PURE__ */ i(
166
+ "p",
167
+ {
168
+ style: {
169
+ margin: 0,
170
+ fontFamily: o,
171
+ fontSize: 16,
172
+ fontWeight: 600,
173
+ color: e.ink,
174
+ wordBreak: "break-word"
175
+ },
176
+ children: `"${p}"`
177
+ }
178
+ ),
179
+ f && /* @__PURE__ */ i("div", { style: { margin: 0 }, children: f })
180
+ ]
181
+ }
182
+ ),
183
+ /* @__PURE__ */ d(
184
+ "div",
185
+ {
186
+ style: {
187
+ display: "flex",
188
+ alignItems: "center",
189
+ justifyContent: "flex-end",
190
+ gap: 16,
191
+ paddingTop: 12,
192
+ paddingBottom: 12,
193
+ paddingRight: 16,
194
+ borderTop: `1px solid ${e.border}`,
195
+ width: "100%",
196
+ boxSizing: "border-box"
197
+ },
198
+ children: [
199
+ u && /* @__PURE__ */ i(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ onClick: () => r == null ? void 0 : r(),
204
+ style: {
205
+ display: "inline-flex",
206
+ alignItems: "center",
207
+ justifyContent: "center",
208
+ height: 32,
209
+ padding: "0 16px",
210
+ borderRadius: 10,
211
+ border: "none",
212
+ background: e.neutral850,
213
+ cursor: "pointer",
214
+ fontFamily: o,
215
+ fontWeight: 600,
216
+ fontSize: 14,
217
+ color: e.neutral50,
218
+ whiteSpace: "nowrap"
219
+ },
220
+ children: u
221
+ }
222
+ ),
223
+ g && /* @__PURE__ */ i(
224
+ "button",
225
+ {
226
+ type: "button",
227
+ onClick: () => s == null ? void 0 : s(),
228
+ style: {
229
+ display: "inline-flex",
230
+ alignItems: "center",
231
+ justifyContent: "center",
232
+ height: 32,
233
+ padding: "0 16px",
234
+ borderRadius: 10,
235
+ border: `1px solid ${e.border}`,
236
+ background: e.white,
237
+ cursor: "pointer",
238
+ fontFamily: o,
239
+ fontWeight: 600,
240
+ fontSize: 14,
241
+ color: e.ink,
242
+ whiteSpace: "nowrap"
243
+ },
244
+ children: g
245
+ }
246
+ )
247
+ ]
248
+ }
249
+ )
250
+ ]
251
+ }
252
+ )
253
+ ]
254
+ }
255
+ );
256
+ return n ? h : I(/* @__PURE__ */ i(
257
+ "div",
258
+ {
259
+ role: "presentation",
260
+ onClick: x ? () => {
261
+ var t;
262
+ return (t = l || r) == null ? void 0 : t();
263
+ } : void 0,
264
+ style: {
265
+ position: "fixed",
266
+ inset: 0,
267
+ zIndex: w,
268
+ background: "rgba(0, 0, 0, 0.4)",
269
+ display: "flex",
270
+ alignItems: "center",
271
+ justifyContent: "center",
272
+ padding: 16
273
+ },
274
+ children: h
275
+ }
276
+ ), k || document.body);
277
+ }
278
+ export {
279
+ T as C
280
+ };
281
+ //# sourceMappingURL=ConfirmationPopup.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmationPopup.es.js","sources":["../src/components/common/ConfirmationPopup.jsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X } from \"lucide-react\";\n\n// Color values resolve to CSS variables declared in `src/tokens/colors.css`.\nconst C = {\n ink: \"var(--color-text)\",\n border: \"var(--grey-absent)\",\n white: \"var(--grey-white)\",\n headerBg: \"var(--surface-hover)\",\n neutral850: \"var(--neutral-850)\",\n neutral50: \"var(--neutral-50)\",\n};\n\nconst FONT_DISPLAY = \"var(--font-sans, 'Averta', ui-sans-serif, system-ui, sans-serif)\";\n\n// Generic two-button confirmation dialog (Figma node 6294:4785).\n//\n// Visual layout:\n// ┌──────────────────────────────────┐\n// │ Title [X] │ ← header (surface-hover bg)\n// ├──────────────────────────────────┤\n// │ │\n// │ Content / description… │ ← body\n// │ │\n// ├──────────────────────────────────┤\n// │ [Primary] [Secondary]│ ← actions\n// └──────────────────────────────────┘\n//\n// The \"primary\" button is the dark, bold one on the LEFT — matching the\n// destructive-flow convention in the design where the safe action is given\n// the prominent treatment. The \"secondary\" button is the outlined one on\n// the right. Hosts decide which semantic (Cancel vs Delete) maps to which.\nexport default function ConfirmationPopup({\n // Controls visibility. When false, nothing renders.\n open = false,\n // Header title.\n title = \"\",\n // Body content — string or any ReactNode for richer content.\n content = \"\",\n // Optional name of the item being acted on (e.g. report title). When\n // provided, it's surfaced above `content` as a bold, quoted line so the\n // user sees exactly which record they're confirming.\n itemName = \"\",\n // Left, dark/primary button.\n primaryLabel = \"Cancel\",\n onPrimary,\n // Right, outlined/secondary button.\n secondaryLabel = \"Confirm\",\n onSecondary,\n // Fires when the user clicks the header [X] or presses ESC.\n // Falls back to `onPrimary` (since the dark button is the safe default).\n onClose,\n // Optional: click on the dim overlay also closes. Defaults to true.\n closeOnOverlayClick = true,\n // Optional className applied to the dialog box itself for layout overrides.\n className = \"\",\n // Optional inline style overrides for the dialog box.\n style,\n // Where to mount the portal. Defaults to document.body in the browser.\n container,\n // z-index for the overlay (dialog sits one above).\n zIndex = 1000,\n // When true, renders just the dialog box inline (no overlay, no portal,\n // no ESC handling). Used by the library showcase so the component can be\n // previewed in place alongside other static examples.\n inline = false,\n}) {\n // Close on ESC. Bound only while the dialog is open (skipped in inline mode).\n React.useEffect(() => {\n if (!open || inline) return undefined;\n const handler = (event) => {\n if (event.key === \"Escape\") {\n (onClose || onPrimary)?.();\n }\n };\n window.addEventListener(\"keydown\", handler);\n return () => window.removeEventListener(\"keydown\", handler);\n }, [open, onClose, onPrimary, inline]);\n\n if (!open) return null;\n if (!inline && typeof document === \"undefined\") return null;\n\n const box = (\n <div\n role=\"dialog\"\n aria-modal={inline ? undefined : \"true\"}\n aria-labelledby={title ? \"cdr-confirm-title\" : undefined}\n className={className}\n onClick={(e) => e.stopPropagation()}\n style={{\n background: C.white,\n borderRadius: 8,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n width: \"100%\",\n maxWidth: 360,\n boxShadow: inline ? \"0 4px 16px rgba(0, 0, 0, 0.08)\" : \"0 10px 32px rgba(0, 0, 0, 0.18)\",\n overflow: \"hidden\",\n fontFamily: FONT_DISPLAY,\n color: C.ink,\n ...style,\n }}\n >\n {/* Header */}\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: 16,\n background: C.headerBg,\n borderTopLeftRadius: 8,\n borderTopRightRadius: 8,\n }}\n >\n <p\n id=\"cdr-confirm-title\"\n style={{\n margin: 0,\n fontFamily: FONT_DISPLAY,\n fontSize: 18,\n color: C.ink,\n lineHeight: \"normal\",\n wordBreak: \"break-word\",\n }}\n >\n {title}\n </p>\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={() => (onClose || onPrimary)?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 20,\n height: 20,\n padding: 0,\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n color: C.ink,\n flexShrink: 0,\n }}\n >\n <X size={20} strokeWidth={1.75} />\n </button>\n </div>\n\n {/* Content + actions */}\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n gap: 16,\n paddingTop: 16,\n width: \"100%\",\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n padding: 16,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 8,\n fontFamily: FONT_DISPLAY,\n fontSize: 16,\n color: C.ink,\n lineHeight: \"normal\",\n wordBreak: \"break-word\",\n }}\n >\n {itemName && (\n <p\n style={{\n margin: 0,\n fontFamily: FONT_DISPLAY,\n fontSize: 16,\n fontWeight: 600,\n color: C.ink,\n wordBreak: \"break-word\",\n }}\n >\n {`\"${itemName}\"`}\n </p>\n )}\n {content && (\n <div style={{ margin: 0 }}>{content}</div>\n )}\n </div>\n\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-end\",\n gap: 16,\n paddingTop: 12,\n paddingBottom: 12,\n paddingRight: 16,\n borderTop: `1px solid ${C.border}`,\n width: \"100%\",\n boxSizing: \"border-box\",\n }}\n >\n {primaryLabel && (\n <button\n type=\"button\"\n onClick={() => onPrimary?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: 32,\n padding: \"0 16px\",\n borderRadius: 10,\n border: \"none\",\n background: C.neutral850,\n cursor: \"pointer\",\n fontFamily: FONT_DISPLAY,\n fontWeight: 600,\n fontSize: 14,\n color: C.neutral50,\n whiteSpace: \"nowrap\",\n }}\n >\n {primaryLabel}\n </button>\n )}\n {secondaryLabel && (\n <button\n type=\"button\"\n onClick={() => onSecondary?.()}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: 32,\n padding: \"0 16px\",\n borderRadius: 10,\n border: `1px solid ${C.border}`,\n background: C.white,\n cursor: \"pointer\",\n fontFamily: FONT_DISPLAY,\n fontWeight: 600,\n fontSize: 14,\n color: C.ink,\n whiteSpace: \"nowrap\",\n }}\n >\n {secondaryLabel}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n if (inline) return box;\n\n const dialog = (\n <div\n role=\"presentation\"\n onClick={closeOnOverlayClick ? () => (onClose || onPrimary)?.() : undefined}\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex,\n background: \"rgba(0, 0, 0, 0.4)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 16,\n }}\n >\n {box}\n </div>\n );\n\n return createPortal(dialog, container || document.body);\n}\n"],"names":["C","FONT_DISPLAY","ConfirmationPopup","open","title","content","itemName","primaryLabel","onPrimary","secondaryLabel","onSecondary","onClose","closeOnOverlayClick","className","style","container","zIndex","inline","React","handler","event","_a","box","jsxs","e","jsx","X","createPortal"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- "use strict";const t=require("react/jsx-runtime"),i=require("react"),T=require("./sortable.esm.cjs.js"),W=require("lucide-react"),Ve=require("react-dom"),wt=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./TourGuideTooltip.cjs.js");function Ft({dateRangePicker:r,onWeekToDate:l,exportConfig:d,filterChipsConfig:f,trailingActions:v}){const[y,c]=i.useState(!1),g=i.useRef(null),E=i.useRef(null);i.useEffect(()=>{const S=F=>{E.current&&!E.current.contains(F.target)&&g.current&&!g.current.contains(F.target)&&c(!1)};if(y)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[y]);const w=()=>{c(S=>!S)},j=S=>{c(!1),d!=null&&d.onExport&&d.onExport(S)},M=(()=>{if(!(f!=null&&f.filters))return!1;const S=f.filters,F=f.customFilters||[],G=Object.entries(S).some(([C,$])=>!!(Array.isArray($)&&$.length||typeof $=="string"&&$.trim()!==""||$&&typeof $=="object"&&($.min!=null||$.max!=null))),L=F.some(C=>C.active);return G||L})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l&&t.jsxs("button",{onClick:l,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[t.jsx(W.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),r&&t.jsx(i.Suspense,{fallback:t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[t.jsx(W.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:r}),d&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:g,onClick:w,disabled:d.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(W.Download,{size:16}),t.jsx("span",{children:d.isExporting?"Exporting...":"Export"})]}),t.jsx(W.ChevronDown,{size:16})]}),y&&t.jsx("div",{ref:E,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(d.types||["csv"]).map(S=>t.jsxs("button",{onClick:()=>j(S),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",S.toUpperCase()]},S))})]}),(M||v)&&t.jsxs(t.Fragment,{children:[M&&t.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[M&&f&&t.jsx(wt.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),v&&t.jsx("div",{className:"flex-shrink-0",children:v})]})]})]})}function et(r){if(r==null)return NaN;const l=String(r).replace(/[,$%]|pp/gi,"").trim(),d=parseFloat(l);return Number.isFinite(d)?d:NaN}function Jt(r){if(r==null)return NaN;const l=String(r).trim(),d=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(d){const w=+d[1],j=+d[2],B=d[3]!=null?+d[3]:null;return B!=null?w*3600+j*60+B:w*60+j}let f=0,v=!1;const y=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),g=l.match(/(\d+)\s*m(?!s)\b/i),E=l.match(/(\d+)\s*s\b/i);return y&&(f+=+y[1]*86400,v=!0),c&&(f+=+c[1]*3600,v=!0),g&&(f+=+g[1]*60,v=!0),E&&(f+=+E[1],v=!0),v?f:NaN}function Yt(r){if(!r)return null;const l=String(r).trim(),d=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(d){const v=d[3].length===2?2e3+ +d[3]:+d[3],y=new Date(v,+d[1]-1,+d[2]);return isNaN(y.getTime())?null:y}const f=new Date(l);return isNaN(f.getTime())?null:f}function Qt(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),d=f=>l.every(f);return d(f=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(f)||/^\d{4}-\d{2}-\d{2}/.test(f))?"date":d(f=>/^\d+\s*[dhms]\b/i.test(f)||/^\d+:\d+(:\d+)?$/.test(f))?"duration":d(f=>/^-?[\d,.]+(%|pp)?$/i.test(f))?"number":"text"}function Ce(r){return r?Array.isArray(r)?r.length>0:r.type==="range"?r.min!==""&&r.min!==void 0&&r.min!==null||r.max!==""&&r.max!==void 0&&r.max!==null:r.type==="durationRange"?r.minSec!==""&&r.minSec!=null||r.maxSec!==""&&r.maxSec!=null:r.type==="scoreRange"?Array.isArray(r.values)&&r.values.length>0||r.min!==""&&r.min!=null||r.max!==""&&r.max!=null:r.type==="dateRange"?!!(r.from||r.to):!1:!1}function bt(r){if(r==null||r===""||isNaN(r))return"";const l=Number(r),d=Math.floor(l/3600),f=Math.floor(l%3600/60),v=Math.floor(l%60);return d>0?`${d}h ${f}m`:f>0?`${f}m ${v}s`:`${v}s`}function Zt(r){if(!r)return"";if(Array.isArray(r))return r.length===0?"":String(r[0]);if(r.type==="range"){const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}if(r.type==="durationRange"){const l=r.minSec!==""&&r.minSec!=null?bt(r.minSec):null,d=r.maxSec!==""&&r.maxSec!=null?bt(r.maxSec):null;return l&&d?`${l} – ${d}`:l?`≥ ${l}`:d?`≤ ${d}`:""}if(r.type==="scoreRange"){if(Array.isArray(r.values)&&r.values.length>0)return r.values.slice().sort((f,v)=>f-v).join(", ");const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}return r.type==="dateRange"?r.from&&r.to?`${r.from} – ${r.to}`:r.from?`from ${r.from}`:r.to?`to ${r.to}`:"":""}function Vt(r){return Array.isArray(r)?Math.max(0,r.length-1):0}function en(r){return Array.isArray(r)?r.slice(1).map(String).join(", "):""}function tn({count:r,values:l}){const[d,f]=i.useState(!1);return t.jsxs("span",{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:22,minWidth:22,padding:"0 6px",background:"#D8D8D8",color:"#0B0B0B",borderRadius:14,fontSize:12,fontWeight:500,lineHeight:1,cursor:"pointer"},children:["+",r,d&&t.jsx("span",{role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:"#1E2125",color:"#FFFFFF",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:400,lineHeight:"20px",padding:"6px 10px",borderRadius:8,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100,boxShadow:"0 6px 16px rgba(11, 11, 11, 0.18)"},children:l})]})}function nn({leftLabel:r,rightLabel:l,leftValue:d,rightValue:f,onLeftChange:v,onRightChange:y,type:c="number",placeholderLeft:g="Min",placeholderRight:E="Max"}){const w={width:"100%",height:32,borderRadius:8,border:"1px solid #D9D9D9",background:"#FFFFFF",padding:"0 10px",fontFamily:"var(--font-sans)",fontSize:14,color:"#0B0B0B",outline:"none",boxSizing:"border-box"},j={fontSize:12,color:"#676767",marginBottom:4,fontFamily:"var(--font-sans)"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:r}),t.jsx("input",{type:c,value:d,onChange:B=>v(B.target.value),placeholder:g,style:w})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:l}),t.jsx("input",{type:c,value:f,onChange:B=>y(B.target.value),placeholder:E,style:w})]})]})}const St=[{id:"0-60",label:"0 to 60 Sec",minSec:0,maxSec:60},{id:"60-120",label:"1m to 2 m",minSec:60,maxSec:120},{id:"120-180",label:"2m to 3 m",minSec:120,maxSec:180},{id:"180-240",label:"3m to 4m",minSec:180,maxSec:240},{id:"240-300",label:"4m to 5m",minSec:240,maxSec:300},{id:"300+",label:"5 mins and above",minSec:300,maxSec:null}];function vt(r){if(r==null||r==="")return null;const l=String(r).trim().match(/^(\d{1,3}):(\d{2})$/);if(l)return Number(l[1])*60+Number(l[2]);const d=Number(r);return Number.isFinite(d)?d:null}function Qe({children:r}){return t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0 2px",fontFamily:"var(--font-sans)"},children:r})}function Ze({minValue:r,maxValue:l,onMinChange:d,onMaxChange:f,inputType:v="number",inputMode:y="decimal",step:c,placeholder:g="0.0",unit:E}){const w={width:"100%",height:30,border:"1px solid #ACADAD",borderRadius:4,padding:"6px 10px",fontSize:13,color:"#0B0B0B",fontFamily:"var(--font-sans)",outline:"none",boxSizing:"border-box"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Min From"}),t.jsx("input",{type:v,inputMode:y,step:c,placeholder:g,value:r,onChange:j=>d(j.target.value),style:w})]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#323232",paddingBottom:8,fontFamily:"var(--font-sans)"},children:"to"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Max"}),t.jsx("input",{type:v,inputMode:y,step:c,placeholder:g,value:l,onChange:j=>f(j.target.value),style:w})]})]}),E&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Input values in ",E==="sec"?"seconds":E]})]})}function rn({column:r,columnId:l,filterType:d="text",position:f,popoverRef:v,distinctValues:y,initialValue:c,onApply:g,onCancel:E}){const w=d==="text",j=d==="number",B=d==="date",M=d==="duration",S=d==="score",F=i.useMemo(()=>{if(!S||!Array.isArray(y)||y.length===0)return!1;let m=1/0,h=-1/0;for(const x of y){const O=et(x);Number.isFinite(O)&&(O<m&&(m=O),O>h&&(h=O))}return Number.isFinite(m)&&Number.isFinite(h)&&m>=0&&h<=5},[S,y]),[G,L]=i.useState(()=>w?new Set(Array.isArray(c)?c:[]):new Set),[C,$]=i.useState(""),[oe,se]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[D,Z]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[U,A]=i.useState(new Set),[q,ce]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[J,ie]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[Y,V]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[K,de]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[ye,X]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[N,ee]=i.useState(()=>B&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[Q,ae]=i.useState(()=>B&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");i.useEffect(()=>{w&&L(new Set(Array.isArray(c)?c:[]))},[l,w]);const _=i.useMemo(()=>{const m=C.trim().toLowerCase();return m?y.filter(h=>String(h).toLowerCase().includes(m)):y},[y,C]),pe=m=>{L(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},be=()=>{w&&L(new Set),j&&(se(""),Z("")),M&&(A(new Set),ce(""),ie("")),S&&(V(new Set),de(""),X("")),B&&(ee(""),ae("")),$("")},De=m=>{A(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},R=m=>{V(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},fe=()=>{if(w)return g(Array.from(G));if(j)return g({type:"range",min:oe===""?"":Number(oe),max:D===""?"":Number(D)});if(M){const m=vt(q),h=vt(J),x=m!=null||h!=null;let O="",ue="";if(x)O=m??"",ue=h??"";else if(U.size>0){const Se=St.filter(te=>U.has(te.id));O=Math.min(...Se.map(te=>te.minSec)),ue=Se.some(te=>te.maxSec==null)?"":Math.max(...Se.map(te=>te.maxSec))}return g({type:"durationRange",minSec:O,maxSec:ue})}if(S){const m=K===""?null:Number(K),h=ye===""?null:Number(ye);return m!=null||h!=null?g({type:"scoreRange",values:[],min:m!=null&&Number.isFinite(m)?m:"",max:h!=null&&Number.isFinite(h)?h:""}):g({type:"scoreRange",values:Array.from(Y).sort((O,ue)=>O-ue),min:"",max:""})}if(B)return g({type:"dateRange",from:N,to:Q})};return t.jsxs("div",{ref:v,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:f.top,left:f.left,zIndex:50,width:w?240:220,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,padding:12,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 8px 24px rgba(11, 11, 11, 0.10)",fontFamily:"var(--font-sans)"},children:[w&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{background:"#D8D8D8",height:32,borderRadius:10,padding:1,display:"flex",alignItems:"center"},children:t.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[t.jsx(W.Search,{size:16,color:"#989898",strokeWidth:2}),t.jsx("input",{autoFocus:!0,type:"text",value:C,onChange:m=>$(m.target.value),placeholder:"Search",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#0B0B0B",minWidth:0,fontFamily:"var(--font-sans)"}})]})}),t.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},children:_.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):_.map(m=>{const h=G.has(m);return t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"6px 4px",cursor:"pointer",borderRadius:6},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("input",{type:"checkbox",checked:h,onChange:()=>pe(m),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),t.jsx("span",{onClick:x=>{x.preventDefault(),pe(m)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]},m)})})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Filter"}),t.jsx(Ze,{minValue:oe,maxValue:D,onMinChange:se,onMaxChange:Z})]}),M&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Duration"}),r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:St.map(m=>{const h=U.has(m.id);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>De(m.id),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),De(m.id))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m.label})]},m.id)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"})]}),t.jsx(Ze,{minValue:q,maxValue:J,onMinChange:ce,onMaxChange:ie,inputType:"number",inputMode:"numeric",placeholder:"0",unit:"sec"})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Score"}),F&&r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[1,2,3,4,5].map(m=>{const h=Y.has(m);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>R(m),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),R(m))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m})]},m)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}})]}),F&&r.filterShowPresets===!0&&t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"}),t.jsx(Ze,{minValue:K,maxValue:ye,onMinChange:de,onMaxChange:X,step:"0.1"})]}),B&&t.jsx(nn,{leftLabel:"From",rightLabel:"To",leftValue:N,rightValue:Q,onLeftChange:ee,onRightChange:ae,type:"date",placeholderLeft:"",placeholderRight:""}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("button",{type:"button",onClick:be,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:M&&r.filterShowPresets===!0||S&&F&&r.filterShowPresets===!0?"View All":"Reset"}),t.jsx("button",{type:"button",onClick:fe,style:{background:"#0B0B0B",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Apply"})]})]})}const on=()=>({userData:{email:"anonymous"}}),sn=r=>t.jsx("img",{...r});function an({children:r,content:l,direction:d="top",align:f="center",styling:v,indicatorColor:y}){const c=typeof l=="string"?l:l!=null?String(l):"",g=typeof y=="string"&&(y.startsWith("#")||y.startsWith("rgb")||y.startsWith("hsl")||y.startsWith("var("))?y:"var(--Grey-Strong, #2E3236)",[E,w]=i.useState(!1),[j,B]=i.useState(!1),[M,S]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),F=i.useRef(null),G=i.useRef(null);if(!c)return r;i.useEffect(()=>{B(!0)},[]);const L=i.useCallback(()=>{if(!F.current||!G.current||typeof window>"u")return;const C=F.current.getBoundingClientRect(),$=G.current.getBoundingClientRect(),oe=window.innerWidth,se=window.innerHeight,D=8,Z=10,U=$.width,A=$.height,q=C.top,ce=se-C.bottom,J=d==="bottom"?"bottom":"top";let ie=J;J==="top"&&q<A+Z+D&&ce>q?ie="bottom":J==="bottom"&&ce<A+Z+D&&q>ce&&(ie="top");let Y=C.left+C.width/2;f==="start"&&(Y=C.left),f==="end"&&(Y=C.right);let V=ie==="top"?C.top-A-Z:C.bottom+Z,K=f==="start"?Y:f==="end"?Y-U:Y-U/2;V=Math.max(D,Math.min(V,se-A-D)),K=Math.max(D,Math.min(K,oe-U-D));const de=Math.max(10,Math.min(Y-K,U-10));S({top:V,left:K,arrowLeft:de,placement:ie})},[f,d]);return i.useEffect(()=>{if(!E||!j)return;L();const C=()=>L();return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[E,j,L]),t.jsxs("span",{ref:F,style:{display:"block",width:"100%"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:[r,E&&j&&Ve.createPortal(t.jsxs("span",{ref:G,style:{position:"fixed",top:`${M.top}px`,left:`${M.left}px`,background:"var(--Grey-Strong, #2E3236)",color:"var(--Grey-White, #FFF)",fontSize:"12px",lineHeight:1.3,fontWeight:500,padding:"8px 10px",borderRadius:"6px",whiteSpace:"normal",maxWidth:"320px",width:"max-content",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.2)",zIndex:99999,pointerEvents:"none",...typeof v=="object"?v:{}},children:[c,t.jsx("span",{style:{position:"absolute",left:`${M.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...M.placement==="top"?{top:"100%",borderTop:`7px solid ${g}`}:{bottom:"100%",borderBottom:`7px solid ${g}`}}})]}),document.body)]})}function ln({data:r=[],columns:l=[],initialPageSize:d=10,onRowClick:f,totalCount:v=null,page:y=null,pageSize:c=null,onPageChange:g=null,onPageSizeChange:E=null,onFilterChange:w=null,columnFilters:j=null,onMaxColumnsError:B=null,onSort:M=null,sortFields:S=[],tableId:F=null,isLoading:G=!1,filtersConfig:L=null,columnResizeMinWidth:C=120,columnResizeMaxWidth:$=280,onVisibleColumnsChange:oe=null}){var yt;const{userData:se}=on(),D=(se==null?void 0:se.email)||"anonymous",Z=i.memo(({children:e,content:n,className:o=""})=>{const a=i.useRef(null),[s,p]=i.useState(!1);i.useEffect(()=>{const b=()=>{if(a.current){const P=a.current.scrollWidth>a.current.clientWidth;p(P)}};b();const I=setTimeout(b,0);return window.addEventListener("resize",b),()=>{clearTimeout(I),window.removeEventListener("resize",b)}},[e,n]);const u=t.jsx("span",{className:`truncate block ${o}`,ref:a,children:e});return s&&n?t.jsx(an,{content:n,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:u}):u});Z.displayName="TruncatedCell";const U=v!==null&&g!==null,A=w!==null,q=M!==null,[ce,J]=i.useState(1),[ie,Y]=i.useState(d),V=y!==null?y:ce,K=c!==null?c:ie,de=e=>{g?g(e):J(e)},ye=e=>{E?E(e):Y(e)},X=50,N="action",ee=i.useRef(!1),Q=i.useMemo(()=>F?`dataTable_columns_${F}:${D}`:`dataTable_columns_${l.map(n=>n.id||n.key).sort().join("_")}:${D}`,[F,l,D]),ae=i.useMemo(()=>F?`dataTable_manual_change_${F}:${D}`:null,[F,D]);i.useCallback((e,n)=>{if(typeof window>"u"||!e||!n||n.length===0)return null;try{const o=localStorage.getItem(e);if(o){const s=JSON.parse(o).filter(p=>n.some(u=>(u.id||u.key)===p));if(s.length>0)return s}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}return null},[]);const[_,pe]=i.useState({}),[be,De]=i.useState(""),[R,fe]=i.useState(null),[m,h]=i.useState({top:0,left:0}),x=i.useRef(null),O=i.useRef({}),[ue,Se]=i.useState(null),[Oe,te]=i.useState("asc"),Te=i.useCallback((e,n)=>{const o=Ce(n);pe(a=>{const s={...a};return o?s[e]=n:delete s[e],s}),g?g(1):J(1),A&&w&&w(o?{..._,[e]:n}:Object.fromEntries(Object.entries(_).filter(([a])=>a!==e)))},[_,w,A,g]),jt=i.useCallback(()=>{pe({}),De(""),g?g(1):J(1),A&&w&&w({})},[w,A,g]),_e=i.useCallback(e=>{if(!r||r.length===0)return[];const n=new Set,o=[];for(const a of r){const s=a[e];if(s==null)continue;const p=typeof s=="object"?JSON.stringify(s):String(s);n.has(p)||(n.add(p),o.push(p))}return o.sort((a,s)=>a.localeCompare(s))},[r]),kt=i.useCallback(e=>{const n=l.find(o=>H(o)===e);return n&&n.filterType?n.filterType:Qt(_e(e))},[l,_e]),Re=i.useCallback(e=>{const a=typeof window<"u"?window.innerWidth:1/0;let s=e.left;return s+280>a-8&&(s=Math.max(8,e.right-280)),{top:e.bottom+6,left:s}},[]),Ct=i.useCallback((e,n)=>{if(!n){fe(e);return}const o=n.getBoundingClientRect();h(Re(o)),fe(a=>a===e?null:e)},[Re]);i.useEffect(()=>{if(!R)return;const e=n=>{if(x.current&&x.current.contains(n.target))return;const o=O.current[R];o&&o.contains(n.target)||fe(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[R]),i.useEffect(()=>{if(!R)return;const e=()=>{const n=O.current[R];if(!n)return;const o=n.getBoundingClientRect();h(Re(o))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[R,Re]),i.useLayoutEffect(()=>{if(!R)return;const e=x.current,n=O.current[R];if(!e||!n)return;const o=e.offsetWidth,a=n.getBoundingClientRect(),s=8,p=typeof window<"u"?window.innerWidth:1/0;if(!(a.left+o>p-s))return;const b=Math.max(s,a.right-o);h(I=>I.left===b?I:{...I,left:b})},[R,m.top]);const tt=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim()!=="":!0)),[]),nt=i.useCallback((e,n)=>{const o=Object.keys(e||{}),a=Object.keys(n||{});return o.length!==a.length?!1:o.every(s=>e[s]===n[s])},[]);i.useEffect(()=>{if(!A||j===null)return;const e=tt(j);pe(n=>nt(n,e)?n:e)},[A,j,tt,nt]),i.useCallback((e,n)=>e==="csat_score"&&n==="evaluation.csat_score"?n:e,[]);const ve=q&&S.length>0?S[0][0]:ue,Ee=q&&S.length>0?S[0][1]:Oe,[cn,rt]=i.useState(()=>l.map(e=>e.id||e.key)),ne=i.useCallback(e=>{if(!e||e.length===0)return e;let n=Array.from(new Set(e));n.length>X&&(n=n.slice(0,X));const a=l.map(u=>u.id||u.key).includes(N);return!n.includes(N)&&a&&(n.length>=X?n=[...n.slice(0,X-1),N]:n=[...n,N]),[...n.filter(u=>u!==N),N]},[l]),[z,we]=i.useState(()=>{if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const a=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(a){const s=JSON.parse(a);if(Array.isArray(s)&&s.length>0){ee.current=!0;const p=s.filter(u=>l.some(b=>(b.id||b.key)===u));if(p.length>0)return p.slice(0,X)}}}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}const n=l.map(o=>o.id||o.key).slice(0,X);return ne(n)}),[re,He]=i.useState(!1),[me,Me]=i.useState([]),[ot,Dt]=i.useState({top:0,left:0,width:0}),[st,it]=i.useState(new Set),[at,lt]=i.useState(new Set),ze=i.useRef(null);ze.current===null&&(ze.current=[...z]);const[le,qe]=i.useState(null),[Rt,Be]=i.useState(null),he=i.useRef(null),Ke=i.useRef(null),Xe=i.useRef(null),[ct,Ge]=i.useState(null),[Ue,Et]=i.useState({}),Mt=i.useRef(null),Ne=i.useRef(null),H=e=>e.id||e.key,We=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=e.trim();if(n.endsWith("px")){const a=parseFloat(n);return Number.isFinite(a)?a:null}const o=parseFloat(n);return Number.isFinite(o)&&`${o}`===n?o:null}return null},[]),dt=i.useCallback((e,n)=>Ue[e]!=null?`${Ue[e]}px`:typeof n=="number"?`${n}px`:n||"auto",[Ue]),$e=i.useCallback(e=>{if(!Ne.current)return;const{columnId:n,startX:o,startWidth:a,minWidth:s,maxWidth:p}=Ne.current,u=e.clientX-o,b=Math.round(a+u),I=Math.min(p,Math.max(s,b));Et(P=>({...P,[n]:I}))},[]),Fe=i.useCallback(()=>{Ne.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Fe)},[$e]),zt=i.useCallback((e,n,o)=>{var Pe;e.preventDefault(),e.stopPropagation();const a=n.id||n.key,s=We(n.minWidth)??C,p=We(n.maxWidth)??$,u=Math.min(s,p),b=Math.max(s,p),I=((Pe=e.currentTarget.closest("th"))==null?void 0:Pe.getBoundingClientRect().width)||0,P=We(o),ke=P??Math.max(u,Math.round(I)||u),Je=Math.min(b,Math.max(u,ke));Ne.current={columnId:a,startX:e.clientX,startWidth:Je,minWidth:u,maxWidth:b},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",Fe)},[$,C,$e,Fe,We]);i.useEffect(()=>()=>Fe(),[Fe]);const Bt=T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor,{coordinateGetter:T.sortableKeyboardCoordinates})),Nt=e=>{const{active:n,over:o}=e;if(o&&n.id!==o.id){if(n.id===N||o.id===N){ft("Cannot drop columns on the Action column"),Ge(null);return}ee.current=!0,we(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);if(s!==-1&&p!==-1){const u=T.arrayMove(a,s,p),b=ne(u);return pt(b),b}return a}),rt(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);return T.arrayMove(a,s,p)})}Ge(null)},Wt=e=>{Ge(e.active.id)},Ae=i.useMemo(()=>{if(A)return r||[];if(!r||r.length===0)return[];const e=be.trim().toLowerCase(),n=Object.entries(_).filter(([,o])=>Ce(o));return r.filter(o=>{for(const[a,s]of n){const p=o[a];if(p==null)return!1;if(Array.isArray(s)){const u=String(p);if(!s.some(b=>String(b)===u))return!1;continue}if(s.type==="range"){const u=et(p);if(isNaN(u)||s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="durationRange"){const u=Jt(p);if(isNaN(u)||s.minSec!==""&&s.minSec!=null&&u<Number(s.minSec)||s.maxSec!==""&&s.maxSec!=null&&u>Number(s.maxSec))return!1;continue}if(s.type==="scoreRange"){const u=et(p);if(isNaN(u))return!1;if(Array.isArray(s.values)&&s.values.length>0){const b=Math.floor(u);if(!s.values.includes(b))return!1;continue}if(s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="dateRange"){const u=Yt(p);if(!u)return!1;if(s.from){const b=new Date(s.from+"T00:00:00");if(u<b)return!1}if(s.to){const b=new Date(s.to+"T23:59:59");if(u>b)return!1}continue}}return!(e&&!Object.values(o).some(s=>s==null?!1:String(s).toLowerCase().includes(e)))})},[r,_,be,A]),je=i.useMemo(()=>q||!ve?Ae:[...Ae].sort((e,n)=>{const o=e[ve],a=n[ve];if(o==null)return 1;if(a==null)return-1;if(typeof o=="number"&&typeof a=="number")return Ee==="asc"?o-a:a-o;const s=String(o).toLowerCase(),p=String(a).toLowerCase();return Ee==="asc"?s.localeCompare(p):p.localeCompare(s)}),[Ae,ve,Ee,q]),Ie=i.useMemo(()=>{if(U)return je;{const e=(V-1)*K,n=e+K;return je.slice(e,n)}},[je,V,K,U]),ut=e=>{q&&M?(M(e),g?g(1):J(1)):(ue===e?te(Oe==="asc"?"desc":"asc"):(Se(e),te("asc")),de(1))},$t=(e,n)=>{const o=(n||"").split(/\s+/).map(a=>a.trim()).filter(Boolean);Te(e,o)},ft=e=>{Xe.current||(typeof B=="function"&&B(e),Xe.current=setTimeout(()=>{Xe.current=null},3e3))},pt=i.useCallback(e=>{if(typeof window<"u"&&Q&&e.length>0&&ee.current)try{localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(n){console.warn("Failed to save columns to localStorage:",n)}},[Q,ae]),At=e=>{e!==N&&Me(n=>n.includes(e)?n.length===1?n:n.filter(o=>o!==e):n.length>=X?(ft("Maximum 9 column selection allowed"),n):ne([...n,e]))},It=(e,n)=>{me[n]!==N&&qe(n)},Pt=()=>{qe(null),Be(null)},Lt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&Be(n)},Ot=()=>{Be(null)},Tt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&me[n]!==N&&me[le]!==N&&Me(o=>{const a=T.arrayMove(o,le,n);return ne(a)}),qe(null),Be(null)};i.useEffect(()=>{rt(e=>{const n=z.filter(s=>e.includes(s)),o=z.filter(s=>!e.includes(s)),a=e.filter(s=>!z.includes(s));return[...n,...o,...a]})},[z]),i.useEffect(()=>{if(typeof window<"u"&&Q&&z.length>0&&ee.current)try{const e=ne(z);localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[z,Q,ae]),i.useEffect(()=>{oe&&oe(z.filter(e=>e!==N))},[z,oe]),i.useEffect(()=>{if(l.length>0&&z.length===0){if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(o){const a=JSON.parse(o);if(Array.isArray(a)&&a.length>0){const s=a.filter(p=>l.some(u=>(u.id||u.key)===p));if(s.length>0){ee.current=!0,we(s.slice(0,X));return}}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const e=l.map(n=>n.id||n.key);we(ne(e.slice(0,X)))}},[l,F,D,ne]);const xe=i.useMemo(()=>{const e=z.map(n=>l.find(o=>H(o)===n)).filter(Boolean);return ne(e.map(H)).map(n=>l.find(o=>H(o)===n)).filter(Boolean)},[l,z]);i.useMemo(()=>xe.some(e=>e.filterable===!0),[xe]),i.useEffect(()=>{if(!re||!he.current)return;const e=()=>{if(he.current){const n=he.current.getBoundingClientRect(),o=217,a=Math.max(8,n.right-o);Dt({top:n.bottom,left:a,width:Math.max(n.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[re]),i.useEffect(()=>{const e=n=>{re&&he.current&&!he.current.contains(n.target)&&Ke.current&&!Ke.current.contains(n.target)&&He(!1)};if(re)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[re]),i.useEffect(()=>{re&&(Me(z),it(new Set),lt(new Set))},[re,z]),z.length===1?(yt=l.find(e=>(e.id||e.key)===z[0]))!=null&&yt.label:`${z.length}`;function _t({column:e,isHeaderRow:n=!0}){const o=H(e),a=o===N,s=dt(o,e.width),[p,u]=i.useState(!1),{attributes:b,listeners:I,setNodeRef:P,transform:ke,transition:Je,isDragging:Pe}=T.useSortable({id:o}),qt={transform:T.CSS.Transform.toString(ke),transition:Je,opacity:Pe?.5:1,width:s,minWidth:s};let ge=!1;if(q&&S.length>0){const k=S[0][0];(k===o||k==="csat_score"&&o==="evaluation.csat_score")&&(ge=!0)}else ge=ve===o;const Kt=Ee==="asc",Xt=e.filterable===!0;if(!n)return t.jsx("th",{style:{width:s,minWidth:s,backgroundColor:"var(--primary-foreground)",borderRight:"1px solid #e6e6e6",borderBottom:"1px solid #e6e6e6",boxSizing:"border-box"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:Xt?t.jsxs("div",{className:"relative",children:[t.jsx(Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),t.jsx("input",{type:"text",placeholder:"Filter...",value:_[o]||"",onChange:k=>{k.stopPropagation(),$t(o,k.target.value)},onKeyDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})});const Ye=R===o,Le=Ce(_[o]),Gt=e.sortable!==!1&&(p||ge),Ut=e.filterable!==!1&&!a&&(p||Ye||Le);return t.jsxs("th",{ref:P,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...qt,padding:"0 12px",height:36,textAlign:a?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:s,...typeof s=="string"&&s.endsWith("px")?{maxWidth:s}:{},borderRight:"1px solid #e6e6e6",boxSizing:"border-box",userSelect:"none",whiteSpace:"nowrap",wordBreak:"normal",overflowWrap:"normal",verticalAlign:"middle",background:p||Ye?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!a&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:a?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!a&&t.jsx("div",{...b,...I,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:p?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&ut(o),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:a?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),Gt&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),ut(o)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:ge?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:ge?Kt?t.jsx(W.ArrowUp,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowDown,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowUpDown,{size:14,strokeWidth:1.75})}),Ut&&t.jsxs("button",{type:"button",ref:k=>{O.current[o]=k},onClick:k=>{k.stopPropagation(),Ct(o,k.currentTarget)},title:"Filter",style:{position:"relative",background:Ye||Le?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Le?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[t.jsx(W.ListFilter,{size:14,strokeWidth:1.75}),Le&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),!a&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||o} column`,title:"Drag to resize column",onMouseDown:k=>zt(k,e,s),onClick:k=>k.stopPropagation(),onMouseEnter:k=>{k.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const mt=ct?l.find(e=>H(e)===ct):null,ht=({col:e,columnId:n,isSelected:o,draggable:a,isAction:s,actualIndex:p})=>{const u=a&&le===p,b=a&&Rt===p&&le!==null&&le!==p;o?at.has(n):st.has(n);const I=o?!at.has(n):st.has(n);return t.jsxs("div",{draggable:a,onDragStart:a?P=>It(P,p):void 0,onDragEnd:a?Pt:void 0,onDragOver:a?P=>Lt(P,p):void 0,onDragLeave:a?Ot:void 0,onDrop:a?P=>Tt(P,p):void 0,onClick:()=>{s||At(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:s?"default":a?"grab":"pointer",opacity:u?.5:1,background:b?"#F2F2F0":"transparent",borderRadius:6},children:[t.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:a?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14,strokeWidth:1.75})}),t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:I?"#0B0B0B":"#FFFFFF",border:`1px solid ${I?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:I&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{flex:1,fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",marginLeft:8},children:e.label})]})},Ht=re?t.jsxs("div",{ref:Ke,style:{position:"fixed",top:`${ot.top}px`,left:`${ot.left}px`,width:217,maxHeight:320,zIndex:49,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)",boxShadow:"0 8px 24px rgba(11, 11, 11, 0.08)"},children:[t.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:12},children:[me.map((e,n)=>{const o=l.find(s=>H(s)===e);if(!o)return null;const a=e===N;return t.jsx(i.Fragment,{children:ht({col:o,columnId:e,isSelected:!0,draggable:!a,isAction:a,actualIndex:n})},`selected-${e}-${n}`)}),l.filter(e=>!me.includes(H(e))).map(e=>{const n=H(e);return t.jsx(i.Fragment,{children:ht({col:e,columnId:n,isSelected:!1,draggable:!1,isAction:!1,actualIndex:-1})},`unselected-${n}`)})]}),t.jsxs("div",{style:{flexShrink:0,borderTop:"1px solid #D9D9D9",padding:"8px 12px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"space-between",height:46,boxSizing:"border-box"},children:[t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=ze.current?[...ze.current]:l.map(H).slice(0,X),o=ne(n);if(ee.current=!1,Me(o),we(o),it(new Set),lt(new Set),typeof window<"u"&&Q)try{localStorage.removeItem(Q)}catch{}},style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"}),t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=ne(me);ee.current=!0,we(n),pt(n),He(!1)},style:{background:"#2E3236",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Apply"})]})]}):null,xt=R?l.find(e=>H(e)===R):null,gt=xt?t.jsx(rn,{column:xt,columnId:R,filterType:kt(R),position:m,popoverRef:x,distinctValues:_e(R),initialValue:_[R],onApply:e=>{Te(R,e),fe(null)},onCancel:()=>fe(null)},R):null;return t.jsxs("div",{className:"w-full",children:[gt&&Ve.createPortal(gt,document.body),l.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,flexWrap:"wrap"},children:[L&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(Ft,{dateRangePicker:L.dateRangePicker,onWeekToDate:L.onWeekToDate,exportConfig:L.exportConfig,filterChipsConfig:L.filterChipsConfig,trailingActions:L.trailingActions})}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:he,type:"button",onClick:()=>He(!re),style:{display:"inline-flex",alignItems:"center",gap:10,height:32,padding:"0 16px",background:"#FFFFFF",border:"1px solid #D9D9D9",borderRadius:10,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,color:"#2E3236",whiteSpace:"nowrap"},children:[t.jsx(W.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),re&&Ve.createPortal(Ht,document.body)]})]})}),Object.keys(_).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(_).map(([e,n])=>{const o=l.find(u=>H(u)===e);if(!o||!Ce(n))return null;const a=Zt(n),s=Vt(n),p=en(n);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,height:28,padding:"0 12px",borderRadius:20,border:"1px solid #B2B2B0",background:"#F2F2F0",fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",whiteSpace:"nowrap"},children:[t.jsxs("span",{children:[t.jsxs("span",{style:{color:"#676767"},children:[o.label,": "]}),t.jsx("span",{children:a})]}),s>0&&t.jsx(tn,{count:s,values:p}),t.jsx("button",{type:"button",onClick:()=>Te(e,[]),"aria-label":`Remove ${o.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:t.jsx(W.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),t.jsx("button",{type:"button",onClick:jt,style:{marginLeft:"auto",background:"transparent",border:"none",padding:"0 4px",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"})]}),l.length>0&&xe.length>0?t.jsxs(T.DndContext,{sensors:Bt,collisionDetection:T.closestCenter,onDragStart:Wt,onDragEnd:Nt,children:[t.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[G&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[t.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),t.jsx(sn,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),t.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Mt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"auto",minWidth:"100%",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)",border:"1px solid #e6e6e6",boxSizing:"border-box"},children:[t.jsx("thead",{children:t.jsx("tr",{children:t.jsx(T.SortableContext,{items:z,strategy:T.horizontalListSortingStrategy,children:xe.map(e=>t.jsx(_t,{column:e,isHeaderRow:!0},`header-${H(e)}`))})})}),t.jsx("tbody",{children:!G&&Ie.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:xe.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!G&&Ie.length>0?Ie.map((e,n)=>t.jsx("tr",{"data-row-id":e.id||n,style:{borderBottom:"1px solid #e6e6e6",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?o=>{o.stopPropagation(),f(e,n)}:void 0,onMouseEnter:o=>{o.currentTarget.style.background="#E6E6E6"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:xe.map(o=>{const a=H(o),s=dt(a,o.width),p=e[a],u=o.render?o.render(p,e):p,b=s&&s!=="auto",I=typeof u=="string"&&u.trim()!=="",P=b&&I,ke=P?t.jsx(Z,{content:u,children:u}):u;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid #e6e6e6",boxSizing:"border-box",width:s,fontFamily:"var(--font-sans)",...P&&{maxWidth:s||"200px"}},children:ke},a)})},n)):null})]})})]}),t.jsx(T.DragOverlay,{children:mt?t.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(W.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:mt.label})]})}):null})]}):null,(()=>{const e=!A&&(be.trim()!==""||Object.values(_).some(o=>Ce(o))),n=U?e?je.length:v:je.length;return n<=0?null:t.jsx(wt.Pagination,{page:V,pageSizeOptions:[5,10,20,50,100],pageSize:K,totalCount:n,currentDataLength:Ie.length,onPageChange:de,onPageSizeChange:o=>{ye(o),de(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=ln;exports.DataTableFilters=Ft;
1
+ "use strict";const t=require("react/jsx-runtime"),i=require("react"),T=require("./sortable.esm.cjs.js"),W=require("lucide-react"),Ve=require("react-dom"),wt=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./TourGuideTooltip.cjs.js");function Ft({dateRangePicker:r,onWeekToDate:l,exportConfig:d,filterChipsConfig:f,trailingActions:v}){const[y,c]=i.useState(!1),g=i.useRef(null),E=i.useRef(null);i.useEffect(()=>{const S=F=>{E.current&&!E.current.contains(F.target)&&g.current&&!g.current.contains(F.target)&&c(!1)};if(y)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[y]);const w=()=>{c(S=>!S)},j=S=>{c(!1),d!=null&&d.onExport&&d.onExport(S)},M=(()=>{if(!(f!=null&&f.filters))return!1;const S=f.filters,F=f.customFilters||[],G=Object.entries(S).some(([C,$])=>!!(Array.isArray($)&&$.length||typeof $=="string"&&$.trim()!==""||$&&typeof $=="object"&&($.min!=null||$.max!=null))),L=F.some(C=>C.active);return G||L})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l&&t.jsxs("button",{onClick:l,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[t.jsx(W.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),r&&t.jsx(i.Suspense,{fallback:t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[t.jsx(W.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:r}),d&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:g,onClick:w,disabled:d.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(W.Download,{size:16}),t.jsx("span",{children:d.isExporting?"Exporting...":"Export"})]}),t.jsx(W.ChevronDown,{size:16})]}),y&&t.jsx("div",{ref:E,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(d.types||["csv"]).map(S=>t.jsxs("button",{onClick:()=>j(S),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",S.toUpperCase()]},S))})]}),(M||v)&&t.jsxs(t.Fragment,{children:[M&&t.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[M&&f&&t.jsx(wt.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),v&&t.jsx("div",{className:"flex-shrink-0",children:v})]})]})]})}function et(r){if(r==null)return NaN;const l=String(r).replace(/[,$%]|pp/gi,"").trim(),d=parseFloat(l);return Number.isFinite(d)?d:NaN}function Jt(r){if(r==null)return NaN;const l=String(r).trim(),d=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(d){const w=+d[1],j=+d[2],N=d[3]!=null?+d[3]:null;return N!=null?w*3600+j*60+N:w*60+j}let f=0,v=!1;const y=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),g=l.match(/(\d+)\s*m(?!s)\b/i),E=l.match(/(\d+)\s*s\b/i);return y&&(f+=+y[1]*86400,v=!0),c&&(f+=+c[1]*3600,v=!0),g&&(f+=+g[1]*60,v=!0),E&&(f+=+E[1],v=!0),v?f:NaN}function Yt(r){if(!r)return null;const l=String(r).trim(),d=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(d){const v=d[3].length===2?2e3+ +d[3]:+d[3],y=new Date(v,+d[1]-1,+d[2]);return isNaN(y.getTime())?null:y}const f=new Date(l);return isNaN(f.getTime())?null:f}function Qt(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),d=f=>l.every(f);return d(f=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(f)||/^\d{4}-\d{2}-\d{2}/.test(f))?"date":d(f=>/^\d+\s*[dhms]\b/i.test(f)||/^\d+:\d+(:\d+)?$/.test(f))?"duration":d(f=>/^-?[\d,.]+(%|pp)?$/i.test(f))?"number":"text"}function Ce(r){return r?Array.isArray(r)?r.length>0:r.type==="range"?r.min!==""&&r.min!==void 0&&r.min!==null||r.max!==""&&r.max!==void 0&&r.max!==null:r.type==="durationRange"?r.minSec!==""&&r.minSec!=null||r.maxSec!==""&&r.maxSec!=null:r.type==="scoreRange"?Array.isArray(r.values)&&r.values.length>0||r.min!==""&&r.min!=null||r.max!==""&&r.max!=null:r.type==="dateRange"?!!(r.from||r.to):!1:!1}function bt(r){if(r==null||r===""||isNaN(r))return"";const l=Number(r),d=Math.floor(l/3600),f=Math.floor(l%3600/60),v=Math.floor(l%60);return d>0?`${d}h ${f}m`:f>0?`${f}m ${v}s`:`${v}s`}function Zt(r){if(!r)return"";if(Array.isArray(r))return r.length===0?"":String(r[0]);if(r.type==="range"){const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}if(r.type==="durationRange"){const l=r.minSec!==""&&r.minSec!=null?bt(r.minSec):null,d=r.maxSec!==""&&r.maxSec!=null?bt(r.maxSec):null;return l&&d?`${l} – ${d}`:l?`≥ ${l}`:d?`≤ ${d}`:""}if(r.type==="scoreRange"){if(Array.isArray(r.values)&&r.values.length>0)return r.values.slice().sort((f,v)=>f-v).join(", ");const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}return r.type==="dateRange"?r.from&&r.to?`${r.from} – ${r.to}`:r.from?`from ${r.from}`:r.to?`to ${r.to}`:"":""}function Vt(r){return Array.isArray(r)?Math.max(0,r.length-1):0}function en(r){return Array.isArray(r)?r.slice(1).map(String).join(", "):""}function tn({count:r,values:l}){const[d,f]=i.useState(!1);return t.jsxs("span",{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:22,minWidth:22,padding:"0 6px",background:"#D8D8D8",color:"#0B0B0B",borderRadius:14,fontSize:12,fontWeight:500,lineHeight:1,cursor:"pointer"},children:["+",r,d&&t.jsx("span",{role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:"#1E2125",color:"#FFFFFF",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:400,lineHeight:"20px",padding:"6px 10px",borderRadius:8,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100,boxShadow:"0 6px 16px rgba(11, 11, 11, 0.18)"},children:l})]})}function nn({leftLabel:r,rightLabel:l,leftValue:d,rightValue:f,onLeftChange:v,onRightChange:y,type:c="number",placeholderLeft:g="Min",placeholderRight:E="Max"}){const w={width:"100%",height:32,borderRadius:8,border:"1px solid #D9D9D9",background:"#FFFFFF",padding:"0 10px",fontFamily:"var(--font-sans)",fontSize:14,color:"#0B0B0B",outline:"none",boxSizing:"border-box"},j={fontSize:12,color:"#676767",marginBottom:4,fontFamily:"var(--font-sans)"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:r}),t.jsx("input",{type:c,value:d,onChange:N=>v(N.target.value),placeholder:g,style:w})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:l}),t.jsx("input",{type:c,value:f,onChange:N=>y(N.target.value),placeholder:E,style:w})]})]})}const St=[{id:"0-60",label:"0 to 60 Sec",minSec:0,maxSec:60},{id:"60-120",label:"1m to 2 m",minSec:60,maxSec:120},{id:"120-180",label:"2m to 3 m",minSec:120,maxSec:180},{id:"180-240",label:"3m to 4m",minSec:180,maxSec:240},{id:"240-300",label:"4m to 5m",minSec:240,maxSec:300},{id:"300+",label:"5 mins and above",minSec:300,maxSec:null}];function vt(r){if(r==null||r==="")return null;const l=String(r).trim().match(/^(\d{1,3}):(\d{2})$/);if(l)return Number(l[1])*60+Number(l[2]);const d=Number(r);return Number.isFinite(d)?d:null}function Qe({children:r}){return t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0 2px",fontFamily:"var(--font-sans)"},children:r})}function Ze({minValue:r,maxValue:l,onMinChange:d,onMaxChange:f,inputType:v="number",inputMode:y="decimal",step:c,placeholder:g="0.0",unit:E}){const w={width:"100%",height:30,border:"1px solid #ACADAD",borderRadius:4,padding:"6px 10px",fontSize:13,color:"#0B0B0B",fontFamily:"var(--font-sans)",outline:"none",boxSizing:"border-box"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Min From"}),t.jsx("input",{type:v,inputMode:y,step:c,placeholder:g,value:r,onChange:j=>d(j.target.value),style:w})]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#323232",paddingBottom:8,fontFamily:"var(--font-sans)"},children:"to"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Max"}),t.jsx("input",{type:v,inputMode:y,step:c,placeholder:g,value:l,onChange:j=>f(j.target.value),style:w})]})]}),E&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Input values in ",E==="sec"?"seconds":E]})]})}function rn({column:r,columnId:l,filterType:d="text",position:f,popoverRef:v,distinctValues:y,initialValue:c,onApply:g,onCancel:E}){const w=d==="text",j=d==="number",N=d==="date",M=d==="duration",S=d==="score",F=i.useMemo(()=>{if(!S||!Array.isArray(y)||y.length===0)return!1;let m=1/0,h=-1/0;for(const x of y){const O=et(x);Number.isFinite(O)&&(O<m&&(m=O),O>h&&(h=O))}return Number.isFinite(m)&&Number.isFinite(h)&&m>=0&&h<=5},[S,y]),[G,L]=i.useState(()=>w?new Set(Array.isArray(c)?c:[]):new Set),[C,$]=i.useState(""),[oe,se]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[D,Z]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[U,A]=i.useState(new Set),[q,ce]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[J,ie]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[Y,V]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[K,de]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[ye,X]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[z,ee]=i.useState(()=>N&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[Q,ae]=i.useState(()=>N&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");i.useEffect(()=>{w&&L(new Set(Array.isArray(c)?c:[]))},[l,w]);const _=i.useMemo(()=>{const m=C.trim().toLowerCase();return m?y.filter(h=>String(h).toLowerCase().includes(m)):y},[y,C]),pe=m=>{L(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},be=()=>{w&&L(new Set),j&&(se(""),Z("")),M&&(A(new Set),ce(""),ie("")),S&&(V(new Set),de(""),X("")),N&&(ee(""),ae("")),$("")},De=m=>{A(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},R=m=>{V(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},fe=()=>{if(w)return g(Array.from(G));if(j)return g({type:"range",min:oe===""?"":Number(oe),max:D===""?"":Number(D)});if(M){const m=vt(q),h=vt(J),x=m!=null||h!=null;let O="",ue="";if(x)O=m??"",ue=h??"";else if(U.size>0){const Se=St.filter(te=>U.has(te.id));O=Math.min(...Se.map(te=>te.minSec)),ue=Se.some(te=>te.maxSec==null)?"":Math.max(...Se.map(te=>te.maxSec))}return g({type:"durationRange",minSec:O,maxSec:ue})}if(S){const m=K===""?null:Number(K),h=ye===""?null:Number(ye);return m!=null||h!=null?g({type:"scoreRange",values:[],min:m!=null&&Number.isFinite(m)?m:"",max:h!=null&&Number.isFinite(h)?h:""}):g({type:"scoreRange",values:Array.from(Y).sort((O,ue)=>O-ue),min:"",max:""})}if(N)return g({type:"dateRange",from:z,to:Q})};return t.jsxs("div",{ref:v,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:f.top,left:f.left,zIndex:50,width:w?240:220,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,padding:12,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 8px 24px rgba(11, 11, 11, 0.10)",fontFamily:"var(--font-sans)"},children:[w&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{background:"#D8D8D8",height:32,borderRadius:10,padding:1,display:"flex",alignItems:"center"},children:t.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[t.jsx(W.Search,{size:16,color:"#989898",strokeWidth:2}),t.jsx("input",{autoFocus:!0,type:"text",value:C,onChange:m=>$(m.target.value),placeholder:"Search",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#0B0B0B",minWidth:0,fontFamily:"var(--font-sans)"}})]})}),t.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},children:_.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):_.map(m=>{const h=G.has(m);return t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"6px 4px",cursor:"pointer",borderRadius:6},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("input",{type:"checkbox",checked:h,onChange:()=>pe(m),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),t.jsx("span",{onClick:x=>{x.preventDefault(),pe(m)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]},m)})})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Filter"}),t.jsx(Ze,{minValue:oe,maxValue:D,onMinChange:se,onMaxChange:Z})]}),M&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Duration"}),r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:St.map(m=>{const h=U.has(m.id);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>De(m.id),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),De(m.id))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m.label})]},m.id)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"})]}),t.jsx(Ze,{minValue:q,maxValue:J,onMinChange:ce,onMaxChange:ie,inputType:"number",inputMode:"numeric",placeholder:"0",unit:"sec"})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Score"}),F&&r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[1,2,3,4,5].map(m=>{const h=Y.has(m);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>R(m),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),R(m))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m})]},m)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}})]}),F&&r.filterShowPresets===!0&&t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"}),t.jsx(Ze,{minValue:K,maxValue:ye,onMinChange:de,onMaxChange:X,step:"0.1"})]}),N&&t.jsx(nn,{leftLabel:"From",rightLabel:"To",leftValue:z,rightValue:Q,onLeftChange:ee,onRightChange:ae,type:"date",placeholderLeft:"",placeholderRight:""}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("button",{type:"button",onClick:be,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:M&&r.filterShowPresets===!0||S&&F&&r.filterShowPresets===!0?"View All":"Reset"}),t.jsx("button",{type:"button",onClick:fe,style:{background:"#0B0B0B",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Apply"})]})]})}const on=()=>({userData:{email:"anonymous"}}),sn=r=>t.jsx("img",{...r});function an({children:r,content:l,direction:d="top",align:f="center",styling:v,indicatorColor:y}){const c=typeof l=="string"?l:l!=null?String(l):"",g=typeof y=="string"&&(y.startsWith("#")||y.startsWith("rgb")||y.startsWith("hsl")||y.startsWith("var("))?y:"var(--Grey-Strong, #2E3236)",[E,w]=i.useState(!1),[j,N]=i.useState(!1),[M,S]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),F=i.useRef(null),G=i.useRef(null);if(!c)return r;i.useEffect(()=>{N(!0)},[]);const L=i.useCallback(()=>{if(!F.current||!G.current||typeof window>"u")return;const C=F.current.getBoundingClientRect(),$=G.current.getBoundingClientRect(),oe=window.innerWidth,se=window.innerHeight,D=8,Z=10,U=$.width,A=$.height,q=C.top,ce=se-C.bottom,J=d==="bottom"?"bottom":"top";let ie=J;J==="top"&&q<A+Z+D&&ce>q?ie="bottom":J==="bottom"&&ce<A+Z+D&&q>ce&&(ie="top");let Y=C.left+C.width/2;f==="start"&&(Y=C.left),f==="end"&&(Y=C.right);let V=ie==="top"?C.top-A-Z:C.bottom+Z,K=f==="start"?Y:f==="end"?Y-U:Y-U/2;V=Math.max(D,Math.min(V,se-A-D)),K=Math.max(D,Math.min(K,oe-U-D));const de=Math.max(10,Math.min(Y-K,U-10));S({top:V,left:K,arrowLeft:de,placement:ie})},[f,d]);return i.useEffect(()=>{if(!E||!j)return;L();const C=()=>L();return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[E,j,L]),t.jsxs("span",{ref:F,style:{display:"block",width:"100%"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:[r,E&&j&&Ve.createPortal(t.jsxs("span",{ref:G,style:{position:"fixed",top:`${M.top}px`,left:`${M.left}px`,background:"var(--Grey-Strong, #2E3236)",color:"var(--Grey-White, #FFF)",fontSize:"12px",lineHeight:1.3,fontWeight:500,padding:"8px 10px",borderRadius:"6px",whiteSpace:"normal",maxWidth:"320px",width:"max-content",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.2)",zIndex:99999,pointerEvents:"none",...typeof v=="object"?v:{}},children:[c,t.jsx("span",{style:{position:"absolute",left:`${M.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...M.placement==="top"?{top:"100%",borderTop:`7px solid ${g}`}:{bottom:"100%",borderBottom:`7px solid ${g}`}}})]}),document.body)]})}function ln({data:r=[],columns:l=[],initialPageSize:d=10,onRowClick:f,totalCount:v=null,page:y=null,pageSize:c=null,onPageChange:g=null,onPageSizeChange:E=null,onFilterChange:w=null,columnFilters:j=null,onMaxColumnsError:N=null,onSort:M=null,sortFields:S=[],tableId:F=null,isLoading:G=!1,filtersConfig:L=null,columnResizeMinWidth:C=120,columnResizeMaxWidth:$=280,onVisibleColumnsChange:oe=null}){var yt;const{userData:se}=on(),D=(se==null?void 0:se.email)||"anonymous",Z=i.memo(({children:e,content:n,className:o=""})=>{const a=i.useRef(null),[s,p]=i.useState(!1);i.useEffect(()=>{const b=()=>{if(a.current){const P=a.current.scrollWidth>a.current.clientWidth;p(P)}};b();const I=setTimeout(b,0);return window.addEventListener("resize",b),()=>{clearTimeout(I),window.removeEventListener("resize",b)}},[e,n]);const u=t.jsx("span",{className:`truncate block ${o}`,ref:a,children:e});return s&&n?t.jsx(an,{content:n,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:u}):u});Z.displayName="TruncatedCell";const U=v!==null&&g!==null,A=w!==null,q=M!==null,[ce,J]=i.useState(1),[ie,Y]=i.useState(d),V=y!==null?y:ce,K=c!==null?c:ie,de=e=>{g?g(e):J(e)},ye=e=>{E?E(e):Y(e)},X=50,z="action",ee=i.useRef(!1),Q=i.useMemo(()=>F?`dataTable_columns_${F}:${D}`:`dataTable_columns_${l.map(n=>n.id||n.key).sort().join("_")}:${D}`,[F,l,D]),ae=i.useMemo(()=>F?`dataTable_manual_change_${F}:${D}`:null,[F,D]);i.useCallback((e,n)=>{if(typeof window>"u"||!e||!n||n.length===0)return null;try{const o=localStorage.getItem(e);if(o){const s=JSON.parse(o).filter(p=>n.some(u=>(u.id||u.key)===p));if(s.length>0)return s}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}return null},[]);const[_,pe]=i.useState({}),[be,De]=i.useState(""),[R,fe]=i.useState(null),[m,h]=i.useState({top:0,left:0}),x=i.useRef(null),O=i.useRef({}),[ue,Se]=i.useState(null),[Oe,te]=i.useState("asc"),Te=i.useCallback((e,n)=>{const o=Ce(n);pe(a=>{const s={...a};return o?s[e]=n:delete s[e],s}),g?g(1):J(1),A&&w&&w(o?{..._,[e]:n}:Object.fromEntries(Object.entries(_).filter(([a])=>a!==e)))},[_,w,A,g]),jt=i.useCallback(()=>{pe({}),De(""),g?g(1):J(1),A&&w&&w({})},[w,A,g]),_e=i.useCallback(e=>{if(!r||r.length===0)return[];const n=new Set,o=[];for(const a of r){const s=a[e];if(s==null)continue;const p=typeof s=="object"?JSON.stringify(s):String(s);n.has(p)||(n.add(p),o.push(p))}return o.sort((a,s)=>a.localeCompare(s))},[r]),kt=i.useCallback(e=>{const n=l.find(o=>H(o)===e);return n&&n.filterType?n.filterType:Qt(_e(e))},[l,_e]),Re=i.useCallback(e=>{const a=typeof window<"u"?window.innerWidth:1/0;let s=e.left;return s+280>a-8&&(s=Math.max(8,e.right-280)),{top:e.bottom+6,left:s}},[]),Ct=i.useCallback((e,n)=>{if(!n){fe(e);return}const o=n.getBoundingClientRect();h(Re(o)),fe(a=>a===e?null:e)},[Re]);i.useEffect(()=>{if(!R)return;const e=n=>{if(x.current&&x.current.contains(n.target))return;const o=O.current[R];o&&o.contains(n.target)||fe(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[R]),i.useEffect(()=>{if(!R)return;const e=()=>{const n=O.current[R];if(!n)return;const o=n.getBoundingClientRect();h(Re(o))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[R,Re]),i.useLayoutEffect(()=>{if(!R)return;const e=x.current,n=O.current[R];if(!e||!n)return;const o=e.offsetWidth,a=n.getBoundingClientRect(),s=8,p=typeof window<"u"?window.innerWidth:1/0;if(!(a.left+o>p-s))return;const b=Math.max(s,a.right-o);h(I=>I.left===b?I:{...I,left:b})},[R,m.top]);const tt=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim()!=="":!0)),[]),nt=i.useCallback((e,n)=>{const o=Object.keys(e||{}),a=Object.keys(n||{});return o.length!==a.length?!1:o.every(s=>e[s]===n[s])},[]);i.useEffect(()=>{if(!A||j===null)return;const e=tt(j);pe(n=>nt(n,e)?n:e)},[A,j,tt,nt]),i.useCallback((e,n)=>e==="csat_score"&&n==="evaluation.csat_score"?n:e,[]);const ve=q&&S.length>0?S[0][0]:ue,Ee=q&&S.length>0?S[0][1]:Oe,[cn,rt]=i.useState(()=>l.map(e=>e.id||e.key)),ne=i.useCallback(e=>{if(!e||e.length===0)return e;let n=Array.from(new Set(e));n.length>X&&(n=n.slice(0,X));const a=l.map(u=>u.id||u.key).includes(z);return!n.includes(z)&&a&&(n.length>=X?n=[...n.slice(0,X-1),z]:n=[...n,z]),[...n.filter(u=>u!==z),z]},[l]),[B,we]=i.useState(()=>{if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const a=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(a){const s=JSON.parse(a);if(Array.isArray(s)&&s.length>0){ee.current=!0;const p=s.filter(u=>l.some(b=>(b.id||b.key)===u));if(p.length>0)return p.slice(0,X)}}}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}const n=l.map(o=>o.id||o.key).slice(0,X);return ne(n)}),[re,He]=i.useState(!1),[me,Me]=i.useState([]),[ot,Dt]=i.useState({top:0,left:0,width:0}),[st,it]=i.useState(new Set),[at,lt]=i.useState(new Set),ze=i.useRef(null);ze.current===null&&(ze.current=[...B]);const[le,qe]=i.useState(null),[Rt,Be]=i.useState(null),he=i.useRef(null),Ke=i.useRef(null),Xe=i.useRef(null),[ct,Ge]=i.useState(null),[Ue,Et]=i.useState({}),Mt=i.useRef(null),Ne=i.useRef(null),H=e=>e.id||e.key,We=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=e.trim();if(n.endsWith("px")){const a=parseFloat(n);return Number.isFinite(a)?a:null}const o=parseFloat(n);return Number.isFinite(o)&&`${o}`===n?o:null}return null},[]),dt=i.useCallback((e,n)=>Ue[e]!=null?`${Ue[e]}px`:typeof n=="number"?`${n}px`:n||"auto",[Ue]),$e=i.useCallback(e=>{if(!Ne.current)return;const{columnId:n,startX:o,startWidth:a,minWidth:s,maxWidth:p}=Ne.current,u=e.clientX-o,b=Math.round(a+u),I=Math.min(p,Math.max(s,b));Et(P=>({...P,[n]:I}))},[]),Fe=i.useCallback(()=>{Ne.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Fe)},[$e]),zt=i.useCallback((e,n,o)=>{var Pe;e.preventDefault(),e.stopPropagation();const a=n.id||n.key,s=We(n.minWidth)??C,p=We(n.maxWidth)??$,u=Math.min(s,p),b=Math.max(s,p),I=((Pe=e.currentTarget.closest("th"))==null?void 0:Pe.getBoundingClientRect().width)||0,P=We(o),ke=P??Math.max(u,Math.round(I)||u),Je=Math.min(b,Math.max(u,ke));Ne.current={columnId:a,startX:e.clientX,startWidth:Je,minWidth:u,maxWidth:b},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",Fe)},[$,C,$e,Fe,We]);i.useEffect(()=>()=>Fe(),[Fe]);const Bt=T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor,{coordinateGetter:T.sortableKeyboardCoordinates})),Nt=e=>{const{active:n,over:o}=e;if(o&&n.id!==o.id){if(n.id===z||o.id===z){ft("Cannot drop columns on the Action column"),Ge(null);return}ee.current=!0,we(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);if(s!==-1&&p!==-1){const u=T.arrayMove(a,s,p),b=ne(u);return pt(b),b}return a}),rt(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);return T.arrayMove(a,s,p)})}Ge(null)},Wt=e=>{Ge(e.active.id)},Ae=i.useMemo(()=>{if(A)return r||[];if(!r||r.length===0)return[];const e=be.trim().toLowerCase(),n=Object.entries(_).filter(([,o])=>Ce(o));return r.filter(o=>{for(const[a,s]of n){const p=o[a];if(p==null)return!1;if(Array.isArray(s)){const u=String(p);if(!s.some(b=>String(b)===u))return!1;continue}if(s.type==="range"){const u=et(p);if(isNaN(u)||s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="durationRange"){const u=Jt(p);if(isNaN(u)||s.minSec!==""&&s.minSec!=null&&u<Number(s.minSec)||s.maxSec!==""&&s.maxSec!=null&&u>Number(s.maxSec))return!1;continue}if(s.type==="scoreRange"){const u=et(p);if(isNaN(u))return!1;if(Array.isArray(s.values)&&s.values.length>0){const b=Math.floor(u);if(!s.values.includes(b))return!1;continue}if(s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="dateRange"){const u=Yt(p);if(!u)return!1;if(s.from){const b=new Date(s.from+"T00:00:00");if(u<b)return!1}if(s.to){const b=new Date(s.to+"T23:59:59");if(u>b)return!1}continue}}return!(e&&!Object.values(o).some(s=>s==null?!1:String(s).toLowerCase().includes(e)))})},[r,_,be,A]),je=i.useMemo(()=>q||!ve?Ae:[...Ae].sort((e,n)=>{const o=e[ve],a=n[ve];if(o==null)return 1;if(a==null)return-1;if(typeof o=="number"&&typeof a=="number")return Ee==="asc"?o-a:a-o;const s=String(o).toLowerCase(),p=String(a).toLowerCase();return Ee==="asc"?s.localeCompare(p):p.localeCompare(s)}),[Ae,ve,Ee,q]),Ie=i.useMemo(()=>{if(U)return je;{const e=(V-1)*K,n=e+K;return je.slice(e,n)}},[je,V,K,U]),ut=e=>{q&&M?(M(e),g?g(1):J(1)):(ue===e?te(Oe==="asc"?"desc":"asc"):(Se(e),te("asc")),de(1))},$t=(e,n)=>{const o=(n||"").split(/\s+/).map(a=>a.trim()).filter(Boolean);Te(e,o)},ft=e=>{Xe.current||(typeof N=="function"&&N(e),Xe.current=setTimeout(()=>{Xe.current=null},3e3))},pt=i.useCallback(e=>{if(typeof window<"u"&&Q&&e.length>0&&ee.current)try{localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(n){console.warn("Failed to save columns to localStorage:",n)}},[Q,ae]),At=e=>{e!==z&&Me(n=>n.includes(e)?n.length===1?n:n.filter(o=>o!==e):n.length>=X?(ft("Maximum 9 column selection allowed"),n):ne([...n,e]))},It=(e,n)=>{me[n]!==z&&qe(n)},Pt=()=>{qe(null),Be(null)},Lt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&Be(n)},Ot=()=>{Be(null)},Tt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&me[n]!==z&&me[le]!==z&&Me(o=>{const a=T.arrayMove(o,le,n);return ne(a)}),qe(null),Be(null)};i.useEffect(()=>{rt(e=>{const n=B.filter(s=>e.includes(s)),o=B.filter(s=>!e.includes(s)),a=e.filter(s=>!B.includes(s));return[...n,...o,...a]})},[B]),i.useEffect(()=>{if(typeof window<"u"&&Q&&B.length>0&&ee.current)try{const e=ne(B);localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[B,Q,ae]),i.useEffect(()=>{oe&&oe(B.filter(e=>e!==z))},[B,oe]),i.useEffect(()=>{if(l.length>0&&B.length===0){if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(o){const a=JSON.parse(o);if(Array.isArray(a)&&a.length>0){const s=a.filter(p=>l.some(u=>(u.id||u.key)===p));if(s.length>0){ee.current=!0,we(s.slice(0,X));return}}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const e=l.map(n=>n.id||n.key);we(ne(e.slice(0,X)))}},[l,F,D,ne]);const xe=i.useMemo(()=>{const e=B.map(n=>l.find(o=>H(o)===n)).filter(Boolean);return ne(e.map(H)).map(n=>l.find(o=>H(o)===n)).filter(Boolean)},[l,B]);i.useMemo(()=>xe.some(e=>e.filterable===!0),[xe]),i.useEffect(()=>{if(!re||!he.current)return;const e=()=>{if(he.current){const n=he.current.getBoundingClientRect(),o=217,a=Math.max(8,n.right-o);Dt({top:n.bottom,left:a,width:Math.max(n.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[re]),i.useEffect(()=>{const e=n=>{re&&he.current&&!he.current.contains(n.target)&&Ke.current&&!Ke.current.contains(n.target)&&He(!1)};if(re)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[re]),i.useEffect(()=>{re&&(Me(B),it(new Set),lt(new Set))},[re,B]),B.length===1?(yt=l.find(e=>(e.id||e.key)===B[0]))!=null&&yt.label:`${B.length}`;function _t({column:e,isHeaderRow:n=!0}){const o=H(e),a=o===z,s=dt(o,e.width),[p,u]=i.useState(!1),{attributes:b,listeners:I,setNodeRef:P,transform:ke,transition:Je,isDragging:Pe}=T.useSortable({id:o}),qt={transform:T.CSS.Transform.toString(ke),transition:Je,opacity:Pe?.5:1,width:s,minWidth:s};let ge=!1;if(q&&S.length>0){const k=S[0][0];(k===o||k==="csat_score"&&o==="evaluation.csat_score")&&(ge=!0)}else ge=ve===o;const Kt=Ee==="asc",Xt=e.filterable===!0;if(!n)return t.jsx("th",{style:{width:s,minWidth:s,backgroundColor:"var(--primary-foreground)",borderRight:"1px solid #e6e6e6",borderBottom:"1px solid #e6e6e6",boxSizing:"border-box"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:Xt?t.jsxs("div",{className:"relative",children:[t.jsx(Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),t.jsx("input",{type:"text",placeholder:"Filter...",value:_[o]||"",onChange:k=>{k.stopPropagation(),$t(o,k.target.value)},onKeyDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})});const Ye=R===o,Le=Ce(_[o]),Gt=e.sortable!==!1&&(p||ge),Ut=e.filterable!==!1&&!a&&(p||Ye||Le);return t.jsxs("th",{ref:P,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...qt,padding:"0 12px",height:36,textAlign:a?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:s,...typeof s=="string"&&s.endsWith("px")?{maxWidth:s}:{},borderRight:"1px solid #e6e6e6",boxSizing:"border-box",userSelect:"none",whiteSpace:"nowrap",wordBreak:"normal",overflowWrap:"normal",verticalAlign:"middle",background:p||Ye?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!a&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:a?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!a&&t.jsx("div",{...b,...I,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:p?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&ut(o),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:a?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),Gt&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),ut(o)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:ge?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:ge?Kt?t.jsx(W.ArrowUp,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowDown,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowUpDown,{size:14,strokeWidth:1.75})}),Ut&&t.jsxs("button",{type:"button",ref:k=>{O.current[o]=k},onClick:k=>{k.stopPropagation(),Ct(o,k.currentTarget)},title:"Filter",style:{position:"relative",background:Ye||Le?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Le?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[t.jsx(W.ListFilter,{size:14,strokeWidth:1.75}),Le&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),!a&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||o} column`,title:"Drag to resize column",onMouseDown:k=>zt(k,e,s),onClick:k=>k.stopPropagation(),onMouseEnter:k=>{k.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const mt=ct?l.find(e=>H(e)===ct):null,ht=({col:e,columnId:n,isSelected:o,draggable:a,isAction:s,actualIndex:p})=>{const u=a&&le===p,b=a&&Rt===p&&le!==null&&le!==p;o?at.has(n):st.has(n);const I=o?!at.has(n):st.has(n);return t.jsxs("div",{draggable:a,onDragStart:a?P=>It(P,p):void 0,onDragEnd:a?Pt:void 0,onDragOver:a?P=>Lt(P,p):void 0,onDragLeave:a?Ot:void 0,onDrop:a?P=>Tt(P,p):void 0,onClick:()=>{s||At(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:s?"default":a?"grab":"pointer",opacity:u?.5:1,background:b?"#F2F2F0":"transparent",borderRadius:6},children:[t.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:a?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14,strokeWidth:1.75})}),t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:I?"#0B0B0B":"#FFFFFF",border:`1px solid ${I?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:I&&t.jsx(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{flex:1,fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",marginLeft:8},children:e.label})]})},Ht=re?t.jsxs("div",{ref:Ke,style:{position:"fixed",top:`${ot.top}px`,left:`${ot.left}px`,width:217,maxHeight:320,zIndex:49,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)",boxShadow:"0 8px 24px rgba(11, 11, 11, 0.08)"},children:[t.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:12},children:[me.map((e,n)=>{if(e===z)return null;const o=l.find(a=>H(a)===e);return o?t.jsx(i.Fragment,{children:ht({col:o,columnId:e,isSelected:!0,draggable:!0,isAction:!1,actualIndex:n})},`selected-${e}-${n}`):null}),l.filter(e=>{const n=H(e);return n!==z&&!me.includes(n)}).map(e=>{const n=H(e);return t.jsx(i.Fragment,{children:ht({col:e,columnId:n,isSelected:!1,draggable:!1,isAction:!1,actualIndex:-1})},`unselected-${n}`)})]}),t.jsxs("div",{style:{flexShrink:0,borderTop:"1px solid #D9D9D9",padding:"8px 12px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"space-between",height:46,boxSizing:"border-box"},children:[t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=ze.current?[...ze.current]:l.map(H).slice(0,X),o=ne(n);if(ee.current=!1,Me(o),we(o),it(new Set),lt(new Set),typeof window<"u"&&Q)try{localStorage.removeItem(Q)}catch{}},style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"}),t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=ne(me);ee.current=!0,we(n),pt(n),He(!1)},style:{background:"#2E3236",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Apply"})]})]}):null,xt=R?l.find(e=>H(e)===R):null,gt=xt?t.jsx(rn,{column:xt,columnId:R,filterType:kt(R),position:m,popoverRef:x,distinctValues:_e(R),initialValue:_[R],onApply:e=>{Te(R,e),fe(null)},onCancel:()=>fe(null)},R):null;return t.jsxs("div",{className:"w-full",children:[gt&&Ve.createPortal(gt,document.body),l.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,flexWrap:"wrap"},children:[L&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(Ft,{dateRangePicker:L.dateRangePicker,onWeekToDate:L.onWeekToDate,exportConfig:L.exportConfig,filterChipsConfig:L.filterChipsConfig,trailingActions:L.trailingActions})}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:he,type:"button",onClick:()=>He(!re),style:{display:"inline-flex",alignItems:"center",gap:10,height:32,padding:"0 16px",background:"#FFFFFF",border:"1px solid #D9D9D9",borderRadius:10,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,color:"#2E3236",whiteSpace:"nowrap"},children:[t.jsx(W.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),re&&Ve.createPortal(Ht,document.body)]})]})}),Object.keys(_).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(_).map(([e,n])=>{const o=l.find(u=>H(u)===e);if(!o||!Ce(n))return null;const a=Zt(n),s=Vt(n),p=en(n);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,height:28,padding:"0 12px",borderRadius:20,border:"1px solid #B2B2B0",background:"#F2F2F0",fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",whiteSpace:"nowrap"},children:[t.jsxs("span",{children:[t.jsxs("span",{style:{color:"#676767"},children:[o.label,": "]}),t.jsx("span",{children:a})]}),s>0&&t.jsx(tn,{count:s,values:p}),t.jsx("button",{type:"button",onClick:()=>Te(e,[]),"aria-label":`Remove ${o.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:t.jsx(W.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),t.jsx("button",{type:"button",onClick:jt,style:{marginLeft:"auto",background:"transparent",border:"none",padding:"0 4px",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"})]}),l.length>0&&xe.length>0?t.jsxs(T.DndContext,{sensors:Bt,collisionDetection:T.closestCenter,onDragStart:Wt,onDragEnd:Nt,children:[t.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[G&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[t.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),t.jsx(sn,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),t.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Mt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"auto",minWidth:"100%",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)",border:"1px solid #e6e6e6",boxSizing:"border-box"},children:[t.jsx("thead",{children:t.jsx("tr",{children:t.jsx(T.SortableContext,{items:B,strategy:T.horizontalListSortingStrategy,children:xe.map(e=>t.jsx(_t,{column:e,isHeaderRow:!0},`header-${H(e)}`))})})}),t.jsx("tbody",{children:!G&&Ie.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:xe.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!G&&Ie.length>0?Ie.map((e,n)=>t.jsx("tr",{"data-row-id":e.id||n,style:{borderBottom:"1px solid #e6e6e6",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?o=>{o.stopPropagation(),f(e,n)}:void 0,onMouseEnter:o=>{o.currentTarget.style.background="#E6E6E6"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:xe.map(o=>{const a=H(o),s=dt(a,o.width),p=e[a],u=o.render?o.render(p,e):p,b=s&&s!=="auto",I=typeof u=="string"&&u.trim()!=="",P=b&&I,ke=P?t.jsx(Z,{content:u,children:u}):u;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid #e6e6e6",boxSizing:"border-box",width:s,fontFamily:"var(--font-sans)",...P&&{maxWidth:s||"200px"}},children:ke},a)})},n)):null})]})})]}),t.jsx(T.DragOverlay,{children:mt?t.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(W.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:mt.label})]})}):null})]}):null,(()=>{const e=!A&&(be.trim()!==""||Object.values(_).some(o=>Ce(o))),n=U?e?je.length:v:je.length;return n<=0?null:t.jsx(wt.Pagination,{page:V,pageSizeOptions:[5,10,20,50,100],pageSize:K,totalCount:n,currentDataLength:Ie.length,onPageChange:de,onPageSizeChange:o=>{ye(o),de(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=ln;exports.DataTableFilters=Ft;
2
2
  //# sourceMappingURL=DataTable2.cjs.js.map