chordia-ui 3.7.2 → 3.7.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 (36) hide show
  1. package/dist/CustomFilterChips.cjs.js +1 -1
  2. package/dist/CustomFilterChips.cjs.js.map +1 -1
  3. package/dist/CustomFilterChips.es.js +239 -125
  4. package/dist/CustomFilterChips.es.js.map +1 -1
  5. package/dist/DataTable2.cjs.js +2 -0
  6. package/dist/DataTable2.cjs.js.map +1 -0
  7. package/dist/DataTable2.es.js +1863 -0
  8. package/dist/DataTable2.es.js.map +1 -0
  9. package/dist/components/UpdatedInteractionDetails.cjs.js +2 -2
  10. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  11. package/dist/components/UpdatedInteractionDetails.es.js +14 -13
  12. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  13. package/dist/components/data.cjs.js +1 -1
  14. package/dist/components/data.cjs.js.map +1 -1
  15. package/dist/components/data.es.js +157 -153
  16. package/dist/components/data.es.js.map +1 -1
  17. package/dist/components/performance.cjs.js +1 -1
  18. package/dist/components/performance.cjs.js.map +1 -1
  19. package/dist/components/performance.es.js +1900 -480
  20. package/dist/components/performance.es.js.map +1 -1
  21. package/dist/index.cjs.js +1 -1
  22. package/dist/index.es.js +94 -89
  23. package/dist/index.es.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +13 -13
  26. package/src/components/UpdatedInteractionDetails/UpdatedThreads.jsx +1 -0
  27. package/src/components/common/CustomFilterChips.jsx +5 -1
  28. package/src/components/common/Pagination.jsx +152 -39
  29. package/src/components/data/DataTable2.jsx +2449 -0
  30. package/src/components/data/DataTableFilters2.jsx +186 -0
  31. package/src/components/data/index.js +2 -0
  32. package/src/components/index.js +2 -2
  33. package/src/components/performance/PerformanceDetailsPage.jsx +940 -0
  34. package/src/components/performance/PerformancePanel.jsx +423 -297
  35. package/src/components/performance/SupervisorSelect.jsx +386 -0
  36. package/src/components/performance/index.js +3 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),b=require("../sortable.esm.cjs.js"),L=require("lucide-react"),Ue=require("react-dom"),Xe=require("../CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("../TourGuideTooltip.cjs.js");function Ge({dateRangePicker:g,onWeekToDate:c,exportConfig:y,filterChipsConfig:u,trailingActions:D}){const[S,W]=i.useState(!1),v=i.useRef(null),E=i.useRef(null);i.useEffect(()=>{const x=f=>{E.current&&!E.current.contains(f.target)&&v.current&&!v.current.contains(f.target)&&W(!1)};if(S)return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[S]);const K=()=>{W(x=>!x)},$=x=>{W(!1),y!=null&&y.onExport&&y.onExport(x)},M=(()=>{if(!(u!=null&&u.filters))return!1;const x=u.filters,f=u.customFilters||[],P=Object.entries(x).some(([m,w])=>!!(Array.isArray(w)&&w.length||typeof w=="string"&&w.trim()!==""||w&&typeof w=="object"&&(w.min!=null||w.max!=null))),N=f.some(m=>m.active);return P||N})();return r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&r.jsxs("button",{onClick:c,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:[r.jsx(L.CalendarClock,{size:16}),r.jsx("span",{children:"Week to Date"})]}),g&&r.jsx(i.Suspense,{fallback:r.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:[r.jsx(L.CalendarClock,{size:16}),r.jsx("span",{children:"Loading..."})]}),children:g}),y&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{ref:v,onClick:K,disabled:y.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(L.Download,{size:16}),r.jsx("span",{children:y.isExporting?"Exporting...":"Export"})]}),r.jsx(L.ChevronDown,{size:16})]}),S&&r.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:(y.types||["csv"]).map(x=>r.jsxs("button",{onClick:()=>$(x),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 ",x.toUpperCase()]},x))})]}),(M||D)&&r.jsxs(r.Fragment,{children:[M&&r.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),r.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[M&&u&&r.jsx(Xe.CustomFilterChips,{filters:u.filters,onChange:u.onChange,onClear:u.onClear,customFilters:u.customFilters||[],fieldOptions:u.fieldOptions||{}}),D&&r.jsx("div",{className:"flex-shrink-0",children:D})]})]})]})}function Ee(){return r.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}function bt({size:g=10,color:c="currentColor"}){return r.jsxs("svg",{width:g,height:g,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},"aria-hidden":"true",children:[r.jsx("path",{d:"M3.5 8H12.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round"}),r.jsx("path",{d:"M5 6.5L3.5 8L5 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M11 6.5L12.5 8L11 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6.8 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"}),r.jsx("path",{d:"M9.2 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"})]})}const yt=()=>({userData:{email:"anonymous"}}),vt=g=>r.jsx("img",{...g});function wt({children:g,content:c,direction:y="top",align:u="center",styling:D,indicatorColor:S}){const W=typeof c=="string"?c:c!=null?String(c):"",v=typeof S=="string"&&(S.startsWith("#")||S.startsWith("rgb")||S.startsWith("hsl")||S.startsWith("var("))?S:"var(--Grey-Strong, #2E3236)",[E,K]=i.useState(!1),[$,oe]=i.useState(!1),[M,x]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),f=i.useRef(null),P=i.useRef(null);if(!W)return g;i.useEffect(()=>{oe(!0)},[]);const N=i.useCallback(()=>{if(!f.current||!P.current||typeof window>"u")return;const m=f.current.getBoundingClientRect(),w=P.current.getBoundingClientRect(),ie=window.innerWidth,k=window.innerHeight,I=8,A=10,R=w.width,F=w.height,ae=m.top,X=k-m.bottom,le=y==="bottom"?"bottom":"top";let ee=le;le==="top"&&ae<F+A+I&&X>ae?ee="bottom":le==="bottom"&&X<F+A+I&&ae>X&&(ee="top");let O=m.left+m.width/2;u==="start"&&(O=m.left),u==="end"&&(O=m.right);let U=ee==="top"?m.top-F-A:m.bottom+A,_=u==="start"?O:u==="end"?O-R:O-R/2;U=Math.max(I,Math.min(U,k-F-I)),_=Math.max(I,Math.min(_,ie-R-I));const pe=Math.max(10,Math.min(O-_,R-10));x({top:U,left:_,arrowLeft:pe,placement:ee})},[u,y]);return i.useEffect(()=>{if(!E||!$)return;N();const m=()=>N();return window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[E,$,N]),r.jsxs("span",{ref:f,style:{display:"block",width:"100%"},onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),children:[g,E&&$&&Ue.createPortal(r.jsxs("span",{ref:P,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 D=="object"?D:{}},children:[W,r.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 ${v}`}:{bottom:"100%",borderBottom:`7px solid ${v}`}}})]}),document.body)]})}function jt({data:g=[],columns:c=[],initialPageSize:y=10,onRowClick:u,totalCount:D=null,page:S=null,pageSize:W=null,onPageChange:v=null,onPageSizeChange:E=null,onFilterChange:K=null,columnFilters:$=null,onMaxColumnsError:oe=null,onSort:M=null,sortFields:x=[],tableId:f=null,isLoading:P=!1,filtersConfig:N=null,columnResizeMinWidth:m=100,columnResizeMaxWidth:w=280}){var Ke;const{userData:ie}=yt(),k=(ie==null?void 0:ie.email)||"anonymous",I=i.memo(({children:e,content:t,className:n=""})=>{const s=i.useRef(null),[o,l]=i.useState(!1);i.useEffect(()=>{const d=()=>{if(s.current){const z=s.current.scrollWidth>s.current.clientWidth;l(z)}};d();const q=setTimeout(d,0);return window.addEventListener("resize",d),()=>{clearTimeout(q),window.removeEventListener("resize",d)}},[e,t]);const a=r.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return o&&t?r.jsx(wt,{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:a}):a});I.displayName="TruncatedCell";const A=D!==null&&v!==null,R=K!==null,F=M!==null,[ae,X]=i.useState(1),[le,ee]=i.useState(y),O=S!==null?S:ae,U=W!==null?W:le,_=e=>{v?v(e):X(e)},pe=e=>{E?E(e):ee(e)},B=9,j="action",G=i.useRef(!1),te=i.useMemo(()=>f?`dataTable_columns_${f}:${k}`:`dataTable_columns_${c.map(t=>t.id||t.key).sort().join("_")}:${k}`,[f,c,k]),re=i.useMemo(()=>f?`dataTable_manual_change_${f}:${k}`:null,[f,k]);i.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const n=localStorage.getItem(e);if(n){const o=JSON.parse(n).filter(l=>t.some(a=>(a.id||a.key)===l));if(o.length>0)return o}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[J,Fe]=i.useState({}),[ze,Je]=i.useState(null),[Re,Oe]=i.useState("asc"),Te=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),We=i.useCallback((e,t)=>{const n=Object.keys(e||{}),s=Object.keys(t||{});return n.length!==s.length?!1:n.every(o=>e[o]===t[o])},[]);i.useEffect(()=>{if(!R||$===null)return;const e=Te($);Fe(t=>We(t,e)?t:e)},[R,$,Te,We]),i.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const ce=F&&x.length>0?x[0][0]:ze,fe=F&&x.length>0?x[0][1]:Re,[kt,$e]=i.useState(()=>c.map(e=>e.id||e.key)),V=i.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>B&&(t=t.slice(0,B));const s=c.map(a=>a.id||a.key).includes(j);return!t.includes(j)&&s&&(t.length>=B?t=[...t.slice(0,B-1),j]:t=[...t,j]),[...t.filter(a=>a!==j),j]},[c]),[p,Y]=i.useState(()=>{if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){G.current=!0;const l=o.filter(a=>c.some(d=>(d.id||d.key)===a));if(l.length>0)return l.slice(0,B)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const t=c.map(n=>n.id||n.key).slice(0,B);return V(t)}),[T,Pe]=i.useState(!1),[je,Ye]=i.useState({top:0,left:0,width:0}),[Qe,Ie]=i.useState(new Set),[Ae,_e]=i.useState(new Set),[H,Se]=i.useState(null),[Ze,xe]=i.useState(null),ne=i.useRef(null),ke=i.useRef(null),se=i.useRef(null),[Be,Ce]=i.useState(null),[De,et]=i.useState({}),tt=i.useRef(null),ge=i.useRef(null),C=e=>e.id||e.key,me=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const s=parseFloat(t);return Number.isFinite(s)?s:null}const n=parseFloat(t);return Number.isFinite(n)&&`${n}`===t?n:null}return null},[]),Me=i.useCallback((e,t)=>De[e]!=null?`${De[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[De]),he=i.useCallback(e=>{if(!ge.current)return;const{columnId:t,startX:n,startWidth:s,minWidth:o,maxWidth:l}=ge.current,a=e.clientX-n,d=Math.round(s+a),q=Math.min(l,Math.max(o,d));et(z=>({...z,[t]:q}))},[]),de=i.useCallback(()=>{ge.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",de)},[he]),rt=i.useCallback((e,t,n)=>{var Z;e.preventDefault(),e.stopPropagation();const s=t.id||t.key,o=me(t.minWidth)??m,l=me(t.maxWidth)??w,a=Math.min(o,l),d=Math.max(o,l),q=((Z=e.currentTarget.closest("th"))==null?void 0:Z.getBoundingClientRect().width)||0,z=me(n),ue=z??Math.max(a,Math.round(q)||a),Le=Math.min(d,Math.max(a,ue));ge.current={columnId:s,startX:e.clientX,startWidth:Le,minWidth:a,maxWidth:d},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",he),document.addEventListener("mouseup",de)},[w,m,he,de,me]);i.useEffect(()=>()=>de(),[de]);const nt=b.useSensors(b.useSensor(b.PointerSensor),b.useSensor(b.KeyboardSensor,{coordinateGetter:b.sortableKeyboardCoordinates})),st=e=>{const{active:t,over:n}=e;if(n&&t.id!==n.id){if(t.id===j||n.id===j){He("Cannot drop columns on the Action column"),Ce(null);return}G.current=!0,Y(s=>{const o=s.indexOf(t.id),l=s.indexOf(n.id);if(o!==-1&&l!==-1){const a=b.arrayMove(s,o,l),d=V(a);return we(d),d}return s}),$e(s=>{const o=s.indexOf(t.id),l=s.indexOf(n.id);return b.arrayMove(s,o,l)})}Ce(null)},ot=e=>{Ce(e.active.id)},be=i.useMemo(()=>R?g||[]:!g||g.length===0?[]:g.filter(e=>Object.keys(J).every(t=>{const n=J[t];if(!n||n.trim()==="")return!0;const s=e[t];if(s==null)return!1;const o=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(d=>d.length>0).every(d=>o.includes(d))})),[g,J,R]),ye=i.useMemo(()=>F||!ce?be:[...be].sort((e,t)=>{const n=e[ce],s=t[ce];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return fe==="asc"?n-s:s-n;const o=String(n).toLowerCase(),l=String(s).toLowerCase();return fe==="asc"?o.localeCompare(l):l.localeCompare(o)}),[be,ce,fe,F]),ve=i.useMemo(()=>{if(A)return g||[];{const e=(O-1)*U,t=e+U;return ye.slice(e,t)}},[g,ye,O,U,A]),it=e=>{F&&M?(M(e),v?v(1):X(1)):(ze===e?Oe(Re==="asc"?"desc":"asc"):(Je(e),Oe("asc")),_(1))},Ve=(e,t)=>{const n=t&&t.trim()!==""?{...J,[e]:t}:Object.fromEntries(Object.entries(J).filter(([s])=>s!==e));Fe(n),R&&K&&K(n),v?v(1):X(1)},He=e=>{se.current||(typeof oe=="function"&&oe(e),se.current=setTimeout(()=>{se.current=null},3e3))},we=i.useCallback(e=>{if(typeof window<"u"&&te&&e.length>0&&G.current)try{localStorage.setItem(te,JSON.stringify(e)),re&&localStorage.setItem(re,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[te,re]),Ne=e=>{e!==j&&(G.current=!0,Y(t=>t.includes(e)?(se.current&&(clearTimeout(se.current),se.current=null),t.length===1||(_e(n=>new Set(n).add(e)),setTimeout(()=>{Y(n=>{const s=n.filter(l=>l!==e),o=V(s);return we(o),o}),_e(n=>{const s=new Set(n);return s.delete(e),s})},200)),t):t.length>=B?(He("Maximum 9 column selection allowed"),t):(Ie(n=>new Set(n).add(e)),setTimeout(()=>{Y(n=>{const s=n.includes(e)?n:[...n,e],o=V(s);return we(o),o}),Ie(n=>{const s=new Set(n);return s.delete(e),s})},200),t)))},at=(e,t)=>{p[t]!==j&&Se(t)},lt=()=>{Se(null),xe(null)},ct=(e,t)=>{e.preventDefault(),H!==null&&H!==t&&xe(t)},dt=()=>{xe(null)},ut=(e,t)=>{e.preventDefault(),H!==null&&H!==t&&p[t]!==j&&p[H]!==j&&(G.current=!0,Y(n=>{const s=b.arrayMove(n,H,t),o=V(s);return we(o),o})),Se(null),xe(null)};i.useEffect(()=>{$e(e=>{const t=p.filter(o=>e.includes(o)),n=p.filter(o=>!e.includes(o)),s=e.filter(o=>!p.includes(o));return[...t,...n,...s]})},[p]),i.useEffect(()=>{if(typeof window<"u"&&te&&p.length>0&&G.current)try{const e=V(p);localStorage.setItem(te,JSON.stringify(e)),re&&localStorage.setItem(re,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[p,te,re]),i.useEffect(()=>{if(c.length>0&&p.length===0){if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const o=s.filter(l=>c.some(a=>(a.id||a.key)===l));if(o.length>0){G.current=!0,Y(o.slice(0,B));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=c.map(t=>t.id||t.key);Y(V(e.slice(0,B)))}},[c,f,k,V]);const Q=i.useMemo(()=>{const e=p.map(t=>c.find(n=>C(n)===t)).filter(Boolean);return V(e.map(C)).map(t=>c.find(n=>C(n)===t)).filter(Boolean)},[c,p]),pt=i.useMemo(()=>Q.some(e=>e.filterable===!0),[Q]);i.useEffect(()=>{if(!T||!ne.current)return;const e=()=>{if(ne.current){const t=ne.current.getBoundingClientRect();Ye({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)}},[T]),i.useEffect(()=>{const e=t=>{T&&ne.current&&!ne.current.contains(t.target)&&ke.current&&!ke.current.contains(t.target)&&Pe(!1)};if(T)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[T]);const ft=p.length===1?((Ke=c.find(e=>(e.id||e.key)===p[0]))==null?void 0:Ke.label)||"1 selected":`${p.length} selected`;function xt({column:e,isHeaderRow:t=!0}){const n=C(e),s=n===j,o=Me(n,e.width),{attributes:l,listeners:a,setNodeRef:d,transform:q,transition:z,isDragging:ue}=b.useSortable({id:n}),Le={transform:b.CSS.Transform.toString(q),transition:z,opacity:ue?.5:1,width:o,minWidth:o};let Z=!1;if(F&&x.length>0){const h=x[0][0];(h===n||h==="csat_score"&&n==="evaluation.csat_score")&&(Z=!0)}else Z=ce===n;const mt=fe==="asc",ht=e.filterable===!0;return t?r.jsx("th",{ref:d,style:{...Le,padding:"12px 14px",textAlign:s?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:o,borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start",position:"relative",minHeight:20},children:[!s&&r.jsx("div",{...l,...a,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:r.jsx(L.GripVertical,{size:12})}),r.jsx("span",{onClick:()=>e.sortable!==!1&&it(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&Z&&r.jsx("span",{children:mt?r.jsx(L.ChevronUp,{size:12}):r.jsx(L.ChevronDown,{size:12})}),!s&&r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||n} column`,title:"Drag to resize column",onMouseDown:h=>rt(h,e,o),onClick:h=>h.stopPropagation(),style:{position:"absolute",top:0,right:-1,width:14,height:"100%",cursor:"col-resize",zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(30, 33, 37, 0.56)"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(30, 33, 37, 0.08)",h.currentTarget.style.color="rgba(30, 33, 37, 0.86)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent",h.currentTarget.style.color="rgba(30, 33, 37, 0.56)"},children:r.jsx(bt,{size:10,color:"currentColor"})})]})}):r.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:ht?r.jsxs("div",{className:"relative",children:[r.jsx(L.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),r.jsx("input",{type:"text",placeholder:"Filter...",value:J[n]||"",onChange:h=>{h.stopPropagation(),Ve(n,h.target.value)},onKeyDown:h=>h.stopPropagation(),onMouseDown:h=>h.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"})]}):r.jsx("div",{className:"h-[34px]"})})}const qe=Be?c.find(e=>C(e)===Be):null,gt=T?r.jsxs("div",{ref:ke,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${je.top}px`,left:`${je.left}px`,width:je.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[p.map((e,t)=>{const n=c.find(d=>C(d)===e);if(!n)return null;const s=p.indexOf(e),o=H===s,l=Ze===s,a=e===j;return r.jsxs(i.Fragment,{children:[r.jsxs("div",{draggable:!a,onDragStart:a?void 0:d=>at(d,s),onDragEnd:a?void 0:lt,onDragOver:a?void 0:d=>ct(d,s),onDragLeave:a?void 0:dt,onDrop:a?void 0:d=>ut(d,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${a?"cursor-default opacity-100":"cursor-move"} ${!a&&o?"opacity-50":""} ${!a&&l&&H!==null&&H!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!a&&r.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),r.jsx("button",{type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),a||Ne(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${a?"bg-green-2 border-green-2 cursor-default":Ae.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!Ae.has(e)&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),t<p.length-1&&r.jsx(Ee,{})]},`selected-${e}-${t}`)}),c.filter(e=>!p.includes(C(e))).map((e,t)=>{const n=C(e),s=Qe.has(n),o=c.filter(l=>!p.includes(C(l))).indexOf(e);return r.jsxs(i.Fragment,{children:[p.length>0&&o===0&&r.jsx(Ee,{}),r.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:l=>{l.preventDefault(),Ne(n)},children:[r.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),Ne(n)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${s?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:s&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),o<c.filter(l=>!p.includes(C(l))).length-1&&r.jsx(Ee,{})]},`unselected-${n}`)})]}):null;return r.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[c.length>0&&r.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex-shrink-0",children:[r.jsx("div",{className:"mb-1 ml-1.5",children:r.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),r.jsxs("div",{ref:ne,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>Pe(!T),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:T?"8px 8px 0 0":"8px"},children:[r.jsx("span",{children:ft}),T?r.jsx(L.ChevronUp,{size:16}):r.jsx(L.ChevronDown,{size:16})]}),T&&Ue.createPortal(gt,document.body)]}),N&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),r.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:r.jsx(Ge,{dateRangePicker:N.dateRangePicker,onWeekToDate:N.onWeekToDate,exportConfig:N.exportConfig,filterChipsConfig:N.filterChipsConfig,trailingActions:N.trailingActions})})]})]})}),c.length>0&&Q.length>0?r.jsxs(b.DndContext,{sensors:nt,collisionDetection:b.closestCenter,onDragStart:ot,onDragEnd:st,children:[r.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[P&&r.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:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[r.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),r.jsx(vt,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),r.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:tt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[r.jsxs("thead",{children:[r.jsx("tr",{children:r.jsx(b.SortableContext,{items:p,strategy:b.horizontalListSortingStrategy,children:Q.map(e=>r.jsx(xt,{column:e,isHeaderRow:!0},`header-${C(e)}`))})}),pt&&r.jsx("tr",{children:Q.map(e=>{const t=C(e),n=Me(t,e.width),s=e.filterable===!0;return r.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:n,fontFamily:"var(--font-sans)"},children:s?r.jsxs("div",{style:{position:"relative"},children:[r.jsx("input",{type:"text",placeholder:"Filter...",value:J[t]||"",onChange:o=>{o.stopPropagation(),Ve(t,o.target.value)},onKeyDown:o=>o.stopPropagation(),onMouseDown:o=>o.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:o=>{o.target.style.borderColor="rgba(231, 212, 162, 0.65)",o.target.style.background="var(--primary-foreground)"},onBlur:o=>{o.target.style.borderColor="rgba(52, 58, 64, 0.16)",o.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),r.jsx(L.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):r.jsx("div",{className:"h-[34px]"})},`filter-${t}`)})})]}),r.jsx("tbody",{children:!P&&ve.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:Q.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!P&&ve.length>0?ve.map((e,t)=>r.jsx("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:u?"pointer":"default",transition:"background 0.15s ease"},onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:Q.map(n=>{const s=C(n),o=Me(s,n.width),l=e[s],a=n.render?n.render(l,e):l,d=o&&o!=="auto",q=typeof a=="string"&&a.trim()!=="",z=d&&q,ue=z?r.jsx(I,{content:a,children:a}):a;return r.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:ue},s)})},t)):null})]})})]}),r.jsx(b.DragOverlay,{children:qe?r.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(L.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),r.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:qe.label})]})}):null})]}):null,(A?D>0:ye.length>0)&&r.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:r.jsx(Xe.Pagination,{page:O,pageSizeOptions:[5,10,20,50,100],pageSize:U,totalCount:A?D:ye.length,currentDataLength:ve.length,onPageChange:_,onPageSizeChange:E?e=>{pe(e),_(1)}:e=>{pe(e),_(1)},showPageSizeSelector:!0})})]})}function St({title:g="Summary stats",stats:c=[],columns:y=2}){return r.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[r.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:g}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:"10px"},children:c.map((u,D)=>r.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:u.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[u.accentColor&&r.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:u.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),r.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),r.jsx("div",{style:{fontSize:"13px",color:u.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:u.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:u.value}),u.subtext&&r.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.subtext})]},D))})]})}exports.DataTable=jt;exports.DataTableFilters=Ge;exports.SummaryStatsPanel=St;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),b=require("../sortable.esm.cjs.js"),L=require("lucide-react"),Xe=require("react-dom"),Ge=require("../CustomFilterChips.cjs.js"),Ee=require("../DataTable2.cjs.js");require("motion/react");require("recharts");require("../TourGuideTooltip.cjs.js");function Fe(){return r.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}function bt({size:g=10,color:c="currentColor"}){return r.jsxs("svg",{width:g,height:g,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},"aria-hidden":"true",children:[r.jsx("path",{d:"M3.5 8H12.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round"}),r.jsx("path",{d:"M5 6.5L3.5 8L5 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M11 6.5L12.5 8L11 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6.8 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"}),r.jsx("path",{d:"M9.2 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"})]})}const yt=()=>({userData:{email:"anonymous"}}),vt=g=>r.jsx("img",{...g});function wt({children:g,content:c,direction:y="top",align:u="center",styling:D,indicatorColor:S}){const W=typeof c=="string"?c:c!=null?String(c):"",v=typeof S=="string"&&(S.startsWith("#")||S.startsWith("rgb")||S.startsWith("hsl")||S.startsWith("var("))?S:"var(--Grey-Strong, #2E3236)",[F,K]=i.useState(!1),[$,oe]=i.useState(!1),[M,x]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),f=i.useRef(null),P=i.useRef(null);if(!W)return g;i.useEffect(()=>{oe(!0)},[]);const N=i.useCallback(()=>{if(!f.current||!P.current||typeof window>"u")return;const m=f.current.getBoundingClientRect(),w=P.current.getBoundingClientRect(),ie=window.innerWidth,k=window.innerHeight,I=8,A=10,R=w.width,E=w.height,ae=m.top,X=k-m.bottom,le=y==="bottom"?"bottom":"top";let ee=le;le==="top"&&ae<E+A+I&&X>ae?ee="bottom":le==="bottom"&&X<E+A+I&&ae>X&&(ee="top");let T=m.left+m.width/2;u==="start"&&(T=m.left),u==="end"&&(T=m.right);let U=ee==="top"?m.top-E-A:m.bottom+A,_=u==="start"?T:u==="end"?T-R:T-R/2;U=Math.max(I,Math.min(U,k-E-I)),_=Math.max(I,Math.min(_,ie-R-I));const pe=Math.max(10,Math.min(T-_,R-10));x({top:U,left:_,arrowLeft:pe,placement:ee})},[u,y]);return i.useEffect(()=>{if(!F||!$)return;N();const m=()=>N();return window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[F,$,N]),r.jsxs("span",{ref:f,style:{display:"block",width:"100%"},onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),children:[g,F&&$&&Xe.createPortal(r.jsxs("span",{ref:P,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 D=="object"?D:{}},children:[W,r.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 ${v}`}:{bottom:"100%",borderBottom:`7px solid ${v}`}}})]}),document.body)]})}function jt({data:g=[],columns:c=[],initialPageSize:y=10,onRowClick:u,totalCount:D=null,page:S=null,pageSize:W=null,onPageChange:v=null,onPageSizeChange:F=null,onFilterChange:K=null,columnFilters:$=null,onMaxColumnsError:oe=null,onSort:M=null,sortFields:x=[],tableId:f=null,isLoading:P=!1,filtersConfig:N=null,columnResizeMinWidth:m=100,columnResizeMaxWidth:w=280}){var Ue;const{userData:ie}=yt(),k=(ie==null?void 0:ie.email)||"anonymous",I=i.memo(({children:e,content:t,className:n=""})=>{const s=i.useRef(null),[o,l]=i.useState(!1);i.useEffect(()=>{const d=()=>{if(s.current){const z=s.current.scrollWidth>s.current.clientWidth;l(z)}};d();const q=setTimeout(d,0);return window.addEventListener("resize",d),()=>{clearTimeout(q),window.removeEventListener("resize",d)}},[e,t]);const a=r.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return o&&t?r.jsx(wt,{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:a}):a});I.displayName="TruncatedCell";const A=D!==null&&v!==null,R=K!==null,E=M!==null,[ae,X]=i.useState(1),[le,ee]=i.useState(y),T=S!==null?S:ae,U=W!==null?W:le,_=e=>{v?v(e):X(e)},pe=e=>{F?F(e):ee(e)},B=9,j="action",G=i.useRef(!1),te=i.useMemo(()=>f?`dataTable_columns_${f}:${k}`:`dataTable_columns_${c.map(t=>t.id||t.key).sort().join("_")}:${k}`,[f,c,k]),re=i.useMemo(()=>f?`dataTable_manual_change_${f}:${k}`:null,[f,k]);i.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const n=localStorage.getItem(e);if(n){const o=JSON.parse(n).filter(l=>t.some(a=>(a.id||a.key)===l));if(o.length>0)return o}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[J,ze]=i.useState({}),[Re,Je]=i.useState(null),[Te,Oe]=i.useState("asc"),We=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),$e=i.useCallback((e,t)=>{const n=Object.keys(e||{}),s=Object.keys(t||{});return n.length!==s.length?!1:n.every(o=>e[o]===t[o])},[]);i.useEffect(()=>{if(!R||$===null)return;const e=We($);ze(t=>$e(t,e)?t:e)},[R,$,We,$e]),i.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const ce=E&&x.length>0?x[0][0]:Re,fe=E&&x.length>0?x[0][1]:Te,[Ct,Pe]=i.useState(()=>c.map(e=>e.id||e.key)),V=i.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>B&&(t=t.slice(0,B));const s=c.map(a=>a.id||a.key).includes(j);return!t.includes(j)&&s&&(t.length>=B?t=[...t.slice(0,B-1),j]:t=[...t,j]),[...t.filter(a=>a!==j),j]},[c]),[p,Y]=i.useState(()=>{if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){G.current=!0;const l=o.filter(a=>c.some(d=>(d.id||d.key)===a));if(l.length>0)return l.slice(0,B)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const t=c.map(n=>n.id||n.key).slice(0,B);return V(t)}),[O,Ie]=i.useState(!1),[je,Ye]=i.useState({top:0,left:0,width:0}),[Qe,Ae]=i.useState(new Set),[_e,Be]=i.useState(new Set),[H,Se]=i.useState(null),[Ze,xe]=i.useState(null),ne=i.useRef(null),ke=i.useRef(null),se=i.useRef(null),[Ve,Ce]=i.useState(null),[De,et]=i.useState({}),tt=i.useRef(null),ge=i.useRef(null),C=e=>e.id||e.key,me=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const s=parseFloat(t);return Number.isFinite(s)?s:null}const n=parseFloat(t);return Number.isFinite(n)&&`${n}`===t?n:null}return null},[]),Me=i.useCallback((e,t)=>De[e]!=null?`${De[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[De]),he=i.useCallback(e=>{if(!ge.current)return;const{columnId:t,startX:n,startWidth:s,minWidth:o,maxWidth:l}=ge.current,a=e.clientX-n,d=Math.round(s+a),q=Math.min(l,Math.max(o,d));et(z=>({...z,[t]:q}))},[]),de=i.useCallback(()=>{ge.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",de)},[he]),rt=i.useCallback((e,t,n)=>{var Z;e.preventDefault(),e.stopPropagation();const s=t.id||t.key,o=me(t.minWidth)??m,l=me(t.maxWidth)??w,a=Math.min(o,l),d=Math.max(o,l),q=((Z=e.currentTarget.closest("th"))==null?void 0:Z.getBoundingClientRect().width)||0,z=me(n),ue=z??Math.max(a,Math.round(q)||a),Le=Math.min(d,Math.max(a,ue));ge.current={columnId:s,startX:e.clientX,startWidth:Le,minWidth:a,maxWidth:d},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",he),document.addEventListener("mouseup",de)},[w,m,he,de,me]);i.useEffect(()=>()=>de(),[de]);const nt=b.useSensors(b.useSensor(b.PointerSensor),b.useSensor(b.KeyboardSensor,{coordinateGetter:b.sortableKeyboardCoordinates})),st=e=>{const{active:t,over:n}=e;if(n&&t.id!==n.id){if(t.id===j||n.id===j){qe("Cannot drop columns on the Action column"),Ce(null);return}G.current=!0,Y(s=>{const o=s.indexOf(t.id),l=s.indexOf(n.id);if(o!==-1&&l!==-1){const a=b.arrayMove(s,o,l),d=V(a);return we(d),d}return s}),Pe(s=>{const o=s.indexOf(t.id),l=s.indexOf(n.id);return b.arrayMove(s,o,l)})}Ce(null)},ot=e=>{Ce(e.active.id)},be=i.useMemo(()=>R?g||[]:!g||g.length===0?[]:g.filter(e=>Object.keys(J).every(t=>{const n=J[t];if(!n||n.trim()==="")return!0;const s=e[t];if(s==null)return!1;const o=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(d=>d.length>0).every(d=>o.includes(d))})),[g,J,R]),ye=i.useMemo(()=>E||!ce?be:[...be].sort((e,t)=>{const n=e[ce],s=t[ce];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return fe==="asc"?n-s:s-n;const o=String(n).toLowerCase(),l=String(s).toLowerCase();return fe==="asc"?o.localeCompare(l):l.localeCompare(o)}),[be,ce,fe,E]),ve=i.useMemo(()=>{if(A)return g||[];{const e=(T-1)*U,t=e+U;return ye.slice(e,t)}},[g,ye,T,U,A]),it=e=>{E&&M?(M(e),v?v(1):X(1)):(Re===e?Oe(Te==="asc"?"desc":"asc"):(Je(e),Oe("asc")),_(1))},He=(e,t)=>{const n=t&&t.trim()!==""?{...J,[e]:t}:Object.fromEntries(Object.entries(J).filter(([s])=>s!==e));ze(n),R&&K&&K(n),v?v(1):X(1)},qe=e=>{se.current||(typeof oe=="function"&&oe(e),se.current=setTimeout(()=>{se.current=null},3e3))},we=i.useCallback(e=>{if(typeof window<"u"&&te&&e.length>0&&G.current)try{localStorage.setItem(te,JSON.stringify(e)),re&&localStorage.setItem(re,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[te,re]),Ne=e=>{e!==j&&(G.current=!0,Y(t=>t.includes(e)?(se.current&&(clearTimeout(se.current),se.current=null),t.length===1||(Be(n=>new Set(n).add(e)),setTimeout(()=>{Y(n=>{const s=n.filter(l=>l!==e),o=V(s);return we(o),o}),Be(n=>{const s=new Set(n);return s.delete(e),s})},200)),t):t.length>=B?(qe("Maximum 9 column selection allowed"),t):(Ae(n=>new Set(n).add(e)),setTimeout(()=>{Y(n=>{const s=n.includes(e)?n:[...n,e],o=V(s);return we(o),o}),Ae(n=>{const s=new Set(n);return s.delete(e),s})},200),t)))},at=(e,t)=>{p[t]!==j&&Se(t)},lt=()=>{Se(null),xe(null)},ct=(e,t)=>{e.preventDefault(),H!==null&&H!==t&&xe(t)},dt=()=>{xe(null)},ut=(e,t)=>{e.preventDefault(),H!==null&&H!==t&&p[t]!==j&&p[H]!==j&&(G.current=!0,Y(n=>{const s=b.arrayMove(n,H,t),o=V(s);return we(o),o})),Se(null),xe(null)};i.useEffect(()=>{Pe(e=>{const t=p.filter(o=>e.includes(o)),n=p.filter(o=>!e.includes(o)),s=e.filter(o=>!p.includes(o));return[...t,...n,...s]})},[p]),i.useEffect(()=>{if(typeof window<"u"&&te&&p.length>0&&G.current)try{const e=V(p);localStorage.setItem(te,JSON.stringify(e)),re&&localStorage.setItem(re,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[p,te,re]),i.useEffect(()=>{if(c.length>0&&p.length===0){if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const o=s.filter(l=>c.some(a=>(a.id||a.key)===l));if(o.length>0){G.current=!0,Y(o.slice(0,B));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=c.map(t=>t.id||t.key);Y(V(e.slice(0,B)))}},[c,f,k,V]);const Q=i.useMemo(()=>{const e=p.map(t=>c.find(n=>C(n)===t)).filter(Boolean);return V(e.map(C)).map(t=>c.find(n=>C(n)===t)).filter(Boolean)},[c,p]),pt=i.useMemo(()=>Q.some(e=>e.filterable===!0),[Q]);i.useEffect(()=>{if(!O||!ne.current)return;const e=()=>{if(ne.current){const t=ne.current.getBoundingClientRect();Ye({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)}},[O]),i.useEffect(()=>{const e=t=>{O&&ne.current&&!ne.current.contains(t.target)&&ke.current&&!ke.current.contains(t.target)&&Ie(!1)};if(O)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[O]);const ft=p.length===1?((Ue=c.find(e=>(e.id||e.key)===p[0]))==null?void 0:Ue.label)||"1 selected":`${p.length} selected`;function xt({column:e,isHeaderRow:t=!0}){const n=C(e),s=n===j,o=Me(n,e.width),{attributes:l,listeners:a,setNodeRef:d,transform:q,transition:z,isDragging:ue}=b.useSortable({id:n}),Le={transform:b.CSS.Transform.toString(q),transition:z,opacity:ue?.5:1,width:o,minWidth:o};let Z=!1;if(E&&x.length>0){const h=x[0][0];(h===n||h==="csat_score"&&n==="evaluation.csat_score")&&(Z=!0)}else Z=ce===n;const mt=fe==="asc",ht=e.filterable===!0;return t?r.jsx("th",{ref:d,style:{...Le,padding:"12px 14px",textAlign:s?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:o,borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start",position:"relative",minHeight:20},children:[!s&&r.jsx("div",{...l,...a,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:r.jsx(L.GripVertical,{size:12})}),r.jsx("span",{onClick:()=>e.sortable!==!1&&it(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&Z&&r.jsx("span",{children:mt?r.jsx(L.ChevronUp,{size:12}):r.jsx(L.ChevronDown,{size:12})}),!s&&r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||n} column`,title:"Drag to resize column",onMouseDown:h=>rt(h,e,o),onClick:h=>h.stopPropagation(),style:{position:"absolute",top:0,right:-1,width:14,height:"100%",cursor:"col-resize",zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(30, 33, 37, 0.56)"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(30, 33, 37, 0.08)",h.currentTarget.style.color="rgba(30, 33, 37, 0.86)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent",h.currentTarget.style.color="rgba(30, 33, 37, 0.56)"},children:r.jsx(bt,{size:10,color:"currentColor"})})]})}):r.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:ht?r.jsxs("div",{className:"relative",children:[r.jsx(L.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),r.jsx("input",{type:"text",placeholder:"Filter...",value:J[n]||"",onChange:h=>{h.stopPropagation(),He(n,h.target.value)},onKeyDown:h=>h.stopPropagation(),onMouseDown:h=>h.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"})]}):r.jsx("div",{className:"h-[34px]"})})}const Ke=Ve?c.find(e=>C(e)===Ve):null,gt=O?r.jsxs("div",{ref:ke,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${je.top}px`,left:`${je.left}px`,width:je.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[p.map((e,t)=>{const n=c.find(d=>C(d)===e);if(!n)return null;const s=p.indexOf(e),o=H===s,l=Ze===s,a=e===j;return r.jsxs(i.Fragment,{children:[r.jsxs("div",{draggable:!a,onDragStart:a?void 0:d=>at(d,s),onDragEnd:a?void 0:lt,onDragOver:a?void 0:d=>ct(d,s),onDragLeave:a?void 0:dt,onDrop:a?void 0:d=>ut(d,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${a?"cursor-default opacity-100":"cursor-move"} ${!a&&o?"opacity-50":""} ${!a&&l&&H!==null&&H!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!a&&r.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),r.jsx("button",{type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),a||Ne(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${a?"bg-green-2 border-green-2 cursor-default":_e.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!_e.has(e)&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),t<p.length-1&&r.jsx(Fe,{})]},`selected-${e}-${t}`)}),c.filter(e=>!p.includes(C(e))).map((e,t)=>{const n=C(e),s=Qe.has(n),o=c.filter(l=>!p.includes(C(l))).indexOf(e);return r.jsxs(i.Fragment,{children:[p.length>0&&o===0&&r.jsx(Fe,{}),r.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:l=>{l.preventDefault(),Ne(n)},children:[r.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),Ne(n)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${s?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:s&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),o<c.filter(l=>!p.includes(C(l))).length-1&&r.jsx(Fe,{})]},`unselected-${n}`)})]}):null;return r.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[c.length>0&&r.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex-shrink-0",children:[r.jsx("div",{className:"mb-1 ml-1.5",children:r.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),r.jsxs("div",{ref:ne,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>Ie(!O),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:O?"8px 8px 0 0":"8px"},children:[r.jsx("span",{children:ft}),O?r.jsx(L.ChevronUp,{size:16}):r.jsx(L.ChevronDown,{size:16})]}),O&&Xe.createPortal(gt,document.body)]}),N&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),r.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:r.jsx(Ee.DataTableFilters,{dateRangePicker:N.dateRangePicker,onWeekToDate:N.onWeekToDate,exportConfig:N.exportConfig,filterChipsConfig:N.filterChipsConfig,trailingActions:N.trailingActions})})]})]})}),c.length>0&&Q.length>0?r.jsxs(b.DndContext,{sensors:nt,collisionDetection:b.closestCenter,onDragStart:ot,onDragEnd:st,children:[r.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[P&&r.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:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[r.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),r.jsx(vt,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),r.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:tt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[r.jsxs("thead",{children:[r.jsx("tr",{children:r.jsx(b.SortableContext,{items:p,strategy:b.horizontalListSortingStrategy,children:Q.map(e=>r.jsx(xt,{column:e,isHeaderRow:!0},`header-${C(e)}`))})}),pt&&r.jsx("tr",{children:Q.map(e=>{const t=C(e),n=Me(t,e.width),s=e.filterable===!0;return r.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:n,fontFamily:"var(--font-sans)"},children:s?r.jsxs("div",{style:{position:"relative"},children:[r.jsx("input",{type:"text",placeholder:"Filter...",value:J[t]||"",onChange:o=>{o.stopPropagation(),He(t,o.target.value)},onKeyDown:o=>o.stopPropagation(),onMouseDown:o=>o.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:o=>{o.target.style.borderColor="rgba(231, 212, 162, 0.65)",o.target.style.background="var(--primary-foreground)"},onBlur:o=>{o.target.style.borderColor="rgba(52, 58, 64, 0.16)",o.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),r.jsx(L.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):r.jsx("div",{className:"h-[34px]"})},`filter-${t}`)})})]}),r.jsx("tbody",{children:!P&&ve.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:Q.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!P&&ve.length>0?ve.map((e,t)=>r.jsx("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:u?"pointer":"default",transition:"background 0.15s ease"},onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:Q.map(n=>{const s=C(n),o=Me(s,n.width),l=e[s],a=n.render?n.render(l,e):l,d=o&&o!=="auto",q=typeof a=="string"&&a.trim()!=="",z=d&&q,ue=z?r.jsx(I,{content:a,children:a}):a;return r.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:ue},s)})},t)):null})]})})]}),r.jsx(b.DragOverlay,{children:Ke?r.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(L.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),r.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:Ke.label})]})}):null})]}):null,(A?D>0:ye.length>0)&&r.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:r.jsx(Ge.Pagination,{page:T,pageSizeOptions:[5,10,20,50,100],pageSize:U,totalCount:A?D:ye.length,currentDataLength:ve.length,onPageChange:_,onPageSizeChange:F?e=>{pe(e),_(1)}:e=>{pe(e),_(1)},showPageSizeSelector:!0})})]})}function St({dateRangePicker:g,onWeekToDate:c,exportConfig:y,filterChipsConfig:u,trailingActions:D}){const[S,W]=i.useState(!1),v=i.useRef(null),F=i.useRef(null);i.useEffect(()=>{const x=f=>{F.current&&!F.current.contains(f.target)&&v.current&&!v.current.contains(f.target)&&W(!1)};if(S)return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[S]);const K=()=>{W(x=>!x)},$=x=>{W(!1),y!=null&&y.onExport&&y.onExport(x)},M=(()=>{if(!(u!=null&&u.filters))return!1;const x=u.filters,f=u.customFilters||[],P=Object.entries(x).some(([m,w])=>!!(Array.isArray(w)&&w.length||typeof w=="string"&&w.trim()!==""||w&&typeof w=="object"&&(w.min!=null||w.max!=null))),N=f.some(m=>m.active);return P||N})();return r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&r.jsxs("button",{onClick:c,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:[r.jsx(L.CalendarClock,{size:16}),r.jsx("span",{children:"Week to Date"})]}),g&&r.jsx(i.Suspense,{fallback:r.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:[r.jsx(L.CalendarClock,{size:16}),r.jsx("span",{children:"Loading..."})]}),children:g}),y&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{ref:v,onClick:K,disabled:y.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(L.Download,{size:16}),r.jsx("span",{children:y.isExporting?"Exporting...":"Export"})]}),r.jsx(L.ChevronDown,{size:16})]}),S&&r.jsx("div",{ref:F,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:(y.types||["csv"]).map(x=>r.jsxs("button",{onClick:()=>$(x),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 ",x.toUpperCase()]},x))})]}),(M||D)&&r.jsxs(r.Fragment,{children:[M&&r.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),r.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[M&&u&&r.jsx(Ge.CustomFilterChips,{filters:u.filters,onChange:u.onChange,onClear:u.onClear,customFilters:u.customFilters||[],fieldOptions:u.fieldOptions||{}}),D&&r.jsx("div",{className:"flex-shrink-0",children:D})]})]})]})}function kt({title:g="Summary stats",stats:c=[],columns:y=2}){return r.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[r.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:g}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:"10px"},children:c.map((u,D)=>r.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:u.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[u.accentColor&&r.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:u.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),r.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),r.jsx("div",{style:{fontSize:"13px",color:u.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:u.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:u.value}),u.subtext&&r.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.subtext})]},D))})]})}exports.DataTable2=Ee.DataTable2;exports.DataTableFilters=Ee.DataTableFilters;exports.DataTable=jt;exports.DataTableFilters2=St;exports.SummaryStatsPanel=kt;
2
2
  //# sourceMappingURL=data.cjs.js.map