1import{r as s,j as t}from"./index-CWRjl4JA.js";import{c as S,d as o,S as T}from"./search-D5hIV8JX.js";import{u as F,a as M,P as j}from"./index-BBZtD5O_.js";import{A as B}from"./arrow-left-5Oq5lr8P.js";import{C as L}from"./circle-x-DWIM801c.js";import{C as E}from"./clock-BRJxUOOc.js";import{T as _}from"./trash-2-COhisFdH.js";import{C as W}from"./chevron-down-CT2QBcrr.js";/** 2 * @license lucide-react v0.469.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const $=S("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** 7 * @license lucide-react v0.469.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const H=S("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),U=o.div.withConfig({displayName:"PageWrapper",componentId:"sc-1j19fvv-0"})(["display:flex;flex-direction:column;flex:1;height:100%;min-height:100%;width:100%;background:",";"],({theme:e})=>e.background),R=o.div.withConfig({displayName:"AllChatsContainer",componentId:"sc-1j19fvv-1"})(["display:flex;flex-direction:column;flex:1;height:100%;min-height:0;background:transparent;color:",";padding:32px 48px;width:100%;max-width:1400px;margin:0 auto;@media (max-width:1024px){padding:24px;max-width:100%;}"],({theme:e})=>e.textPrimary),q=o.header.withConfig({displayName:"Header",componentId:"sc-1j19fvv-2"})(["display:flex;align-items:center;margin-bottom:24px;gap:20px;"]),V=o.button.withConfig({displayName:"BackButton",componentId:"sc-1j19fvv-3"})(["display:flex;align-items:center;gap:6px;padding:8px 16px;background:transparent;color:",";border:1px solid ",";border-radius:8px;font-size:14px;cursor:pointer;transition:all 0.2s ease;white-space:nowrap;&:hover{color:",";border-color:",";}"],({theme:e})=>e.textSecondary,({theme:e})=>e.border,({theme:e})=>e.textPrimary,({theme:e})=>e.textSecondary),X=o.h1.withConfig({displayName:"StyledTitle",componentId:"sc-1j19fvv-4"})(["font-size:32px;font-weight:600;margin:0;color:",";text-align:center;flex-grow:1;"],({theme:e})=>e.textPrimary),Y=o.div.withConfig({displayName:"FilterContainer",componentId:"sc-1j19fvv-5"})(["display:flex;gap:12px;margin-bottom:32px;align-items:center;flex-wrap:wrap;"]),G=o.div.withConfig({displayName:"InputWrapper",componentId:"sc-1j19fvv-6"})(["position:relative;display:flex;align-items:center;flex-grow:1;
11min-width:200px;"]),J=o(T).withConfig({displayName:"SearchIcon",componentId:"sc-1j19fvv-7"})(["position:absolute;left:12px;color:",";width:18px;height:18px;"],({theme:e})=>e.textSecondary),K=o.input.withConfig({displayName:"StyledInput",componentId:"sc-1j19fvv-8"})(["width:100%;background:",";border:1px solid ",";border-radius:8px;padding:10px 12px 10px 40px;color:",";font-size:14px;transition:border-color 0.2s ease;&:focus{outline:none;border-color:",";}"],({theme:e})=>e.surface,({theme:e})=>e.border,({theme:e})=>e.textPrimary,({theme:e})=>e.accent);o.select.withConfig({displayName:"StyledSelect",componentId:"sc-1j19fvv-9"})(["background:",";border:1px solid ",";border-radius:8px;padding:10px 12px;color:",";font-size:14px;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;padding-right:32px;background-image:url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23888888%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');background-repeat:no-repeat;background-position:right 12px top 50%;background-size:.65em auto;&:focus{outline:none;border-color:",";}"],({theme:e})=>e.surface,({theme:e})=>e.border,({theme:e})=>e.textPrimary,({theme:e})=>e.accent);const k=o.input.withConfig({displayName:"StyledDateInput",componentId:"sc-1j19fvv-10"})(["background:",";border:1px solid ",";border-radius:8px;padding:9px 12px;color:",";font-size:14px;font-family:inherit;color-scheme:dark;&:focus{outline:none;border-color:",";}"],({theme:e})=>e.surface,({theme:e})=>e.border,({theme:e})=>e.textPrimary,({theme:e})=>e.accent),I=o.button.withConfig({displayName:"ActionButton",componentId:"sc-1j19fvv-11"})(["display:flex;align-items:center;gap:8px;padding:10px 12px;background:",";color:",";border:1px solid ",";border-radius:8px;font-size:14px;cursor:pointer;transition:all 0.2s ease;&:hover{color:",";background-color:",";}"],({theme:e})=>e.surface,({theme:e})=>e.textSecondary,({theme:e})=>e.border,({theme:e})=>e.textPrimary,({theme:e})=>e.surfaceHover);o.div.withConfig({displayName:"ProjectSection",componentId:"sc-1j19fvv-12"})(["margin-bottom:24px;"]);o.button.withConfig({displayName:"ProjectHeader",componentId:"sc-1j19fvv-13"})(["display:flex;align-items:center;width:100%;padding:14px 16px;background:",";border:1px solid ",";border-radius:8px;text-align:left;cursor:pointer;&:hover{background:",";}"],({theme:e})=>e.surface,({theme:e})=>e.border,({theme:e})=>e.surfaceHover);o.h2.withConfig({displayName:"ProjectName",componentId:"sc-1j19fvv-14"})(["margin:0;font-size:16px;font-weight:500;color:",";flex-grow:1;"],({theme:e})=>e.textPrimary);const O=o.div.withConfig({displayName:"ChatList",componentId:"sc-1j19fvv-15"})(["overflow:hidden;max-height:",";transition:max-height 0.5s ease-in-out,padding 0.5s ease-in-out;padding:",";"],e=>e.$isopen?"5000px":"0",e=>e.$isopen?"8px 0 0 0":"0"),Q=o.div.withConfig({displayName:"ChatRow",componentId:"sc-1j19fvv-16"})(["display:flex;align-items:center;padding:14px 20px;background:transparent;border-bottom:1px solid ",";cursor:pointer;transition:background-color 0.2s ease;&:first-child{border-top:1px solid ",";}&:hover{background-color:",";}&:hover > .chat-actions{opacity:1;}"],({theme:e})=>e.border,({theme:e})=>e.border,({theme:e})=>e.surface),Z=o.div.withConfig({displayName:"LoadingSpinner",componentId:"sc-1j19fvv-17"})([" border:3px solid ",";border-top:3px solid ",";border-radius:50%;width:32px;height:32px;animation:spin 1s linear infinite;margin:80px auto;@keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}"],({theme:e})=>e.border,({theme:e})=>e.accent),N=o.p.withConfig({displayName:"NoChatsMessage",componentId:"sc-1j19fvv-18"})([" text-align:center;color:",";font-size:16px;margin-top:50px;"],({theme:e})=>e.textSecondary);o.div.withConfig({displayName:"ProjectIcon",componentId:"sc-1j19fvv-19"})([" display:flex;align-items:center;justify-content:center;margin-right:14px;color:",";"],({theme:e})=>e.textSecondary);o.span.withConfig({displayName:"ChatCount",componentId:"sc-1j19fvv-20"})([" font-size:13px;font-weight:400;color:",";margin-right:16px;"],({theme:e})=>e.textSecondary);o(W).withConfig({displayName:"CollapseIcon",componentId:"sc-1j19fvv-21"})(["transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);transform:",";color:",";"],e=>e.$isopen?"rotate(180deg)":"rotate(0deg)",({theme:e})=>e.textSecondary);const ee=o.div.withConfig({displayName:"ChatInfo",componentId:"sc-1j19fvv-22"})([" flex-grow:1;min-width:0;"]),te=o.h3.withConfig({displayName:"ChatTitle",componentId:"sc-1j19fvv-23"})([" margin:0 0 6px 0;color:",";font-size:15px;font-weight:400;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"],({theme:e})=>e.textPrimary),oe=o.div.withConfig({displayName:"ChatTime",componentId:"sc-1j19fvv-24"})([" display:flex;align-items:center;color:",";font-size:13px;gap:8px;svg{width:14px;
11height:14px;}"],({theme:e})=>e.textSecondary),ne=o.div.withConfig({displayName:"ChatActions",componentId:"sc-1j19fvv-25"})([" display:flex;align-items:center;padding-left:16px;opacity:0;transition:opacity 0.2s ease;"]),re=o.button.withConfig({displayName:"DeleteButton",componentId:"sc-1j19fvv-26"})([" background:none;border:none;padding:6px;color:",";cursor:pointer;border-radius:8px;display:flex;align-items:center;justify-content:center;svg{width:16px;height:16px;}&:hover{background:rgba(236,62,62,0.1);color:rgb(236,62,62);}"],({theme:e})=>e.textSecondary),xe=()=>{const[e,f]=s.useState([]),[D,z]=s.useState(!0),[h,m]=s.useState(""),[c,u]=s.useState(""),[d,v]=s.useState(""),[x,y]=s.useState("desc"),w=F(),{supabase:g}=M();s.useEffect(()=>{(async()=>{try{const r=await j(g,"/get_all_chats",{});r!=null&&r.success?f(r.conversations||[]):console.error("Failed to load conversations:",r==null?void 0:r.error)}catch(r){console.error("Failed to load conversations:",r)}finally{z(!1)}})()},[g]);const b=s.useMemo(()=>{const n=h.trim().toLowerCase(),r=c?new Date(`${c}T00:00:00`).getTime():null,l=d?new Date(`${d}T23:59:59.999`).getTime():null;return e.filter(a=>{if(!(!n||(a.title||"").toLowerCase().includes(n)))return!1;if(!r&&!l)return!0;const i=new Date(a.created_at_iso).getTime();return!(Number.isNaN(i)||r&&i<r||l&&i>l)}).sort((a,p)=>{const i=new Date(a.created_at_iso).getTime()||0,C=new Date(p.created_at_iso).getTime()||0;return x==="desc"?C-i:i-C})},[e,h,c,d,x]),A=()=>{m(""),u(""),v(""),y("desc")},P=async(n,r)=>{if(r.stopPropagation(),!!window.confirm("Are you sure you want to permanently delete this conversation?"))try{const a=await j(g,"/delete_conversation",{chatId:n});if(!(a!=null&&a.success))throw new Error((a==null?void 0:a.error)||"Failed to delete conversation.");f(p=>p.filter(i=>i.id!==n))}catch(a){console.error("Failed to delete conversation:",a),window.alert(a.message||"Failed to delete conversation.")}};return t.jsx(U,{children:t.jsxs(R,{children:[t.jsxs(q,{children:[t.jsxs(V,{type:"button",onClick:()=>w("/chat"),children:[t.jsx(B,{size:16}),"Back"]}),t.jsx(X,{children:"All Conversations"}),t.jsx("div",{style:{width:"85.59px",flexShrink:0}})]}),t.jsxs(Y,{children:[t.jsxs(G,{children:[t.jsx(J,{}),t.jsx(K,{type:"search",placeholder:"Search conversations...",value:h,onChange:n=>m(n.target.value)})]}),t.jsx(k,{type:"date","aria-label":"Start date",value:c,onChange:n=>u(n.target.value)}),t.jsx(k,{type:"date","aria-label":"End date",value:d,onChange:n=>v(n.target.value)}),t.jsxs(I,{type:"button",onClick:()=>y(n=>n==="desc"?"asc":"desc"),children:[x==="desc"?t.jsx($,{size:16}):t.jsx(H,{size:16}),t.jsx("span",{children:"Date"})]}),t.jsxs(I,{type:"button",onClick:A,children:[t.jsx(L,{size:16}),t.jsx("span",{children:"Clear"})]})]}),D?t.jsx(Z,{}):e.length===0?t.jsx(N,{children:"You have no conversations yet."}):b.length===0?t.jsx(N,{children:"No conversations match your filters."}):t.jsx(O,{$isopen:!0,children:b.map(n=>t.jsxs(Q,{onClick:()=>w(`/chat/${n.id}`),children:[t.jsxs(ee,{children:[t.jsx(te,{children:n.title||"Untitled conversation"}),t.jsxs(oe,{children:[t.jsx(E,{size:16}),n.time]})]}),t.jsx(ne,{className:"chat-actions",children:t.jsx(re,{type:"button",title:"Delete conversation","aria-label":`Delete ${n.title||"conversation"}`,onClick:r=>P(n.id,r),children:t.jsx(_,{size:16})})})]},n.id))})]})})};export{xe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.