chordia-ui 3.3.2 → 3.3.3

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 (33) hide show
  1. package/README.md +4 -0
  2. package/dist/SmallButton.cjs.js +1 -1
  3. package/dist/SmallButton.cjs.js.map +1 -1
  4. package/dist/SmallButton.es.js +170 -162
  5. package/dist/SmallButton.es.js.map +1 -1
  6. package/dist/components/chat.cjs.js +8 -8
  7. package/dist/components/chat.cjs.js.map +1 -1
  8. package/dist/components/chat.es.js +329 -335
  9. package/dist/components/chat.es.js.map +1 -1
  10. package/dist/components/data.cjs.js +1 -1
  11. package/dist/components/data.cjs.js.map +1 -1
  12. package/dist/components/data.es.js +83 -80
  13. package/dist/components/data.es.js.map +1 -1
  14. package/dist/components/layout.cjs.js +1 -1
  15. package/dist/components/layout.cjs.js.map +1 -1
  16. package/dist/components/layout.es.js +3 -1
  17. package/dist/components/layout.es.js.map +1 -1
  18. package/dist/index.cjs2.js +1 -1
  19. package/dist/index.cjs2.js.map +1 -1
  20. package/dist/index.es2.js +4 -4
  21. package/dist/index.es2.js.map +1 -1
  22. package/dist/pages/interactionDetails.cjs.js +2 -2
  23. package/dist/pages/interactionDetails.cjs.js.map +1 -1
  24. package/dist/pages/interactionDetails.es.js +117 -123
  25. package/dist/pages/interactionDetails.es.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/chat/ChatHistoryPanel.jsx +3 -3
  28. package/src/components/chat/ChatInterface.jsx +14 -14
  29. package/src/components/common/MessageThread.jsx +19 -19
  30. package/src/components/data/DataTable.jsx +18 -15
  31. package/src/components/layout/SplitPane.jsx +2 -0
  32. package/src/components/login/LoginPage.jsx +4 -4
  33. package/src/components/primitives/SmallButton.jsx +14 -6
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),g=require("../sortable.esm.cjs.js"),v=require("lucide-react"),nt=require("react-dom"),Ee=require("../CustomFilterChips.cjs.js");function Oe({dateRangePicker:p,onWeekToDate:c,exportConfig:b,filterChipsConfig:x,trailingActions:C}){const[_,A]=a.useState(!1),w=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{const d=E=>{M.current&&!M.current.contains(E.target)&&w.current&&!w.current.contains(E.target)&&A(!1)};if(_)return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[_]);const K=()=>{A(d=>!d)},G=d=>{A(!1),b!=null&&b.onExport&&b.onExport(d)},S=(()=>{if(!(x!=null&&x.filters))return!1;const d=x.filters,E=x.customFilters||[],O=Object.entries(d).some(([h,j])=>!!(Array.isArray(j)&&j.length||typeof j=="string"&&j.trim()!==""||j&&typeof j=="object"&&(j.min!=null||j.max!=null))),U=E.some(h=>h.active);return O||U})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&t.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:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),p&&t.jsx(a.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(v.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:p}),b&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:w,onClick:K,disabled:b.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(v.Download,{size:16}),t.jsx("span",{children:b.isExporting?"Exporting...":"Export"})]}),t.jsx(v.ChevronDown,{size:16})]}),_&&t.jsx("div",{ref:M,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:(b.types||["csv"]).map(d=>t.jsxs("button",{onClick:()=>G(d),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 ",d.toUpperCase()]},d))})]}),(S||C)&&t.jsxs(t.Fragment,{children:[S&&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:[S&&x&&t.jsx(Ee.CustomFilterChips,{filters:x.filters,onChange:x.onChange,onClear:x.onClear,customFilters:x.customFilters||[],fieldOptions:x.fieldOptions||{}}),C&&t.jsx("div",{className:"flex-shrink-0",children:C})]})]})]})}function pe(){return t.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}const st=()=>({userData:{email:"anonymous"}}),ot=p=>t.jsx("img",{...p});function at({children:p}){return p}function lt({data:p=[],columns:c=[],initialPageSize:b=10,onRowClick:x,totalCount:C=null,page:_=null,pageSize:A=null,onPageChange:w=null,onPageSizeChange:M=null,onFilterChange:K=null,onMaxColumnsError:G=null,onSort:Y=null,sortFields:S=[],tableId:d=null,isLoading:E=!1,filtersConfig:O=null}){var Fe;const{userData:U}=st(),h=(U==null?void 0:U.email)||"anonymous",j=a.memo(({children:e,content:r,className:n=""})=>{const s=a.useRef(null),[o,l]=a.useState(!1);a.useEffect(()=>{const u=()=>{if(s.current){const J=s.current.scrollWidth>s.current.clientWidth;l(J)}};u();const H=setTimeout(u,0);return window.addEventListener("resize",u),()=>{clearTimeout(H),window.removeEventListener("resize",u)}},[e,r]);const i=t.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return o&&r?t.jsx(at,{content:r,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:i}):i});j.displayName="TruncatedCell";const X=C!==null&&w!==null,le=K!==null,I=Y!==null,[ze,ie]=a.useState(1),[Me,Te]=a.useState(b),ce=_!==null?_:ze,Q=A!==null?A:Me,Z=e=>{w?w(e):ie(e)},ge=e=>{M?M(e):Te(e)},D=9,y="action",T=a.useRef(!1),P=a.useMemo(()=>d?`dataTable_columns_${d}:${h}`:`dataTable_columns_${c.map(r=>r.id||r.key).sort().join("_")}:${h}`,[d,c,h]),B=a.useMemo(()=>d?`dataTable_manual_change_${d}:${h}`:null,[d,h]);a.useCallback((e,r)=>{if(typeof window>"u"||!e||!r||r.length===0)return null;try{const n=localStorage.getItem(e);if(n){const o=JSON.parse(n).filter(l=>r.some(i=>(i.id||i.key)===l));if(o.length>0)return o}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[L,Le]=a.useState({}),[he,Re]=a.useState(null),[me,be]=a.useState("asc");a.useCallback((e,r)=>e==="csat_score"&&r==="evaluation.csat_score"?r:e,[]);const q=I&&S.length>0?S[0][0]:he,ee=I&&S.length>0?S[0][1]:me,[ct,ye]=a.useState(()=>c.map(e=>e.id||e.key)),z=a.useCallback(e=>{if(!e||e.length===0)return e;let r=Array.from(new Set(e));r.length>D&&(r=r.slice(0,D));const s=c.map(i=>i.id||i.key).includes(y);return!r.includes(y)&&s&&(r.length>=D?r=[...r.slice(0,D-1),y]:r=[...r,y]),[...r.filter(i=>i!==y),y]},[c]),[f,R]=a.useState(()=>{if(typeof window<"u"&&d)try{if(localStorage.getItem(`dataTable_manual_change_${d}:${h}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${d}:${h}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){T.current=!0;const l=o.filter(i=>c.some(u=>(u.id||u.key)===i));if(l.length>0)return l.slice(0,D)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const r=c.map(n=>n.id||n.key).slice(0,D);return z(r)}),[k,ve]=a.useState(!1),[de,$e]=a.useState({top:0,left:0,width:0}),[_e,we]=a.useState(new Set),[je,Se]=a.useState(new Set),[N,ue]=a.useState(null),[Ae,te]=a.useState(null),W=a.useRef(null),xe=a.useRef(null),V=a.useRef(null),[ke,Ce]=a.useState(null),Ie=a.useRef(null),m=e=>e.id||e.key,Pe=g.useSensors(g.useSensor(g.PointerSensor),g.useSensor(g.KeyboardSensor,{coordinateGetter:g.sortableKeyboardCoordinates})),Be=e=>{const{active:r,over:n}=e;n&&r.id!==n.id&&(T.current=!0,R(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);if(o!==-1&&l!==-1){const i=g.arrayMove(s,o,l);return oe(i),i}return s}),ye(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);return g.arrayMove(s,o,l)})),Ce(null)},We=e=>{Ce(e.active.id)},re=a.useMemo(()=>le?p||[]:!p||p.length===0?[]:p.filter(e=>Object.keys(L).every(r=>{const n=L[r];if(!n||n.trim()==="")return!0;const s=e[r];if(s==null)return!1;const o=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(u=>u.length>0).every(u=>o.includes(u))})),[p,L,le]),ne=a.useMemo(()=>I||!q?re:[...re].sort((e,r)=>{const n=e[q],s=r[q];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return ee==="asc"?n-s:s-n;const o=String(n).toLowerCase(),l=String(s).toLowerCase();return ee==="asc"?o.localeCompare(l):l.localeCompare(o)}),[re,q,ee,I]),se=a.useMemo(()=>{if(X)return p||[];{const e=(ce-1)*Q,r=e+Q;return ne.slice(e,r)}},[p,ne,ce,Q,X]),Ve=e=>{I&&Y?(Y(e),w?w(1):ie(1)):(he===e?be(me==="asc"?"desc":"asc"):(Re(e),be("asc")),Z(1))},De=(e,r)=>{const n=r&&r.trim()!==""?{...L,[e]:r}:Object.fromEntries(Object.entries(L).filter(([s])=>s!==e));Le(n),le&&K&&K(n),w?w(1):ie(1)},He=e=>{V.current||(typeof G=="function"&&G(e),V.current=setTimeout(()=>{V.current=null},3e3))},oe=a.useCallback(e=>{if(typeof window<"u"&&P&&e.length>0&&T.current)try{localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(r){console.warn("Failed to save columns to localStorage:",r)}},[P,B]),fe=e=>{e!==y&&(T.current=!0,R(r=>r.includes(e)?(V.current&&(clearTimeout(V.current),V.current=null),r.length===1||(Se(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.filter(l=>l!==e),o=z(s);return oe(o),o}),Se(n=>{const s=new Set(n);return s.delete(e),s})},200)),r):r.length>=D?(He("Maximum 9 column selection allowed"),r):(we(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.includes(e)?n:[...n,e],o=z(s);return oe(o),o}),we(n=>{const s=new Set(n);return s.delete(e),s})},200),r)))},Ke=(e,r)=>{f[r]!==y&&ue(r)},Ue=()=>{ue(null),te(null)},qe=(e,r)=>{e.preventDefault(),N!==null&&N!==r&&te(r)},Je=()=>{te(null)},Ge=(e,r)=>{e.preventDefault(),N!==null&&N!==r&&f[r]!==y&&f[N]!==y&&(T.current=!0,R(n=>{const s=g.arrayMove(n,N,r),o=z(s);return oe(o),o})),ue(null),te(null)};a.useEffect(()=>{ye(e=>{const r=f.filter(o=>e.includes(o)),n=f.filter(o=>!e.includes(o)),s=e.filter(o=>!f.includes(o));return[...r,...n,...s]})},[f]),a.useEffect(()=>{if(typeof window<"u"&&P&&f.length>0&&T.current)try{const e=z(f);localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[f,P,B]),a.useEffect(()=>{if(c.length>0&&f.length===0){if(typeof window<"u"&&d)try{if(localStorage.getItem(`dataTable_manual_change_${d}:${h}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${d}:${h}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const o=s.filter(l=>c.some(i=>(i.id||i.key)===l));if(o.length>0){T.current=!0,R(o.slice(0,D));return}}}}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}const e=c.map(r=>r.id||r.key);R(z(e.slice(0,D)))}},[c,d,h,z]);const $=a.useMemo(()=>{const e=f.map(r=>c.find(n=>m(n)===r)).filter(Boolean);return z(e.map(m)).map(r=>c.find(n=>m(n)===r)).filter(Boolean)},[c,f]),Ye=a.useMemo(()=>$.some(e=>e.filterable===!0),[$]);a.useEffect(()=>{if(!k||!W.current)return;const e=()=>{if(W.current){const r=W.current.getBoundingClientRect();$e({top:r.bottom,left:r.left,width:Math.max(r.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[k]),a.useEffect(()=>{const e=r=>{k&&W.current&&!W.current.contains(r.target)&&xe.current&&!xe.current.contains(r.target)&&ve(!1)};if(k)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[k]);const Xe=f.length===1?((Fe=c.find(e=>(e.id||e.key)===f[0]))==null?void 0:Fe.label)||"1 selected":`${f.length} selected`;function Qe({column:e,isHeaderRow:r=!0}){const n=m(e),s=n===y,{attributes:o,listeners:l,setNodeRef:i,transform:u,transition:H,isDragging:J}=g.useSortable({id:n}),et={transform:g.CSS.Transform.toString(u),transition:H,opacity:J?.5:1,width:e.width||"auto",minWidth:e.width||"auto"};let ae=!1;if(I&&S.length>0){const F=S[0][0];(F===n||F==="csat_score"&&n==="evaluation.csat_score")&&(ae=!0)}else ae=q===n;const tt=ee==="asc",rt=e.filterable===!0;return r?t.jsx("th",{ref:i,style:{...et,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:e.width||"auto",borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"rgba(255, 255, 255, 0.95)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start"},children:[!s&&t.jsx("div",{...o,...l,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:t.jsx(v.GripVertical,{size:12})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&Ve(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&ae&&t.jsx("span",{children:tt?t.jsx(v.ChevronUp,{size:12}):t.jsx(v.ChevronDown,{size:12})})]})}):t.jsx("th",{style:{width:e.width||"auto",minWidth:e.width||"auto"},className:"sticky top-[57px] z-10 bg-[var(--paper-elevated)] border-b border-[var(--border-strong)] px-4 py-2 text-left",children:rt?t.jsxs("div",{className:"relative",children:[t.jsx(v.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:L[n]||"",onChange:F=>{F.stopPropagation(),De(n,F.target.value)},onKeyDown:F=>F.stopPropagation(),onMouseDown:F=>F.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded bg-[var(--paper)] 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)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})})}const Ne=ke?c.find(e=>m(e)===ke):null,Ze=k?t.jsxs("div",{ref:xe,className:"flex flex-col bg-white overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${de.top}px`,left:`${de.left}px`,width:de.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",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:[f.map((e,r)=>{const n=c.find(u=>m(u)===e);if(!n)return null;const s=f.indexOf(e),o=N===s,l=Ae===s,i=e===y;return t.jsxs(a.Fragment,{children:[t.jsxs("div",{draggable:!i,onDragStart:i?void 0:u=>Ke(u,s),onDragEnd:i?void 0:Ue,onDragOver:i?void 0:u=>qe(u,s),onDragLeave:i?void 0:Je,onDrop:i?void 0:u=>Ge(u,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${i?"cursor-default opacity-100":"cursor-move"} ${!i&&o?"opacity-50":""} ${!i&&l&&N!==null&&N!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!i&&t.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),t.jsx("button",{type:"button",onClick:u=>{u.preventDefault(),u.stopPropagation(),i||fe(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${i?"bg-green-2 border-green-2 cursor-default":je.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!je.has(e)&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),r<f.length-1&&t.jsx(pe,{})]},`selected-${e}-${r}`)}),c.filter(e=>!f.includes(m(e))).map((e,r)=>{const n=m(e),s=_e.has(n),o=c.filter(l=>!f.includes(m(l))).indexOf(e);return t.jsxs(a.Fragment,{children:[f.length>0&&o===0&&t.jsx(pe,{}),t.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(),fe(n)},children:[t.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),fe(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&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),o<c.filter(l=>!f.includes(m(l))).length-1&&t.jsx(pe,{})]},`unselected-${n}`)})]}):null;return t.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"#F4F1E6"},children:[c.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"#F4F1E6"},children:t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx("div",{className:"mb-1 ml-1.5",children:t.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),t.jsxs("div",{ref:W,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 bg-white/80 cursor-pointer hover:bg-white transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>ve(!k),style:{fontFamily:"var(--font-sans)",borderRadius:k?"8px 8px 0 0":"8px"},children:[t.jsx("span",{children:Xe}),k?t.jsx(v.ChevronUp,{size:16}):t.jsx(v.ChevronDown,{size:16})]}),k&&nt.createPortal(Ze,document.body)]}),O&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),t.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:t.jsx(Oe,{dateRangePicker:O.dateRangePicker,onWeekToDate:O.onWeekToDate,exportConfig:O.exportConfig,filterChipsConfig:O.filterChipsConfig,trailingActions:O.trailingActions})})]})]})}),c.length>0&&$.length>0?t.jsxs(g.DndContext,{sensors:Pe,collisionDetection:g.closestCenter,onDragStart:We,onDragEnd:Be,children:[t.jsxs("div",{className:"rounded-t-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"none",overflow:"hidden",background:"rgba(255, 255, 255, 0.82)",position:"relative",top:"0.5rem"},children:[E&&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(ot,{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:Ie,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[t.jsxs("thead",{children:[t.jsx("tr",{children:t.jsx(g.SortableContext,{items:f,strategy:g.horizontalListSortingStrategy,children:$.map(e=>t.jsx(Qe,{column:e,isHeaderRow:!0},`header-${m(e)}`))})}),Ye&&t.jsx("tr",{children:$.map(e=>{const r=m(e),n=e.filterable===!0;return t.jsx("th",{style:{padding:"8px 14px",background:"rgba(244, 241, 230, 0.35)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:e.width||"auto",fontFamily:"var(--font-sans)"},children:n?t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",placeholder:"Filter...",value:L[r]||"",onChange:s=>{s.stopPropagation(),De(r,s.target.value)},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"rgba(255, 255, 255, 0.85)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:s=>{s.target.style.borderColor="rgba(231, 212, 162, 0.65)",s.target.style.background="rgba(255, 255, 255, 1)"},onBlur:s=>{s.target.style.borderColor="rgba(52, 58, 64, 0.16)",s.target.style.background="rgba(255, 255, 255, 0.85)"},autoComplete:"off"}),t.jsx(v.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):t.jsx("div",{className:"h-[34px]"})},`filter-${r}`)})})]}),t.jsx("tbody",{children:!E&&se.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:$.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!E&&se.length>0?se.map((e,r)=>t.jsx("tr",{"data-row-id":e.id||r,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:x?"pointer":"default",transition:"background 0.15s ease"},onClick:x?n=>{n.stopPropagation(),x(e,r)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:$.map(n=>{const s=m(n),o=e[s],l=n.render?n.render(o,e):o,i=n.width&&n.width!=="auto",u=typeof l=="string"&&l.trim()!=="",H=i&&u,J=H?t.jsx(j,{content:l,children:l}):l;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:n.width||"auto",fontFamily:"var(--font-sans)",...H&&{maxWidth:n.width||"200px",overflow:"hidden"}},children:J},s)})},r)):null})]})})]}),t.jsx(g.DragOverlay,{children:Ne?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(v.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:Ne.label})]})}):null})]}):null,(X?C>0:ne.length>0)&&t.jsx("div",{className:"border-t border-gray-200 bg-white rounded-b-[14px]",children:t.jsx(Ee.Pagination,{page:ce,pageSizeOptions:[5,10,20,50,100],pageSize:Q,totalCount:X?C:ne.length,currentDataLength:se.length,onPageChange:Z,onPageSizeChange:M?e=>{ge(e),Z(1)}:e=>{ge(e),Z(1)},showPageSizeSelector:!0})})]})}function it({title:p="Summary stats",stats:c=[],columns:b=2}){return t.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[t.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:p}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gap:"10px"},children:c.map((x,C)=>t.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:x.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[x.accentColor&&t.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:x.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),t.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:x.label}),t.jsx("div",{style:{fontSize:"13px",color:x.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:x.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:x.value}),x.subtext&&t.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.subtext})]},C))})]})}exports.DataTable=lt;exports.DataTableFilters=Oe;exports.SummaryStatsPanel=it;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),g=require("../sortable.esm.cjs.js"),v=require("lucide-react"),nt=require("react-dom"),Oe=require("../CustomFilterChips.cjs.js");function ze({dateRangePicker:x,onWeekToDate:c,exportConfig:y,filterChipsConfig:f,trailingActions:C}){const[_,A]=a.useState(!1),w=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{const d=O=>{M.current&&!M.current.contains(O.target)&&w.current&&!w.current.contains(O.target)&&A(!1)};if(_)return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[_]);const K=()=>{A(d=>!d)},G=d=>{A(!1),y!=null&&y.onExport&&y.onExport(d)},S=(()=>{if(!(f!=null&&f.filters))return!1;const d=f.filters,O=f.customFilters||[],z=Object.entries(d).some(([m,j])=>!!(Array.isArray(j)&&j.length||typeof j=="string"&&j.trim()!==""||j&&typeof j=="object"&&(j.min!=null||j.max!=null))),U=O.some(m=>m.active);return z||U})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&t.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:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),x&&t.jsx(a.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(v.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:x}),y&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:w,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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v.Download,{size:16}),t.jsx("span",{children:y.isExporting?"Exporting...":"Export"})]}),t.jsx(v.ChevronDown,{size:16})]}),_&&t.jsx("div",{ref:M,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(d=>t.jsxs("button",{onClick:()=>G(d),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 ",d.toUpperCase()]},d))})]}),(S||C)&&t.jsxs(t.Fragment,{children:[S&&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:[S&&f&&t.jsx(Oe.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),C&&t.jsx("div",{className:"flex-shrink-0",children:C})]})]})]})}function xe(){return t.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}const st=()=>({userData:{email:"anonymous"}}),ot=x=>t.jsx("img",{...x});function at({children:x}){return x}function lt({data:x=[],columns:c=[],initialPageSize:y=10,onRowClick:f,totalCount:C=null,page:_=null,pageSize:A=null,onPageChange:w=null,onPageSizeChange:M=null,onFilterChange:K=null,onMaxColumnsError:G=null,onSort:Y=null,sortFields:S=[],tableId:d=null,isLoading:O=!1,filtersConfig:z=null}){var Fe;const{userData:U}=st(),m=(U==null?void 0:U.email)||"anonymous",j=a.memo(({children:e,content:r,className:n=""})=>{const s=a.useRef(null),[o,l]=a.useState(!1);a.useEffect(()=>{const u=()=>{if(s.current){const J=s.current.scrollWidth>s.current.clientWidth;l(J)}};u();const H=setTimeout(u,0);return window.addEventListener("resize",u),()=>{clearTimeout(H),window.removeEventListener("resize",u)}},[e,r]);const i=t.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return o&&r?t.jsx(at,{content:r,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:i}):i});j.displayName="TruncatedCell";const X=C!==null&&w!==null,le=K!==null,I=Y!==null,[Ee,ie]=a.useState(1),[Me,Te]=a.useState(y),ce=_!==null?_:Ee,Q=A!==null?A:Me,Z=e=>{w?w(e):ie(e)},ge=e=>{M?M(e):Te(e)},D=9,b="action",T=a.useRef(!1),P=a.useMemo(()=>d?`dataTable_columns_${d}:${m}`:`dataTable_columns_${c.map(r=>r.id||r.key).sort().join("_")}:${m}`,[d,c,m]),B=a.useMemo(()=>d?`dataTable_manual_change_${d}:${m}`:null,[d,m]);a.useCallback((e,r)=>{if(typeof window>"u"||!e||!r||r.length===0)return null;try{const n=localStorage.getItem(e);if(n){const o=JSON.parse(n).filter(l=>r.some(i=>(i.id||i.key)===l));if(o.length>0)return o}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[L,Le]=a.useState({}),[me,Re]=a.useState(null),[he,ye]=a.useState("asc");a.useCallback((e,r)=>e==="csat_score"&&r==="evaluation.csat_score"?r:e,[]);const q=I&&S.length>0?S[0][0]:me,ee=I&&S.length>0?S[0][1]:he,[ct,be]=a.useState(()=>c.map(e=>e.id||e.key)),E=a.useCallback(e=>{if(!e||e.length===0)return e;let r=Array.from(new Set(e));r.length>D&&(r=r.slice(0,D));const s=c.map(i=>i.id||i.key).includes(b);return!r.includes(b)&&s&&(r.length>=D?r=[...r.slice(0,D-1),b]:r=[...r,b]),[...r.filter(i=>i!==b),b]},[c]),[p,R]=a.useState(()=>{if(typeof window<"u"&&d)try{if(localStorage.getItem(`dataTable_manual_change_${d}:${m}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${d}:${m}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){T.current=!0;const l=o.filter(i=>c.some(u=>(u.id||u.key)===i));if(l.length>0)return l.slice(0,D)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const r=c.map(n=>n.id||n.key).slice(0,D);return E(r)}),[k,ve]=a.useState(!1),[de,$e]=a.useState({top:0,left:0,width:0}),[_e,we]=a.useState(new Set),[je,Se]=a.useState(new Set),[N,ue]=a.useState(null),[Ae,te]=a.useState(null),W=a.useRef(null),fe=a.useRef(null),V=a.useRef(null),[ke,Ce]=a.useState(null),Ie=a.useRef(null),h=e=>e.id||e.key,Pe=g.useSensors(g.useSensor(g.PointerSensor),g.useSensor(g.KeyboardSensor,{coordinateGetter:g.sortableKeyboardCoordinates})),Be=e=>{const{active:r,over:n}=e;n&&r.id!==n.id&&(T.current=!0,R(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);if(o!==-1&&l!==-1){const i=g.arrayMove(s,o,l);return oe(i),i}return s}),be(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);return g.arrayMove(s,o,l)})),Ce(null)},We=e=>{Ce(e.active.id)},re=a.useMemo(()=>le?x||[]:!x||x.length===0?[]:x.filter(e=>Object.keys(L).every(r=>{const n=L[r];if(!n||n.trim()==="")return!0;const s=e[r];if(s==null)return!1;const o=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(u=>u.length>0).every(u=>o.includes(u))})),[x,L,le]),ne=a.useMemo(()=>I||!q?re:[...re].sort((e,r)=>{const n=e[q],s=r[q];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return ee==="asc"?n-s:s-n;const o=String(n).toLowerCase(),l=String(s).toLowerCase();return ee==="asc"?o.localeCompare(l):l.localeCompare(o)}),[re,q,ee,I]),se=a.useMemo(()=>{if(X)return x||[];{const e=(ce-1)*Q,r=e+Q;return ne.slice(e,r)}},[x,ne,ce,Q,X]),Ve=e=>{I&&Y?(Y(e),w?w(1):ie(1)):(me===e?ye(he==="asc"?"desc":"asc"):(Re(e),ye("asc")),Z(1))},De=(e,r)=>{const n=r&&r.trim()!==""?{...L,[e]:r}:Object.fromEntries(Object.entries(L).filter(([s])=>s!==e));Le(n),le&&K&&K(n),w?w(1):ie(1)},He=e=>{V.current||(typeof G=="function"&&G(e),V.current=setTimeout(()=>{V.current=null},3e3))},oe=a.useCallback(e=>{if(typeof window<"u"&&P&&e.length>0&&T.current)try{localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(r){console.warn("Failed to save columns to localStorage:",r)}},[P,B]),pe=e=>{e!==b&&(T.current=!0,R(r=>r.includes(e)?(V.current&&(clearTimeout(V.current),V.current=null),r.length===1||(Se(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.filter(l=>l!==e),o=E(s);return oe(o),o}),Se(n=>{const s=new Set(n);return s.delete(e),s})},200)),r):r.length>=D?(He("Maximum 9 column selection allowed"),r):(we(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.includes(e)?n:[...n,e],o=E(s);return oe(o),o}),we(n=>{const s=new Set(n);return s.delete(e),s})},200),r)))},Ke=(e,r)=>{p[r]!==b&&ue(r)},Ue=()=>{ue(null),te(null)},qe=(e,r)=>{e.preventDefault(),N!==null&&N!==r&&te(r)},Je=()=>{te(null)},Ge=(e,r)=>{e.preventDefault(),N!==null&&N!==r&&p[r]!==b&&p[N]!==b&&(T.current=!0,R(n=>{const s=g.arrayMove(n,N,r),o=E(s);return oe(o),o})),ue(null),te(null)};a.useEffect(()=>{be(e=>{const r=p.filter(o=>e.includes(o)),n=p.filter(o=>!e.includes(o)),s=e.filter(o=>!p.includes(o));return[...r,...n,...s]})},[p]),a.useEffect(()=>{if(typeof window<"u"&&P&&p.length>0&&T.current)try{const e=E(p);localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[p,P,B]),a.useEffect(()=>{if(c.length>0&&p.length===0){if(typeof window<"u"&&d)try{if(localStorage.getItem(`dataTable_manual_change_${d}:${m}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${d}:${m}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const o=s.filter(l=>c.some(i=>(i.id||i.key)===l));if(o.length>0){T.current=!0,R(o.slice(0,D));return}}}}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}const e=c.map(r=>r.id||r.key);R(E(e.slice(0,D)))}},[c,d,m,E]);const $=a.useMemo(()=>{const e=p.map(r=>c.find(n=>h(n)===r)).filter(Boolean);return E(e.map(h)).map(r=>c.find(n=>h(n)===r)).filter(Boolean)},[c,p]),Ye=a.useMemo(()=>$.some(e=>e.filterable===!0),[$]);a.useEffect(()=>{if(!k||!W.current)return;const e=()=>{if(W.current){const r=W.current.getBoundingClientRect();$e({top:r.bottom,left:r.left,width:Math.max(r.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[k]),a.useEffect(()=>{const e=r=>{k&&W.current&&!W.current.contains(r.target)&&fe.current&&!fe.current.contains(r.target)&&ve(!1)};if(k)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[k]);const Xe=p.length===1?((Fe=c.find(e=>(e.id||e.key)===p[0]))==null?void 0:Fe.label)||"1 selected":`${p.length} selected`;function Qe({column:e,isHeaderRow:r=!0}){const n=h(e),s=n===b,{attributes:o,listeners:l,setNodeRef:i,transform:u,transition:H,isDragging:J}=g.useSortable({id:n}),et={transform:g.CSS.Transform.toString(u),transition:H,opacity:J?.5:1,width:e.width||"auto",minWidth:e.width||"auto"};let ae=!1;if(I&&S.length>0){const F=S[0][0];(F===n||F==="csat_score"&&n==="evaluation.csat_score")&&(ae=!0)}else ae=q===n;const tt=ee==="asc",rt=e.filterable===!0;return r?t.jsx("th",{ref:i,style:{...et,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:e.width||"auto",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:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start"},children:[!s&&t.jsx("div",{...o,...l,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:t.jsx(v.GripVertical,{size:12})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&Ve(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&ae&&t.jsx("span",{children:tt?t.jsx(v.ChevronUp,{size:12}):t.jsx(v.ChevronDown,{size:12})})]})}):t.jsx("th",{style:{width:e.width||"auto",minWidth:e.width||"auto",backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:rt?t.jsxs("div",{className:"relative",children:[t.jsx(v.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:L[n]||"",onChange:F=>{F.stopPropagation(),De(n,F.target.value)},onKeyDown:F=>F.stopPropagation(),onMouseDown:F=>F.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 Ne=ke?c.find(e=>h(e)===ke):null,Ze=k?t.jsxs("div",{ref:fe,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${de.top}px`,left:`${de.left}px`,width:de.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,r)=>{const n=c.find(u=>h(u)===e);if(!n)return null;const s=p.indexOf(e),o=N===s,l=Ae===s,i=e===b;return t.jsxs(a.Fragment,{children:[t.jsxs("div",{draggable:!i,onDragStart:i?void 0:u=>Ke(u,s),onDragEnd:i?void 0:Ue,onDragOver:i?void 0:u=>qe(u,s),onDragLeave:i?void 0:Je,onDrop:i?void 0:u=>Ge(u,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${i?"cursor-default opacity-100":"cursor-move"} ${!i&&o?"opacity-50":""} ${!i&&l&&N!==null&&N!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!i&&t.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),t.jsx("button",{type:"button",onClick:u=>{u.preventDefault(),u.stopPropagation(),i||pe(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${i?"bg-green-2 border-green-2 cursor-default":je.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!je.has(e)&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),r<p.length-1&&t.jsx(xe,{})]},`selected-${e}-${r}`)}),c.filter(e=>!p.includes(h(e))).map((e,r)=>{const n=h(e),s=_e.has(n),o=c.filter(l=>!p.includes(h(l))).indexOf(e);return t.jsxs(a.Fragment,{children:[p.length>0&&o===0&&t.jsx(xe,{}),t.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(),pe(n)},children:[t.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),pe(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&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),o<c.filter(l=>!p.includes(h(l))).length-1&&t.jsx(xe,{})]},`unselected-${n}`)})]}):null;return t.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[c.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx("div",{className:"mb-1 ml-1.5",children:t.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),t.jsxs("div",{ref:W,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:()=>ve(!k),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:k?"8px 8px 0 0":"8px"},children:[t.jsx("span",{children:Xe}),k?t.jsx(v.ChevronUp,{size:16}):t.jsx(v.ChevronDown,{size:16})]}),k&&nt.createPortal(Ze,document.body)]}),z&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),t.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:t.jsx(ze,{dateRangePicker:z.dateRangePicker,onWeekToDate:z.onWeekToDate,exportConfig:z.exportConfig,filterChipsConfig:z.filterChipsConfig,trailingActions:z.trailingActions})})]})]})}),c.length>0&&$.length>0?t.jsxs(g.DndContext,{sensors:Pe,collisionDetection:g.closestCenter,onDragStart:We,onDragEnd:Be,children:[t.jsxs("div",{className:"rounded-t-[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:[O&&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(ot,{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:Ie,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[t.jsxs("thead",{children:[t.jsx("tr",{children:t.jsx(g.SortableContext,{items:p,strategy:g.horizontalListSortingStrategy,children:$.map(e=>t.jsx(Qe,{column:e,isHeaderRow:!0},`header-${h(e)}`))})}),Ye&&t.jsx("tr",{children:$.map(e=>{const r=h(e),n=e.filterable===!0;return t.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:e.width||"auto",fontFamily:"var(--font-sans)"},children:n?t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",placeholder:"Filter...",value:L[r]||"",onChange:s=>{s.stopPropagation(),De(r,s.target.value)},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.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:s=>{s.target.style.borderColor="rgba(231, 212, 162, 0.65)",s.target.style.background="var(--primary-foreground)"},onBlur:s=>{s.target.style.borderColor="rgba(52, 58, 64, 0.16)",s.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),t.jsx(v.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):t.jsx("div",{className:"h-[34px]"})},`filter-${r}`)})})]}),t.jsx("tbody",{children:!O&&se.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:$.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!O&&se.length>0?se.map((e,r)=>t.jsx("tr",{"data-row-id":e.id||r,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?n=>{n.stopPropagation(),f(e,r)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:$.map(n=>{const s=h(n),o=e[s],l=n.render?n.render(o,e):o,i=n.width&&n.width!=="auto",u=typeof l=="string"&&l.trim()!=="",H=i&&u,J=H?t.jsx(j,{content:l,children:l}):l;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:n.width||"auto",fontFamily:"var(--font-sans)",...H&&{maxWidth:n.width||"200px",overflow:"hidden"}},children:J},s)})},r)):null})]})})]}),t.jsx(g.DragOverlay,{children:Ne?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(v.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:Ne.label})]})}):null})]}):null,(X?C>0:ne.length>0)&&t.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:t.jsx(Oe.Pagination,{page:ce,pageSizeOptions:[5,10,20,50,100],pageSize:Q,totalCount:X?C:ne.length,currentDataLength:se.length,onPageChange:Z,onPageSizeChange:M?e=>{ge(e),Z(1)}:e=>{ge(e),Z(1)},showPageSizeSelector:!0})})]})}function it({title:x="Summary stats",stats:c=[],columns:y=2}){return t.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[t.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:x}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:"10px"},children:c.map((f,C)=>t.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:f.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[f.accentColor&&t.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:f.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),t.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:f.label}),t.jsx("div",{style:{fontSize:"13px",color:f.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:f.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:f.value}),f.subtext&&t.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.subtext})]},C))})]})}exports.DataTable=lt;exports.DataTableFilters=ze;exports.SummaryStatsPanel=it;
2
2
  //# sourceMappingURL=data.cjs.js.map