chordia-ui 3.7.4 → 3.7.6

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.
@@ -1,2 +1,2 @@
1
- "use strict";const n=require("react/jsx-runtime"),a=require("react"),$=require("./sortable.esm.cjs.js"),N=require("lucide-react"),He=require("react-dom"),ut=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./TourGuideTooltip.cjs.js");function ft({dateRangePicker:s,onWeekToDate:l,exportConfig:c,filterChipsConfig:d,trailingActions:y}){const[b,p]=a.useState(!1),h=a.useRef(null),B=a.useRef(null);a.useEffect(()=>{const S=x=>{B.current&&!B.current.contains(x.target)&&h.current&&!h.current.contains(x.target)&&p(!1)};if(b)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[b]);const g=()=>{p(S=>!S)},k=S=>{p(!1),c!=null&&c.onExport&&c.onExport(S)},R=(()=>{if(!(d!=null&&d.filters))return!1;const S=d.filters,x=d.customFilters||[],I=Object.entries(S).some(([j,M])=>!!(Array.isArray(M)&&M.length||typeof M=="string"&&M.trim()!==""||M&&typeof M=="object"&&(M.min!=null||M.max!=null))),W=x.some(j=>j.active);return I||W})();return n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l&&n.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:[n.jsx(N.CalendarClock,{size:16}),n.jsx("span",{children:"Week to Date"})]}),s&&n.jsx(a.Suspense,{fallback:n.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:[n.jsx(N.CalendarClock,{size:16}),n.jsx("span",{children:"Loading..."})]}),children:s}),c&&n.jsxs("div",{className:"relative",children:[n.jsxs("button",{ref:h,onClick:g,disabled:c.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(N.Download,{size:16}),n.jsx("span",{children:c.isExporting?"Exporting...":"Export"})]}),n.jsx(N.ChevronDown,{size:16})]}),b&&n.jsx("div",{ref:B,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:(c.types||["csv"]).map(S=>n.jsxs("button",{onClick:()=>k(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))})]}),(R||y)&&n.jsxs(n.Fragment,{children:[R&&n.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),n.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[R&&d&&n.jsx(ut.CustomFilterChips,{filters:d.filters,onChange:d.onChange,onClear:d.onClear,customFilters:d.customFilters||[],fieldOptions:d.fieldOptions||{}}),y&&n.jsx("div",{className:"flex-shrink-0",children:y})]})]})]})}function Pt(s){if(s==null)return NaN;const l=String(s).replace(/[,$%]|pp/gi,"").trim(),c=parseFloat(l);return Number.isFinite(c)?c:NaN}function _t(s){if(s==null)return NaN;const l=String(s).trim(),c=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(c){const g=+c[1],k=+c[2],D=c[3]!=null?+c[3]:null;return D!=null?g*3600+k*60+D:g*60+k}let d=0,y=!1;const b=l.match(/(\d+)\s*d\b/i),p=l.match(/(\d+)\s*h\b/i),h=l.match(/(\d+)\s*m(?!s)\b/i),B=l.match(/(\d+)\s*s\b/i);return b&&(d+=+b[1]*86400,y=!0),p&&(d+=+p[1]*3600,y=!0),h&&(d+=+h[1]*60,y=!0),B&&(d+=+B[1],y=!0),y?d:NaN}function Ht(s){if(!s)return null;const l=String(s).trim(),c=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(c){const y=c[3].length===2?2e3+ +c[3]:+c[3],b=new Date(y,+c[1]-1,+c[2]);return isNaN(b.getTime())?null:b}const d=new Date(l);return isNaN(d.getTime())?null:d}function qt(s){if(!s||s.length===0)return"text";const l=s.slice(0,25),c=d=>l.every(d);return c(d=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(d)||/^\d{4}-\d{2}-\d{2}/.test(d))?"date":c(d=>/^\d+\s*[dhms]\b/i.test(d)||/^\d+:\d+(:\d+)?$/.test(d))?"duration":c(d=>/^-?[\d,.]+(%|pp)?$/i.test(d))?"number":"text"}function De(s){return s?Array.isArray(s)?s.length>0:s.type==="range"?s.min!==""&&s.min!==void 0&&s.min!==null||s.max!==""&&s.max!==void 0&&s.max!==null:s.type==="durationRange"?s.minSec!==""&&s.minSec!=null||s.maxSec!==""&&s.maxSec!=null:s.type==="dateRange"?!!(s.from||s.to):!1:!1}function dt(s){if(s==null||s===""||isNaN(s))return"";const l=Number(s),c=Math.floor(l/3600),d=Math.floor(l%3600/60),y=Math.floor(l%60);return c>0?`${c}h ${d}m`:d>0?`${d}m ${y}s`:`${y}s`}function Kt(s){if(!s)return"";if(Array.isArray(s))return s.length===0?"":String(s[0]);if(s.type==="range"){const l=s.min!==""&&s.min!=null?s.min:null,c=s.max!==""&&s.max!=null?s.max:null;return l!=null&&c!=null?`${l} – ${c}`:l!=null?`≥ ${l}`:c!=null?`≤ ${c}`:""}if(s.type==="durationRange"){const l=s.minSec!==""&&s.minSec!=null?dt(s.minSec):null,c=s.maxSec!==""&&s.maxSec!=null?dt(s.maxSec):null;return l&&c?`${l} – ${c}`:l?`≥ ${l}`:c?`≤ ${c}`:""}return s.type==="dateRange"?s.from&&s.to?`${s.from} – ${s.to}`:s.from?`from ${s.from}`:s.to?`to ${s.to}`:"":""}function Xt(s){return Array.isArray(s)?Math.max(0,s.length-1):0}function Gt(s){return Array.isArray(s)?s.slice(1).map(String).join(", "):""}function Ut({count:s,values:l}){const[c,d]=a.useState(!1);return n.jsxs("span",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!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:["+",s,c&&n.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 _e({leftLabel:s,rightLabel:l,leftValue:c,rightValue:d,onLeftChange:y,onRightChange:b,type:p="number",placeholderLeft:h="Min",placeholderRight:B="Max"}){const g={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"},k={fontSize:12,color:"#676767",marginBottom:4,fontFamily:"var(--font-sans)"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[n.jsx("span",{style:k,children:s}),n.jsx("input",{type:p,value:c,onChange:D=>y(D.target.value),placeholder:h,style:g})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[n.jsx("span",{style:k,children:l}),n.jsx("input",{type:p,value:d,onChange:D=>b(D.target.value),placeholder:B,style:g})]})]})}function Jt({column:s,columnId:l,filterType:c="text",position:d,popoverRef:y,distinctValues:b,initialValue:p,onApply:h,onCancel:B}){const g=c==="text",k=c==="number",D=c==="date",R=c==="duration",[S,x]=a.useState(()=>g?new Set(Array.isArray(p)?p:[]):new Set),[I,W]=a.useState(""),[j,M]=a.useState(()=>k&&(p==null?void 0:p.type)==="range"&&p.min!=null?p.min:""),[Y,L]=a.useState(()=>k&&(p==null?void 0:p.type)==="range"&&p.max!=null?p.max:""),[P,q]=a.useState(()=>R&&(p==null?void 0:p.type)==="durationRange"&&p.minSec!=null?p.minSec:""),[E,A]=a.useState(()=>R&&(p==null?void 0:p.type)==="durationRange"&&p.maxSec!=null?p.maxSec:""),[ee,K]=a.useState(()=>D&&(p==null?void 0:p.type)==="dateRange"&&p.from||""),[te,Z]=a.useState(()=>D&&(p==null?void 0:p.type)==="dateRange"&&p.to||"");a.useEffect(()=>{g&&x(new Set(Array.isArray(p)?p:[]))},[l,g]);const _=a.useMemo(()=>{const v=I.trim().toLowerCase();return v?b.filter(F=>String(F).toLowerCase().includes(v)):b},[b,I]),G=v=>{x(F=>{const T=new Set(F);return T.has(v)?T.delete(v):T.add(v),T})},U=()=>{g&&x(new Set),k&&(M(""),L("")),R&&(q(""),A("")),D&&(K(""),Z("")),W("")},de=()=>{if(g)return h(Array.from(S));if(k)return h({type:"range",min:j===""?"":Number(j),max:Y===""?"":Number(Y)});if(R)return h({type:"durationRange",minSec:P===""?"":Number(P),maxSec:E===""?"":Number(E)});if(D)return h({type:"dateRange",from:ee,to:te})};return n.jsxs("div",{ref:y,role:"dialog","aria-label":`Filter ${s.label||l}`,style:{position:"fixed",top:d.top,left:d.left,zIndex:50,width:g?240:280,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:[g&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{background:"#D8D8D8",height:32,borderRadius:10,padding:1,display:"flex",alignItems:"center"},children:n.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[n.jsx(N.Search,{size:16,color:"#989898",strokeWidth:2}),n.jsx("input",{autoFocus:!0,type:"text",value:I,onChange:v=>W(v.target.value),placeholder:"Search",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#0B0B0B",minWidth:0,fontFamily:"var(--font-sans)"}})]})}),n.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},children:_.length===0?n.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):_.map(v=>{const F=S.has(v);return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"6px 4px",cursor:"pointer",borderRadius:6},children:[n.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:F?"#0B0B0B":"#FFFFFF",border:`1px solid ${F?"#0B0B0B":"#676767"}`,flexShrink:0},children:F&&n.jsx(N.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("input",{type:"checkbox",checked:F,onChange:()=>G(v),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),n.jsx("span",{onClick:T=>{T.preventDefault(),G(v)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v})]},v)})})]}),k&&n.jsx(_e,{leftLabel:"Min",rightLabel:"Max",leftValue:j,rightValue:Y,onLeftChange:M,onRightChange:L,type:"number"}),R&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:12,color:"#676767"},children:"Duration in seconds"}),n.jsx(_e,{leftLabel:"Min (sec)",rightLabel:"Max (sec)",leftValue:P,rightValue:E,onLeftChange:q,onRightChange:A,type:"number",placeholderLeft:"0",placeholderRight:"3600"})]}),D&&n.jsx(_e,{leftLabel:"From",rightLabel:"To",leftValue:ee,rightValue:te,onLeftChange:K,onRightChange:Z,type:"date",placeholderLeft:"",placeholderRight:""}),n.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("button",{type:"button",onClick:U,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:"Reset"}),n.jsx("button",{type:"button",onClick:de,style:{background:"#0B0B0B",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Apply"})]})]})}const Qt=()=>({userData:{email:"anonymous"}}),Yt=s=>n.jsx("img",{...s});function Zt({children:s,content:l,direction:c="top",align:d="center",styling:y,indicatorColor:b}){const p=typeof l=="string"?l:l!=null?String(l):"",h=typeof b=="string"&&(b.startsWith("#")||b.startsWith("rgb")||b.startsWith("hsl")||b.startsWith("var("))?b:"var(--Grey-Strong, #2E3236)",[B,g]=a.useState(!1),[k,D]=a.useState(!1),[R,S]=a.useState({top:0,left:0,arrowLeft:0,placement:"top"}),x=a.useRef(null),I=a.useRef(null);if(!p)return s;a.useEffect(()=>{D(!0)},[]);const W=a.useCallback(()=>{if(!x.current||!I.current||typeof window>"u")return;const j=x.current.getBoundingClientRect(),M=I.current.getBoundingClientRect(),Y=window.innerWidth,L=window.innerHeight,P=8,q=10,E=M.width,A=M.height,ee=j.top,K=L-j.bottom,te=c==="bottom"?"bottom":"top";let Z=te;te==="top"&&ee<A+q+P&&K>ee?Z="bottom":te==="bottom"&&K<A+q+P&&ee>K&&(Z="top");let _=j.left+j.width/2;d==="start"&&(_=j.left),d==="end"&&(_=j.right);let G=Z==="top"?j.top-A-q:j.bottom+q,U=d==="start"?_:d==="end"?_-E:_-E/2;G=Math.max(P,Math.min(G,L-A-P)),U=Math.max(P,Math.min(U,Y-E-P));const de=Math.max(10,Math.min(_-U,E-10));S({top:G,left:U,arrowLeft:de,placement:Z})},[d,c]);return a.useEffect(()=>{if(!B||!k)return;W();const j=()=>W();return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[B,k,W]),n.jsxs("span",{ref:x,style:{display:"block",width:"100%"},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[s,B&&k&&He.createPortal(n.jsxs("span",{ref:I,style:{position:"fixed",top:`${R.top}px`,left:`${R.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 y=="object"?y:{}},children:[p,n.jsx("span",{style:{position:"absolute",left:`${R.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...R.placement==="top"?{top:"100%",borderTop:`7px solid ${h}`}:{bottom:"100%",borderBottom:`7px solid ${h}`}}})]}),document.body)]})}function Vt({data:s=[],columns:l=[],initialPageSize:c=10,onRowClick:d,totalCount:y=null,page:b=null,pageSize:p=null,onPageChange:h=null,onPageSizeChange:B=null,onFilterChange:g=null,columnFilters:k=null,onMaxColumnsError:D=null,onSort:R=null,sortFields:S=[],tableId:x=null,isLoading:I=!1,filtersConfig:W=null,columnResizeMinWidth:j=100,columnResizeMaxWidth:M=280}){var ct;const{userData:Y}=Qt(),L=(Y==null?void 0:Y.email)||"anonymous",P=a.memo(({children:e,content:t,className:r=""})=>{const i=a.useRef(null),[o,u]=a.useState(!1);a.useEffect(()=>{const m=()=>{if(i.current){const z=i.current.scrollWidth>i.current.clientWidth;u(z)}};m();const H=setTimeout(m,0);return window.addEventListener("resize",m),()=>{clearTimeout(H),window.removeEventListener("resize",m)}},[e,t]);const f=n.jsx("span",{className:`truncate block ${r}`,ref:i,children:e});return o&&t?n.jsx(Zt,{content:t,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:f}):f});P.displayName="TruncatedCell";const q=y!==null&&h!==null,E=g!==null,A=R!==null,[ee,K]=a.useState(1),[te,Z]=a.useState(c),_=b!==null?b:ee,G=p!==null?p:te,U=e=>{h?h(e):K(e)},de=e=>{B?B(e):Z(e)},v=50,F="action",T=a.useRef(!1),ne=a.useMemo(()=>x?`dataTable_columns_${x}:${L}`:`dataTable_columns_${l.map(t=>t.id||t.key).sort().join("_")}:${L}`,[x,l,L]),se=a.useMemo(()=>x?`dataTable_manual_change_${x}:${L}`:null,[x,L]);a.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const r=localStorage.getItem(e);if(r){const o=JSON.parse(r).filter(u=>t.some(f=>(f.id||f.key)===u));if(o.length>0)return o}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}return null},[]);const[J,Re]=a.useState({}),[Me,qe]=a.useState(""),[X,ue]=a.useState(null),[pt,ht]=a.useState({top:0,left:0}),Ee=a.useRef(null),Ke=a.useRef({}),[Xe,mt]=a.useState(null),[Ge,Ue]=a.useState("asc"),ze=a.useCallback((e,t)=>{const r=De(t);Re(i=>{const o={...i};return r?o[e]=t:delete o[e],o}),h?h(1):K(1),E&&g&&g(r?{...J,[e]:t}:Object.fromEntries(Object.entries(J).filter(([i])=>i!==e)))},[J,g,E,h]),gt=a.useCallback(()=>{Re({}),qe(""),h?h(1):K(1),E&&g&&g({})},[g,E,h]),Ne=a.useCallback(e=>{if(!s||s.length===0)return[];const t=new Set,r=[];for(const i of s){const o=i[e];if(o==null)continue;const u=typeof o=="object"?JSON.stringify(o):String(o);t.has(u)||(t.add(u),r.push(u))}return r.sort((i,o)=>i.localeCompare(o))},[s]),xt=a.useCallback(e=>{const t=l.find(r=>O(r)===e);return t&&t.filterType?t.filterType:qt(Ne(e))},[l,Ne]),yt=a.useCallback((e,t)=>{if(!t){ue(e);return}const r=t.getBoundingClientRect();ht({top:r.bottom+6,left:r.left}),ue(i=>i===e?null:e)},[]);a.useEffect(()=>{if(!X)return;const e=t=>{if(Ee.current&&Ee.current.contains(t.target))return;const r=Ke.current[X];r&&r.contains(t.target)||ue(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[X]);const Je=a.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),Qe=a.useCallback((e,t)=>{const r=Object.keys(e||{}),i=Object.keys(t||{});return r.length!==i.length?!1:r.every(o=>e[o]===t[o])},[]);a.useEffect(()=>{if(!E||k===null)return;const e=Je(k);Re(t=>Qe(t,e)?t:e)},[E,k,Je,Qe]),a.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const fe=A&&S.length>0?S[0][0]:Xe,me=A&&S.length>0?S[0][1]:Ge,[en,Ye]=a.useState(()=>l.map(e=>e.id||e.key)),Q=a.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>v&&(t=t.slice(0,v));const i=l.map(f=>f.id||f.key).includes(F);return!t.includes(F)&&i&&(t.length>=v?t=[...t.slice(0,v-1),F]:t=[...t,F]),[...t.filter(f=>f!==F),F]},[l]),[C,re]=a.useState(()=>{if(typeof window<"u"&&x)try{if(localStorage.getItem(`dataTable_manual_change_${x}:${L}`)==="true"){const i=localStorage.getItem(`dataTable_columns_${x}:${L}`);if(i){const o=JSON.parse(i);if(Array.isArray(o)&&o.length>0){T.current=!0;const u=o.filter(f=>l.some(m=>(m.id||m.key)===f));if(u.length>0)return u.slice(0,v)}}}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}const t=l.map(r=>r.id||r.key).slice(0,v);return Q(t)}),[oe,Be]=a.useState(!1),[Ze,bt]=a.useState({top:0,left:0,width:0}),[Ve,Le]=a.useState(new Set),[et,$e]=a.useState(new Set),ge=a.useRef(null);ge.current===null&&(ge.current=[...C]);const[V,We]=a.useState(null),[vt,xe]=a.useState(null),ie=a.useRef(null),Te=a.useRef(null),ae=a.useRef(null),[tt,Ae]=a.useState(null),[Oe,St]=a.useState({}),wt=a.useRef(null),ye=a.useRef(null),O=e=>e.id||e.key,be=a.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const i=parseFloat(t);return Number.isFinite(i)?i:null}const r=parseFloat(t);return Number.isFinite(r)&&`${r}`===t?r:null}return null},[]),nt=a.useCallback((e,t)=>Oe[e]!=null?`${Oe[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[Oe]),ve=a.useCallback(e=>{if(!ye.current)return;const{columnId:t,startX:r,startWidth:i,minWidth:o,maxWidth:u}=ye.current,f=e.clientX-r,m=Math.round(i+f),H=Math.min(u,Math.max(o,m));St(z=>({...z,[t]:H}))},[]),pe=a.useCallback(()=>{ye.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",pe)},[ve]),jt=a.useCallback((e,t,r)=>{var ke;e.preventDefault(),e.stopPropagation();const i=t.id||t.key,o=be(t.minWidth)??j,u=be(t.maxWidth)??M,f=Math.min(o,u),m=Math.max(o,u),H=((ke=e.currentTarget.closest("th"))==null?void 0:ke.getBoundingClientRect().width)||0,z=be(r),he=z??Math.max(f,Math.round(H)||f),Ie=Math.min(m,Math.max(f,he));ye.current={columnId:i,startX:e.clientX,startWidth:Ie,minWidth:f,maxWidth:m},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",ve),document.addEventListener("mouseup",pe)},[M,j,ve,pe,be]);a.useEffect(()=>()=>pe(),[pe]);const Ft=$.useSensors($.useSensor($.PointerSensor),$.useSensor($.KeyboardSensor,{coordinateGetter:$.sortableKeyboardCoordinates})),kt=e=>{const{active:t,over:r}=e;if(r&&t.id!==r.id){if(t.id===F||r.id===F){ot("Cannot drop columns on the Action column"),Ae(null);return}T.current=!0,re(i=>{const o=i.indexOf(t.id),u=i.indexOf(r.id);if(o!==-1&&u!==-1){const f=$.arrayMove(i,o,u),m=Q(f);return Fe(m),m}return i}),Ye(i=>{const o=i.indexOf(t.id),u=i.indexOf(r.id);return $.arrayMove(i,o,u)})}Ae(null)},Ct=e=>{Ae(e.active.id)},Se=a.useMemo(()=>{if(E)return s||[];if(!s||s.length===0)return[];const e=Me.trim().toLowerCase(),t=Object.entries(J).filter(([,r])=>De(r));return s.filter(r=>{for(const[i,o]of t){const u=r[i];if(u==null)return!1;if(Array.isArray(o)){const f=String(u);if(!o.some(m=>String(m)===f))return!1;continue}if(o.type==="range"){const f=Pt(u);if(isNaN(f)||o.min!==""&&o.min!=null&&f<Number(o.min)||o.max!==""&&o.max!=null&&f>Number(o.max))return!1;continue}if(o.type==="durationRange"){const f=_t(u);if(isNaN(f)||o.minSec!==""&&o.minSec!=null&&f<Number(o.minSec)||o.maxSec!==""&&o.maxSec!=null&&f>Number(o.maxSec))return!1;continue}if(o.type==="dateRange"){const f=Ht(u);if(!f)return!1;if(o.from){const m=new Date(o.from+"T00:00:00");if(f<m)return!1}if(o.to){const m=new Date(o.to+"T23:59:59");if(f>m)return!1}continue}}return!(e&&!Object.values(r).some(o=>o==null?!1:String(o).toLowerCase().includes(e)))})},[s,J,Me,E]),we=a.useMemo(()=>A||!fe?Se:[...Se].sort((e,t)=>{const r=e[fe],i=t[fe];if(r==null)return 1;if(i==null)return-1;if(typeof r=="number"&&typeof i=="number")return me==="asc"?r-i:i-r;const o=String(r).toLowerCase(),u=String(i).toLowerCase();return me==="asc"?o.localeCompare(u):u.localeCompare(o)}),[Se,fe,me,A]),je=a.useMemo(()=>{if(q)return s||[];{const e=(_-1)*G,t=e+G;return we.slice(e,t)}},[s,we,_,G,q]),rt=e=>{A&&R?(R(e),h?h(1):K(1)):(Xe===e?Ue(Ge==="asc"?"desc":"asc"):(mt(e),Ue("asc")),U(1))},Dt=(e,t)=>{const r=(t||"").split(/\s+/).map(i=>i.trim()).filter(Boolean);ze(e,r)},ot=e=>{ae.current||(typeof D=="function"&&D(e),ae.current=setTimeout(()=>{ae.current=null},3e3))},Fe=a.useCallback(e=>{if(typeof window<"u"&&ne&&e.length>0&&T.current)try{localStorage.setItem(ne,JSON.stringify(e)),se&&localStorage.setItem(se,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[ne,se]),Rt=e=>{e!==F&&(T.current=!0,re(t=>t.includes(e)?(ae.current&&(clearTimeout(ae.current),ae.current=null),t.length===1||($e(r=>new Set(r).add(e)),setTimeout(()=>{re(r=>{const i=r.filter(u=>u!==e),o=Q(i);return Fe(o),o}),$e(r=>{const i=new Set(r);return i.delete(e),i})},200)),t):t.length>=v?(ot("Maximum 9 column selection allowed"),t):(Le(r=>new Set(r).add(e)),setTimeout(()=>{re(r=>{const i=r.includes(e)?r:[...r,e],o=Q(i);return Fe(o),o}),Le(r=>{const i=new Set(r);return i.delete(e),i})},200),t)))},Mt=(e,t)=>{C[t]!==F&&We(t)},Et=()=>{We(null),xe(null)},zt=(e,t)=>{e.preventDefault(),V!==null&&V!==t&&xe(t)},Nt=()=>{xe(null)},Bt=(e,t)=>{e.preventDefault(),V!==null&&V!==t&&C[t]!==F&&C[V]!==F&&(T.current=!0,re(r=>{const i=$.arrayMove(r,V,t),o=Q(i);return Fe(o),o})),We(null),xe(null)};a.useEffect(()=>{Ye(e=>{const t=C.filter(o=>e.includes(o)),r=C.filter(o=>!e.includes(o)),i=e.filter(o=>!C.includes(o));return[...t,...r,...i]})},[C]),a.useEffect(()=>{if(typeof window<"u"&&ne&&C.length>0&&T.current)try{const e=Q(C);localStorage.setItem(ne,JSON.stringify(e)),se&&localStorage.setItem(se,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[C,ne,se]),a.useEffect(()=>{if(l.length>0&&C.length===0){if(typeof window<"u"&&x)try{if(localStorage.getItem(`dataTable_manual_change_${x}:${L}`)==="true"){const r=localStorage.getItem(`dataTable_columns_${x}:${L}`);if(r){const i=JSON.parse(r);if(Array.isArray(i)&&i.length>0){const o=i.filter(u=>l.some(f=>(f.id||f.key)===u));if(o.length>0){T.current=!0,re(o.slice(0,v));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=l.map(t=>t.id||t.key);re(Q(e.slice(0,v)))}},[l,x,L,Q]);const le=a.useMemo(()=>{const e=C.map(t=>l.find(r=>O(r)===t)).filter(Boolean);return Q(e.map(O)).map(t=>l.find(r=>O(r)===t)).filter(Boolean)},[l,C]);a.useMemo(()=>le.some(e=>e.filterable===!0),[le]),a.useEffect(()=>{if(!oe||!ie.current)return;const e=()=>{if(ie.current){const t=ie.current.getBoundingClientRect();bt({top:t.bottom,left:t.left,width:Math.max(t.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[oe]),a.useEffect(()=>{const e=t=>{oe&&ie.current&&!ie.current.contains(t.target)&&Te.current&&!Te.current.contains(t.target)&&Be(!1)};if(oe)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[oe]),C.length===1?(ct=l.find(e=>(e.id||e.key)===C[0]))!=null&&ct.label:`${C.length}`;function Lt({column:e,isHeaderRow:t=!0}){const r=O(e),i=r===F,o=nt(r,e.width),[u,f]=a.useState(!1),{attributes:m,listeners:H,setNodeRef:z,transform:he,transition:Ie,isDragging:ke}=$.useSortable({id:r}),Wt={transform:$.CSS.Transform.toString(he),transition:Ie,opacity:ke?.5:1,width:o,minWidth:o};let ce=!1;if(A&&S.length>0){const w=S[0][0];(w===r||w==="csat_score"&&r==="evaluation.csat_score")&&(ce=!0)}else ce=fe===r;const Tt=me==="asc",At=e.filterable===!0;if(!t)return n.jsx("th",{style:{width:o,minWidth:o,backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:At?n.jsxs("div",{className:"relative",children:[n.jsx(Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),n.jsx("input",{type:"text",placeholder:"Filter...",value:J[r]||"",onChange:w=>{w.stopPropagation(),Dt(r,w.target.value)},onKeyDown:w=>w.stopPropagation(),onMouseDown:w=>w.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"})]}):n.jsx("div",{className:"h-[34px]"})});const Pe=X===r,Ce=De(J[r]),Ot=e.sortable!==!1&&(u||ce),It=e.filterable!==!1&&!i&&(u||Pe||Ce);return n.jsxs("th",{ref:z,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{...Wt,padding:"0 12px",height:36,textAlign:i?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:o,borderRight:"none",userSelect:"none",background:u||Pe?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!i&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none"}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:i?"center":"flex-start",position:"relative",minHeight:20},children:[!i&&n.jsx("div",{...m,...H,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center"},children:n.jsx(N.GripVertical,{size:14})}),n.jsx("span",{onClick:()=>e.sortable!==!1&&rt(r),style:{cursor:e.sortable!==!1?"pointer":"default",flex:1,lineHeight:"20px"},children:e.label}),Ot&&n.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),rt(r)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:ce?"#0b0b0b":"rgba(11, 11, 11, 0.55)"},children:ce?Tt?n.jsx(N.ArrowUp,{size:14,strokeWidth:1.75}):n.jsx(N.ArrowDown,{size:14,strokeWidth:1.75}):n.jsx(N.ArrowUpDown,{size:14,strokeWidth:1.75})}),It&&n.jsxs("button",{type:"button",ref:w=>{Ke.current[r]=w},onClick:w=>{w.stopPropagation(),yt(r,w.currentTarget)},title:"Filter",style:{position:"relative",background:Pe||Ce?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Ce?"#0b0b0b":"rgba(11, 11, 11, 0.7)"},children:[n.jsx(N.ListFilter,{size:14,strokeWidth:1.75}),Ce&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!i&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none"}}),!i&&n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||r} column`,title:"Drag to resize column",onMouseDown:w=>jt(w,e,o),onClick:w=>w.stopPropagation(),onMouseEnter:w=>{w.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const st=tt?l.find(e=>O(e)===tt):null,it=({col:e,columnId:t,isSelected:r,draggable:i,isAction:o,actualIndex:u})=>{const f=i&&V===u,m=i&&vt===u&&V!==null&&V!==u;r?et.has(t):Ve.has(t);const H=r?!et.has(t):Ve.has(t);return n.jsxs("div",{draggable:i,onDragStart:i?z=>Mt(z,u):void 0,onDragEnd:i?Et:void 0,onDragOver:i?z=>zt(z,u):void 0,onDragLeave:i?Nt:void 0,onDrop:i?z=>Bt(z,u):void 0,onClick:()=>{o||Rt(t)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:o?"default":i?"grab":"pointer",opacity:f?.5:1,background:m?"#F2F2F0":"transparent",borderRadius:6},children:[n.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:i?"visible":"hidden",flexShrink:0},children:n.jsx(N.GripVertical,{size:14,strokeWidth:1.75})}),n.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,marginLeft:8},children:H&&n.jsx(N.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("span",{style:{flex:1,fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",marginLeft:8},children:e.label})]})},$t=oe?n.jsxs("div",{ref:Te,style:{position:"fixed",top:`${Ze.top}px`,left:`${Ze.left}px`,width:217,maxHeight:400,overflow:"auto",zIndex:49,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,padding:12,display:"flex",flexDirection:"column",gap:12,fontFamily:"var(--font-sans)",boxShadow:"0 8px 24px rgba(11, 11, 11, 0.08)"},children:[C.map((e,t)=>{const r=l.find(o=>O(o)===e);if(!r)return null;const i=e===F;return n.jsx(a.Fragment,{children:it({col:r,columnId:e,isSelected:!0,draggable:!i,isAction:i,actualIndex:t})},`selected-${e}-${t}`)}),l.filter(e=>!C.includes(O(e))).map(e=>{const t=O(e);return n.jsx(a.Fragment,{children:it({col:e,columnId:t,isSelected:!1,draggable:!1,isAction:!1,actualIndex:-1})},`unselected-${t}`)}),n.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",height:30},children:[n.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const t=ge.current?[...ge.current]:l.map(O).slice(0,v);if(T.current=!1,re(Q(t)),Le(new Set),$e(new Set),typeof window<"u"&&ne)try{localStorage.removeItem(ne)}catch{}},style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"}),n.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),Be(!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,at=X?l.find(e=>O(e)===X):null,lt=at?n.jsx(Jt,{column:at,columnId:X,filterType:xt(X),position:pt,popoverRef:Ee,distinctValues:Ne(X),initialValue:J[X],onApply:e=>{ze(X,e),ue(null)},onCancel:()=>ue(null)},X):null;return n.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[lt&&He.createPortal(lt,document.body),l.length>0&&n.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,flexWrap:"wrap"},children:[W&&n.jsx("div",{style:{marginRight:"auto"},children:n.jsx(ft,{dateRangePicker:W.dateRangePicker,onWeekToDate:W.onWeekToDate,exportConfig:W.exportConfig,filterChipsConfig:W.filterChipsConfig,trailingActions:W.trailingActions})}),n.jsxs("div",{style:{position:"relative"},children:[n.jsxs("button",{ref:ie,type:"button",onClick:()=>Be(!oe),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:[n.jsx(N.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),oe&&He.createPortal($t,document.body)]}),n.jsx("div",{style:{background:"#D8D8D8",width:260,height:32,borderRadius:11,padding:1,display:"flex",alignItems:"center"},children:n.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[n.jsx(N.Search,{size:18,color:"#989898",strokeWidth:1.75}),n.jsx("input",{type:"text",placeholder:"Search",value:Me,onChange:e=>{qe(e.target.value),h?h(1):K(1)},style:{flex:1,border:"none",outline:"none",background:"transparent",fontFamily:"var(--font-sans)",fontSize:14,color:"#0B0B0B",minWidth:0}})]})})]})}),Object.keys(J).length>0&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(J).map(([e,t])=>{const r=l.find(f=>O(f)===e);if(!r||!De(t))return null;const i=Kt(t),o=Xt(t),u=Gt(t);return n.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:[n.jsxs("span",{children:[n.jsxs("span",{style:{color:"#676767"},children:[r.label,": "]}),n.jsx("span",{children:i})]}),o>0&&n.jsx(Ut,{count:o,values:u}),n.jsx("button",{type:"button",onClick:()=>ze(e,[]),"aria-label":`Remove ${r.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:n.jsx(N.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),n.jsx("button",{type:"button",onClick:gt,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&&le.length>0?n.jsxs($.DndContext,{sensors:Ft,collisionDetection:$.closestCenter,onDragStart:Ct,onDragEnd:kt,children:[n.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[I&&n.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:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[n.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),n.jsx(Yt,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),n.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:wt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:n.jsxs("table",{style:{width:"auto",minWidth:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[n.jsx("thead",{children:n.jsx("tr",{children:n.jsx($.SortableContext,{items:C,strategy:$.horizontalListSortingStrategy,children:le.map(e=>n.jsx(Lt,{column:e,isHeaderRow:!0},`header-${O(e)}`))})})}),n.jsx("tbody",{children:!I&&je.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:le.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!I&&je.length>0?je.map((e,t)=>n.jsx("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid #e6e6e6",cursor:d?"pointer":"default",transition:"background 0.15s ease"},onClick:d?r=>{r.stopPropagation(),d(e,t)}:void 0,onMouseEnter:r=>{r.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:le.map(r=>{const i=O(r),o=nt(i,r.width),u=e[i],f=r.render?r.render(u,e):u,m=o&&o!=="auto",H=typeof f=="string"&&f.trim()!=="",z=m&&H,he=z?n.jsx(P,{content:f,children:f}):f;return n.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid rgba(52, 58, 64, 0.04)",width:o,fontFamily:"var(--font-sans)",...z&&{maxWidth:o||"200px"}},children:he},i)})},t)):null})]})})]}),n.jsx($.DragOverlay,{children:st?n.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(N.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),n.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:st.label})]})}):null})]}):null,(q?y>0:we.length>0)&&n.jsx(ut.Pagination,{page:_,pageSizeOptions:[5,10,20,50,100],pageSize:G,totalCount:q?y:we.length,currentDataLength:je.length,onPageChange:U,onPageSizeChange:e=>{de(e),U(1)},showPageSizeSelector:!0})]})}exports.DataTable2=Vt;exports.DataTableFilters=ft;
1
+ "use strict";const t=require("react/jsx-runtime"),i=require("react"),L=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:u,trailingActions:S}){const[y,c]=i.useState(!1),x=i.useRef(null),R=i.useRef(null);i.useEffect(()=>{const b=F=>{R.current&&!R.current.contains(F.target)&&x.current&&!x.current.contains(F.target)&&c(!1)};if(y)return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[y]);const v=()=>{c(b=>!b)},j=b=>{c(!1),d!=null&&d.onExport&&d.onExport(b)},M=(()=>{if(!(u!=null&&u.filters))return!1;const b=u.filters,F=u.customFilters||[],G=Object.entries(b).some(([C,$])=>!!(Array.isArray($)&&$.length||typeof $=="string"&&$.trim()!==""||$&&typeof $=="object"&&($.min!=null||$.max!=null))),P=F.some(C=>C.active);return G||P})();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:x,onClick:v,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:R,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(b=>t.jsxs("button",{onClick:()=>j(b),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 ",b.toUpperCase()]},b))})]}),(M||S)&&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&&u&&t.jsx(wt.CustomFilterChips,{filters:u.filters,onChange:u.onChange,onClear:u.onClear,customFilters:u.customFilters||[],fieldOptions:u.fieldOptions||{}}),S&&t.jsx("div",{className:"flex-shrink-0",children:S})]})]})]})}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 v=+d[1],j=+d[2],B=d[3]!=null?+d[3]:null;return B!=null?v*3600+j*60+B:v*60+j}let u=0,S=!1;const y=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),x=l.match(/(\d+)\s*m(?!s)\b/i),R=l.match(/(\d+)\s*s\b/i);return y&&(u+=+y[1]*86400,S=!0),c&&(u+=+c[1]*3600,S=!0),x&&(u+=+x[1]*60,S=!0),R&&(u+=+R[1],S=!0),S?u: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 S=d[3].length===2?2e3+ +d[3]:+d[3],y=new Date(S,+d[1]-1,+d[2]);return isNaN(y.getTime())?null:y}const u=new Date(l);return isNaN(u.getTime())?null:u}function Qt(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),d=u=>l.every(u);return d(u=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(u)||/^\d{4}-\d{2}-\d{2}/.test(u))?"date":d(u=>/^\d+\s*[dhms]\b/i.test(u)||/^\d+:\d+(:\d+)?$/.test(u))?"duration":d(u=>/^-?[\d,.]+(%|pp)?$/i.test(u))?"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),u=Math.floor(l%3600/60),S=Math.floor(l%60);return d>0?`${d}h ${u}m`:u>0?`${u}m ${S}s`:`${S}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((u,S)=>u-S).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,u]=i.useState(!1);return t.jsxs("span",{onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!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:u,onLeftChange:S,onRightChange:y,type:c="number",placeholderLeft:x="Min",placeholderRight:R="Max"}){const v={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=>S(B.target.value),placeholder:x,style:v})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:l}),t.jsx("input",{type:c,value:u,onChange:B=>y(B.target.value),placeholder:R,style:v})]})]})}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:u,inputType:S="number",inputMode:y="decimal",step:c,placeholder:x="0.0",unit:R}){const v={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:S,inputMode:y,step:c,placeholder:x,value:r,onChange:j=>d(j.target.value),style:v})]}),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:S,inputMode:y,step:c,placeholder:x,value:l,onChange:j=>u(j.target.value),style:v})]})]}),R&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Input values in ",R==="sec"?"seconds":R]})]})}function rn({column:r,columnId:l,filterType:d="text",position:u,popoverRef:S,distinctValues:y,initialValue:c,onApply:x,onCancel:R}){const v=d==="text",j=d==="number",B=d==="date",M=d==="duration",b=d==="score",F=i.useMemo(()=>{if(!b||!Array.isArray(y)||y.length===0)return!1;let m=1/0,h=-1/0;for(const g of y){const T=et(g);Number.isFinite(T)&&(T<m&&(m=T),T>h&&(h=T))}return Number.isFinite(m)&&Number.isFinite(h)&&m>=0&&h<=5},[b,y]),[G,P]=i.useState(()=>v?new Set(Array.isArray(c)?c:[]):new Set),[C,$]=i.useState(""),[se,oe]=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),[_,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(()=>b&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[q,de]=i.useState(()=>b&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[ye,K]=i.useState(()=>b&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[z,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(()=>{v&&P(new Set(Array.isArray(c)?c:[]))},[l,v]);const O=i.useMemo(()=>{const m=C.trim().toLowerCase();return m?y.filter(h=>String(h).toLowerCase().includes(m)):y},[y,C]),pe=m=>{P(h=>{const g=new Set(h);return g.has(m)?g.delete(m):g.add(m),g})},be=()=>{v&&P(new Set),j&&(oe(""),Z("")),M&&(A(new Set),ce(""),ie("")),b&&(V(new Set),de(""),K("")),B&&(ee(""),ae("")),$("")},De=m=>{A(h=>{const g=new Set(h);return g.has(m)?g.delete(m):g.add(m),g})},N=m=>{V(h=>{const g=new Set(h);return g.has(m)?g.delete(m):g.add(m),g})},fe=()=>{if(v)return x(Array.from(G));if(j)return x({type:"range",min:se===""?"":Number(se),max:D===""?"":Number(D)});if(M){const m=vt(_),h=vt(J),g=m!=null||h!=null;let T="",ue="";if(g)T=m??"",ue=h??"";else if(U.size>0){const Se=St.filter(te=>U.has(te.id));T=Math.min(...Se.map(te=>te.minSec)),ue=Se.some(te=>te.maxSec==null)?"":Math.max(...Se.map(te=>te.maxSec))}return x({type:"durationRange",minSec:T,maxSec:ue})}if(b){const m=q===""?null:Number(q),h=ye===""?null:Number(ye);return m!=null||h!=null?x({type:"scoreRange",values:[],min:m!=null&&Number.isFinite(m)?m:"",max:h!=null&&Number.isFinite(h)?h:""}):x({type:"scoreRange",values:Array.from(Y).sort((T,ue)=>T-ue),min:"",max:""})}if(B)return x({type:"dateRange",from:z,to:Q})};return t.jsxs("div",{ref:S,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:u.top,left:u.left,zIndex:50,width:v?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:[v&&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:O.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):O.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:g=>{g.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:se,maxValue:D,onMinChange:oe,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:g=>{(g.key===" "||g.key==="Enter")&&(g.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:_,maxValue:J,onMinChange:ce,onMaxChange:ie,inputType:"number",inputMode:"numeric",placeholder:"0",unit:"sec"})]}),b&&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:()=>N(m),onKeyDown:g=>{(g.key===" "||g.key==="Enter")&&(g.preventDefault(),N(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:q,maxValue:ye,onMinChange:de,onMaxChange:K,step:"0.1"})]}),B&&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||b&&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 sn=()=>({userData:{email:"anonymous"}}),on=r=>t.jsx("img",{...r});function an({children:r,content:l,direction:d="top",align:u="center",styling:S,indicatorColor:y}){const c=typeof l=="string"?l:l!=null?String(l):"",x=typeof y=="string"&&(y.startsWith("#")||y.startsWith("rgb")||y.startsWith("hsl")||y.startsWith("var("))?y:"var(--Grey-Strong, #2E3236)",[R,v]=i.useState(!1),[j,B]=i.useState(!1),[M,b]=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 P=i.useCallback(()=>{if(!F.current||!G.current||typeof window>"u")return;const C=F.current.getBoundingClientRect(),$=G.current.getBoundingClientRect(),se=window.innerWidth,oe=window.innerHeight,D=8,Z=10,U=$.width,A=$.height,_=C.top,ce=oe-C.bottom,J=d==="bottom"?"bottom":"top";let ie=J;J==="top"&&_<A+Z+D&&ce>_?ie="bottom":J==="bottom"&&ce<A+Z+D&&_>ce&&(ie="top");let Y=C.left+C.width/2;u==="start"&&(Y=C.left),u==="end"&&(Y=C.right);let V=ie==="top"?C.top-A-Z:C.bottom+Z,q=u==="start"?Y:u==="end"?Y-U:Y-U/2;V=Math.max(D,Math.min(V,oe-A-D)),q=Math.max(D,Math.min(q,se-U-D));const de=Math.max(10,Math.min(Y-q,U-10));b({top:V,left:q,arrowLeft:de,placement:ie})},[u,d]);return i.useEffect(()=>{if(!R||!j)return;P();const C=()=>P();return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[R,j,P]),t.jsxs("span",{ref:F,style:{display:"block",width:"100%"},onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[r,R&&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 S=="object"?S:{}},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 ${x}`}:{bottom:"100%",borderBottom:`7px solid ${x}`}}})]}),document.body)]})}function ln({data:r=[],columns:l=[],initialPageSize:d=10,onRowClick:u,totalCount:S=null,page:y=null,pageSize:c=null,onPageChange:x=null,onPageSizeChange:R=null,onFilterChange:v=null,columnFilters:j=null,onMaxColumnsError:B=null,onSort:M=null,sortFields:b=[],tableId:F=null,isLoading:G=!1,filtersConfig:P=null,columnResizeMinWidth:C=100,columnResizeMaxWidth:$=280,onVisibleColumnsChange:se=null}){var yt;const{userData:oe}=sn(),D=(oe==null?void 0:oe.email)||"anonymous",Z=i.memo(({children:e,content:n,className:s=""})=>{const a=i.useRef(null),[o,p]=i.useState(!1);i.useEffect(()=>{const w=()=>{if(a.current){const I=a.current.scrollWidth>a.current.clientWidth;p(I)}};w();const X=setTimeout(w,0);return window.addEventListener("resize",w),()=>{clearTimeout(X),window.removeEventListener("resize",w)}},[e,n]);const f=t.jsx("span",{className:`truncate block ${s}`,ref:a,children:e});return o&&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:f}):f});Z.displayName="TruncatedCell";const U=S!==null&&x!==null,A=v!==null,_=M!==null,[ce,J]=i.useState(1),[ie,Y]=i.useState(d),V=y!==null?y:ce,q=c!==null?c:ie,de=e=>{x?x(e):J(e)},ye=e=>{R?R(e):Y(e)},K=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 s=localStorage.getItem(e);if(s){const o=JSON.parse(s).filter(p=>n.some(f=>(f.id||f.key)===p));if(o.length>0)return o}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}return null},[]);const[O,pe]=i.useState({}),[be,De]=i.useState(""),[N,fe]=i.useState(null),[m,h]=i.useState({top:0,left:0}),g=i.useRef(null),T=i.useRef({}),[ue,Se]=i.useState(null),[Te,te]=i.useState("asc"),Oe=i.useCallback((e,n)=>{const s=Ce(n);pe(a=>{const o={...a};return s?o[e]=n:delete o[e],o}),x?x(1):J(1),A&&v&&v(s?{...O,[e]:n}:Object.fromEntries(Object.entries(O).filter(([a])=>a!==e)))},[O,v,A,x]),jt=i.useCallback(()=>{pe({}),De(""),x?x(1):J(1),A&&v&&v({})},[v,A,x]),He=i.useCallback(e=>{if(!r||r.length===0)return[];const n=new Set,s=[];for(const a of r){const o=a[e];if(o==null)continue;const p=typeof o=="object"?JSON.stringify(o):String(o);n.has(p)||(n.add(p),s.push(p))}return s.sort((a,o)=>a.localeCompare(o))},[r]),kt=i.useCallback(e=>{const n=l.find(s=>H(s)===e);return n&&n.filterType?n.filterType:Qt(He(e))},[l,He]),Re=i.useCallback(e=>{const a=typeof window<"u"?window.innerWidth:1/0;let o=e.left;return o+240>a-8&&(o=Math.max(8,e.right-240)),{top:e.bottom+6,left:o}},[]),Ct=i.useCallback((e,n)=>{if(!n){fe(e);return}const s=n.getBoundingClientRect();h(Re(s)),fe(a=>a===e?null:e)},[Re]);i.useEffect(()=>{if(!N)return;const e=n=>{if(g.current&&g.current.contains(n.target))return;const s=T.current[N];s&&s.contains(n.target)||fe(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]),i.useEffect(()=>{if(!N)return;const e=()=>{const n=T.current[N];if(!n)return;const s=n.getBoundingClientRect();h(Re(s))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[N,Re]);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 s=Object.keys(e||{}),a=Object.keys(n||{});return s.length!==a.length?!1:s.every(o=>e[o]===n[o])},[]);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=_&&b.length>0?b[0][0]:ue,Me=_&&b.length>0?b[0][1]:Te,[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>K&&(n=n.slice(0,K));const a=l.map(f=>f.id||f.key).includes(z);return!n.includes(z)&&a&&(n.length>=K?n=[...n.slice(0,K-1),z]:n=[...n,z]),[...n.filter(f=>f!==z),z]},[l]),[E,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 o=JSON.parse(a);if(Array.isArray(o)&&o.length>0){ee.current=!0;const p=o.filter(f=>l.some(w=>(w.id||w.key)===f));if(p.length>0)return p.slice(0,K)}}}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}const n=l.map(s=>s.id||s.key).slice(0,K);return ne(n)}),[re,_e]=i.useState(!1),[me,Ee]=i.useState([]),[st,Dt]=i.useState({top:0,left:0,width:0}),[ot,it]=i.useState(new Set),[at,lt]=i.useState(new Set),Be=i.useRef(null);Be.current===null&&(Be.current=[...E]);const[le,qe]=i.useState(null),[Rt,ze]=i.useState(null),he=i.useRef(null),Ke=i.useRef(null),Xe=i.useRef(null),[ct,Ge]=i.useState(null),[Ue,Mt]=i.useState({}),Et=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 s=parseFloat(n);return Number.isFinite(s)&&`${s}`===n?s: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:s,startWidth:a,minWidth:o,maxWidth:p}=Ne.current,f=e.clientX-s,w=Math.round(a+f),X=Math.min(p,Math.max(o,w));Mt(I=>({...I,[n]:X}))},[]),Fe=i.useCallback(()=>{Ne.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Fe)},[$e]),Bt=i.useCallback((e,n,s)=>{var Pe;e.preventDefault(),e.stopPropagation();const a=n.id||n.key,o=We(n.minWidth)??C,p=We(n.maxWidth)??$,f=Math.min(o,p),w=Math.max(o,p),X=((Pe=e.currentTarget.closest("th"))==null?void 0:Pe.getBoundingClientRect().width)||0,I=We(s),ke=I??Math.max(f,Math.round(X)||f),Je=Math.min(w,Math.max(f,ke));Ne.current={columnId:a,startX:e.clientX,startWidth:Je,minWidth:f,maxWidth:w},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 zt=L.useSensors(L.useSensor(L.PointerSensor),L.useSensor(L.KeyboardSensor,{coordinateGetter:L.sortableKeyboardCoordinates})),Nt=e=>{const{active:n,over:s}=e;if(s&&n.id!==s.id){if(n.id===z||s.id===z){ft("Cannot drop columns on the Action column"),Ge(null);return}ee.current=!0,we(a=>{const o=a.indexOf(n.id),p=a.indexOf(s.id);if(o!==-1&&p!==-1){const f=L.arrayMove(a,o,p),w=ne(f);return pt(w),w}return a}),rt(a=>{const o=a.indexOf(n.id),p=a.indexOf(s.id);return L.arrayMove(a,o,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(O).filter(([,s])=>Ce(s));return r.filter(s=>{for(const[a,o]of n){const p=s[a];if(p==null)return!1;if(Array.isArray(o)){const f=String(p);if(!o.some(w=>String(w)===f))return!1;continue}if(o.type==="range"){const f=et(p);if(isNaN(f)||o.min!==""&&o.min!=null&&f<Number(o.min)||o.max!==""&&o.max!=null&&f>Number(o.max))return!1;continue}if(o.type==="durationRange"){const f=Jt(p);if(isNaN(f)||o.minSec!==""&&o.minSec!=null&&f<Number(o.minSec)||o.maxSec!==""&&o.maxSec!=null&&f>Number(o.maxSec))return!1;continue}if(o.type==="scoreRange"){const f=et(p);if(isNaN(f))return!1;if(Array.isArray(o.values)&&o.values.length>0){const w=Math.floor(f);if(!o.values.includes(w))return!1;continue}if(o.min!==""&&o.min!=null&&f<Number(o.min)||o.max!==""&&o.max!=null&&f>Number(o.max))return!1;continue}if(o.type==="dateRange"){const f=Yt(p);if(!f)return!1;if(o.from){const w=new Date(o.from+"T00:00:00");if(f<w)return!1}if(o.to){const w=new Date(o.to+"T23:59:59");if(f>w)return!1}continue}}return!(e&&!Object.values(s).some(o=>o==null?!1:String(o).toLowerCase().includes(e)))})},[r,O,be,A]),je=i.useMemo(()=>_||!ve?Ae:[...Ae].sort((e,n)=>{const s=e[ve],a=n[ve];if(s==null)return 1;if(a==null)return-1;if(typeof s=="number"&&typeof a=="number")return Me==="asc"?s-a:a-s;const o=String(s).toLowerCase(),p=String(a).toLowerCase();return Me==="asc"?o.localeCompare(p):p.localeCompare(o)}),[Ae,ve,Me,_]),Ie=i.useMemo(()=>{if(U)return je;{const e=(V-1)*q,n=e+q;return je.slice(e,n)}},[je,V,q,U]),ut=e=>{_&&M?(M(e),x?x(1):J(1)):(ue===e?te(Te==="asc"?"desc":"asc"):(Se(e),te("asc")),de(1))},$t=(e,n)=>{const s=(n||"").split(/\s+/).map(a=>a.trim()).filter(Boolean);Oe(e,s)},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!==z&&Ee(n=>n.includes(e)?n.length===1?n:n.filter(s=>s!==e):n.length>=K?(ft("Maximum 9 column selection allowed"),n):ne([...n,e]))},It=(e,n)=>{me[n]!==z&&qe(n)},Pt=()=>{qe(null),ze(null)},Lt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&ze(n)},Tt=()=>{ze(null)},Ot=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&me[n]!==z&&me[le]!==z&&Ee(s=>{const a=L.arrayMove(s,le,n);return ne(a)}),qe(null),ze(null)};i.useEffect(()=>{rt(e=>{const n=E.filter(o=>e.includes(o)),s=E.filter(o=>!e.includes(o)),a=e.filter(o=>!E.includes(o));return[...n,...s,...a]})},[E]),i.useEffect(()=>{if(typeof window<"u"&&Q&&E.length>0&&ee.current)try{const e=ne(E);localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[E,Q,ae]),i.useEffect(()=>{se&&se(E.filter(e=>e!==z))},[E,se]),i.useEffect(()=>{if(l.length>0&&E.length===0){if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(s){const a=JSON.parse(s);if(Array.isArray(a)&&a.length>0){const o=a.filter(p=>l.some(f=>(f.id||f.key)===p));if(o.length>0){ee.current=!0,we(o.slice(0,K));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,K)))}},[l,F,D,ne]);const xe=i.useMemo(()=>{const e=E.map(n=>l.find(s=>H(s)===n)).filter(Boolean);return ne(e.map(H)).map(n=>l.find(s=>H(s)===n)).filter(Boolean)},[l,E]);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(),s=217,a=Math.max(8,n.right-s);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)&&_e(!1)};if(re)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[re]),i.useEffect(()=>{re&&(Ee(E),it(new Set),lt(new Set))},[re,E]),E.length===1?(yt=l.find(e=>(e.id||e.key)===E[0]))!=null&&yt.label:`${E.length}`;function Ht({column:e,isHeaderRow:n=!0}){const s=H(e),a=s===z,o=dt(s,e.width),[p,f]=i.useState(!1),{attributes:w,listeners:X,setNodeRef:I,transform:ke,transition:Je,isDragging:Pe}=L.useSortable({id:s}),qt={transform:L.CSS.Transform.toString(ke),transition:Je,opacity:Pe?.5:1,width:o,minWidth:o};let ge=!1;if(_&&b.length>0){const k=b[0][0];(k===s||k==="csat_score"&&s==="evaluation.csat_score")&&(ge=!0)}else ge=ve===s;const Kt=Me==="asc",Xt=e.filterable===!0;if(!n)return t.jsx("th",{style:{width:o,minWidth:o,backgroundColor:"var(--primary-foreground)"},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[s]||"",onChange:k=>{k.stopPropagation(),$t(s,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=N===s,Le=Ce(O[s]),Gt=e.sortable!==!1&&(p||ge),Ut=e.filterable!==!1&&!a&&(p||Ye||Le);return t.jsxs("th",{ref:I,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!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:o,borderRight:"none",userSelect:"none",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"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:a?"center":"flex-start",position:"relative",minHeight:20},children:[!a&&t.jsx("div",{...w,...X,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:p?"visible":"hidden"},children:t.jsx(W.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&ut(s),style:{cursor:e.sortable!==!1?"pointer":"default",flex:1,lineHeight:"20px"},children:e.label}),Gt&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),ut(s)},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)"},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=>{T.current[s]=k},onClick:k=>{k.stopPropagation(),Ct(s,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)"},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"}}),!a&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||s} column`,title:"Drag to resize column",onMouseDown:k=>Bt(k,e,o),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:s,draggable:a,isAction:o,actualIndex:p})=>{const f=a&&le===p,w=a&&Rt===p&&le!==null&&le!==p;s?at.has(n):ot.has(n);const X=s?!at.has(n):ot.has(n);return t.jsxs("div",{draggable:a,onDragStart:a?I=>It(I,p):void 0,onDragEnd:a?Pt:void 0,onDragOver:a?I=>Lt(I,p):void 0,onDragLeave:a?Tt:void 0,onDrop:a?I=>Ot(I,p):void 0,onClick:()=>{o||At(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:o?"default":a?"grab":"pointer",opacity:f?.5:1,background:w?"#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:X?"#0B0B0B":"#FFFFFF",border:`1px solid ${X?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:X&&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})]})},_t=re?t.jsxs("div",{ref:Ke,style:{position:"fixed",top:`${st.top}px`,left:`${st.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 s=l.find(o=>H(o)===e);if(!s)return null;const a=e===z;return t.jsx(i.Fragment,{children:ht({col:s,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=Be.current?[...Be.current]:l.map(H).slice(0,K),s=ne(n);if(ee.current=!1,Ee(s),we(s),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),_e(!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=N?l.find(e=>H(e)===N):null,gt=xt?t.jsx(rn,{column:xt,columnId:N,filterType:kt(N),position:m,popoverRef:g,distinctValues:He(N),initialValue:O[N],onApply:e=>{Oe(N,e),fe(null)},onCancel:()=>fe(null)},N):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:[P&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(Ft,{dateRangePicker:P.dateRangePicker,onWeekToDate:P.onWeekToDate,exportConfig:P.exportConfig,filterChipsConfig:P.filterChipsConfig,trailingActions:P.trailingActions})}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:he,type:"button",onClick:()=>_e(!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(_t,document.body)]})]})}),Object.keys(O).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(O).map(([e,n])=>{const s=l.find(f=>H(f)===e);if(!s||!Ce(n))return null;const a=Zt(n),o=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:[s.label,": "]}),t.jsx("span",{children:a})]}),o>0&&t.jsx(tn,{count:o,values:p}),t.jsx("button",{type:"button",onClick:()=>Oe(e,[]),"aria-label":`Remove ${s.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(L.DndContext,{sensors:zt,collisionDetection:L.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(on,{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:Et,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"auto",minWidth:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[t.jsx("thead",{children:t.jsx("tr",{children:t.jsx(L.SortableContext,{items:E,strategy:L.horizontalListSortingStrategy,children:xe.map(e=>t.jsx(Ht,{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:u?"pointer":"default",transition:"background 0.15s ease"},onClick:u?s=>{s.stopPropagation(),u(e,n)}:void 0,onMouseEnter:s=>{s.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:xe.map(s=>{const a=H(s),o=dt(a,s.width),p=e[a],f=s.render?s.render(p,e):p,w=o&&o!=="auto",X=typeof f=="string"&&f.trim()!=="",I=w&&X,ke=I?t.jsx(Z,{content:f,children:f}):f;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid rgba(52, 58, 64, 0.04)",width:o,fontFamily:"var(--font-sans)",...I&&{maxWidth:o||"200px"}},children:ke},a)})},n)):null})]})})]}),t.jsx(L.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(O).some(s=>Ce(s))),n=U?e?je.length:S:je.length;return n<=0?null:t.jsx(wt.Pagination,{page:V,pageSizeOptions:[5,10,20,50,100],pageSize:q,totalCount:n,currentDataLength:Ie.length,onPageChange:de,onPageSizeChange:s=>{ye(s),de(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=ln;exports.DataTableFilters=Ft;
2
2
  //# sourceMappingURL=DataTable2.cjs.js.map