1import{k as M,u as W,l as X,r as n,j as e,m as F,P as q,S as Z,e as ee,n as se,N as te,o as ae,p as ne,q as ie,f as re,s as ce,t as le,v as oe,M as de,F as xe,w as me,d as ue,G as he}from"./index-2LA4JAv8.js";import{F as G}from"./folder-kanban-D6SwEeiB.js";import{B as pe}from"./brain-B0gxC0Xn.js";const fe=["all","brand","prospect","personal"],be=["all","private","office","organization"];function ve(){const{t}=M(["projects","common"]),o=W(),[d,f]=X(),[b,i]=n.useState([]),[g,j]=n.useState(!0),[w,u]=n.useState(null),[C,L]=n.useState(""),[N,R]=n.useState("all"),[y,E]=n.useState("all"),[m,D]=n.useState(!1),[v,z]=n.useState(null),[h,P]=n.useState(null),[p,U]=n.useState(null),[Q,O]=n.useState(!1),[Y,A]=n.useState(!1),[H,B]=n.useState(!1),T=d.get("project");n.useEffect(()=>{let s=!1;return(async()=>{var c,x;j(!0),u(null);try{const r=await ae({is_archived:m,limit:100,offset:0});s||i(r.items||[])}catch(r){s||(i([]),u(((x=(c=r==null?void 0:r.response)==null?void 0:c.data)==null?void 0:x.detail)||(r==null?void 0:r.message)||t("page.loadFailed")))}finally{s||j(!1)}})(),()=>{s=!0}},[m,t]),n.useEffect(()=>{if(!T)return;let s=!1;return(async()=>{B(!0);try{const c=await ne(T);s||(P(c),z(c.id))}catch{}finally{if(s)return;B(!1);const c=new URLSearchParams(d);c.delete("project"),f(c,{replace:!0})}})(),()=>{s=!0}},[T,d,f]);const l=n.useMemo(()=>{const s=[...b];return h&&m===!!h.is_archived&&!s.some(a=>a.id===h.id)&&s.unshift(h),s},[b,h,m]),V=n.useMemo(()=>{const s=C.trim().toLowerCase();return l.filter(a=>{var x,r,$;return N!=="all"&&a.type!==N||y!=="all"&&a.visibility!==y?!1:s?[a.name,a.description||"",((x=a.brand)==null?void 0:x.name)||"",a.client_name||"",((r=a.creator)==null?void 0:r.name)||"",(($=a.creator)==null?void 0:$.email)||""].join(" ").toLowerCase().includes(s):!0})},[l,C,N,y]),S=n.useMemo(()=>({all:l.length,brand:l.filter(s=>s.type==="brand").length,prospect:l.filter(s=>s.type==="prospect").length,personal:l.filter(s=>s.type==="personal").length}),[l]),k=n.useMemo(()=>{if(v){const s=l.find(a=>a.id===v);if(s)return s}return null},[l,v]),K=n.useMemo(()=>k?`/enable/ai-tools?${new URLSearchParams({project:k.id}).toString()}`:"/enable/ai-tools",[k]),J=s=>{const a=new URLSearchParams({project:s.id});o(`/enable/ai-tools?${a.toString()}`)};return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 px-5 pb-5",children:[e.jsxs("div",{className:"h-14 flex items-center justify-between border-b border-zinc-800/50 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 bg-accent/15 rounded-lg flex items-center justify-center",children:e.jsx(G,{className:"w-4.5 h-4.5 text-accent"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-semibold text-white",children:t("page.title")}),e.jsx("p",{className:"text-[13px] text-zinc-500",children:t("page.subtitle")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>o(K),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-accent/40 bg-accent/10 text-[11px] text-accent hover:bg-accent/15 transition-colors whitespace-nowrap",children:[t(k?"page.openSelectedInAiToolbox":"page.openAiToolbox"),e.jsx(F,{className:"w-3.5 h-3.5 shrink-0"})]}),e.jsxs("button",{type:"button",onClick:()=>A(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-zinc-700 text-[11px] text-zinc-300 hover:bg-zinc-800/70 transition-colors whitespace-nowrap",children:[e.jsx(q,{className:"w-3.5 h-3.5 shrink-0"}),t("page.newProject")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-500"}),e.jsx("input",{type:"text",value:C,onChange:s=>L(s.target.value),placeholder:t("page.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2.5 bg-surface-2 border border-zinc-800/50 rounded-lg text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-accent/40"})]}),e.jsx("select",{value:N,onChange:s=>R(s.target.value),className:"px-4 py-2.5 bg-surface-2 border border-zinc-800/50 rounded-lg text-sm text-zinc-300 focus:outline-none focus:border-accent/40 min-w-[140px]",children:fe.map(s=>e.jsx("option",{value:s,children:t(s==="all"?"filters.allTypes":`type.${s}`)},s))}),e.jsx("select",{value:y,onChange:s=>E(s.target.value),className:"px-4 py-2.5 bg-surface-2 border border-zinc-800/50 rounded-lg text-sm text-zinc-300 focus:outline-none focus:border-accent/40 min-w-[150px]",children:be.map(s=>e.jsx("option",{value:s,children:t(s==="all"?"filters.allVisibility":`visibility.${s}`)},s))}),e.jsxs("label",{className:"inline-flex items-center gap-2 px-3 py-2.5 bg-surface-2 border border-zinc-800/50 rounded-lg text-sm text-zinc-400 cursor-pointer whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:s=>D(s.target.checked),className:"accent-accent shrink-0"}),t("page.showArchived")]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mb-5",children:[e.jsx(I,{label:t("common:labels.all"),value:S.all}),e.jsx(I,{label:t("type.brand"),value:S.brand}),e.jsx(I,{label:t("type.prospect"),value:S.prospect}),e.jsx(I,{label:t("type.personal"),value:S.personal})]}),g||H?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(ee,{className:"w-5 h-5 text-zinc-500 animate-spin"})}):w?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"max-w-md rounded-lg border border-red-500/30 bg-red-500/10 p-4 text-sm text-red-200",children:w})}):V.length===0?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-zinc-800/50 rounded-full flex items-center justify-center mb-4",children:e.jsx(G,{className:"w-8 h-8 text-zinc-600"})}),e.jsx("h3",{className:"text-sm font-medium text-zinc-300 mb-2",children:l.length===0?t("page.emptyTitle"):t("page.noMatchTitle")}),e.jsx("p",{className:"text-sm text-zinc-500 max-w-sm mb-4",children:l.length===0?t("page.emptyDescription"):t("page.noMatchDescription")}),e.jsx("button",{type:"button",onClick:()=>
1{if(l.length===0){A(!0);return}L(""),R("all"),E("all")},className:"flex items-center gap-2 px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 rounded text-sm transition-colors",children:l.length===0?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3.5 h-3.5 shrink-0"}),t("page.createProject")]}):t("page.resetFilters")})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:V.map(s=>e.jsx(je,{project:s,active:v===s.id,onSelect:()=>z(s.id),onOpenDetails:()=>{U(s.id),O(!0)},onOpenInAiTools:()=>J(s)},s.id))}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsxs("button",{type:"button",onClick:()=>o("/enable/ai-tools"),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-zinc-700 text-[11px] text-zinc-300 hover:bg-zinc-800/70 transition-colors whitespace-nowrap",children:[t("page.openAiToolbox"),e.jsx(F,{className:"w-3.5 h-3.5 shrink-0"})]})}),e.jsx(se,{projectId:p,isOpen:Q,onClose:()=>{O(!1),U(null)},onChanged:s=>{if(s){i(a=>{const c=!!s.is_archived===m,x=a.some(r=>r.id===s.id)?a.map(r=>r.id===s.id?s:r):[s,...a];return c?x:x.filter(r=>r.id!==s.id)}),P(a=>(a==null?void 0:a.id)===s.id?s:a);return}p&&(i(a=>a.filter(c=>c.id!==p)),P(a=>(a==null?void 0:a.id)===p?null:a),z(a=>a===p?null:a))}}),e.jsx(te,{isOpen:Y,onClose:()=>A(!1),onCreated:s=>{D(!1),i(a=>[s,...a.filter(c=>c.id!==s.id)]),P(null),z(s.id)}})]})}function I({label:t,value:o}){return e.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/70 p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500 truncate",children:t}),e.jsx("div",{className:"mt-1 text-sm font-medium text-zinc-100",children:o})]})}function _({icon:t,label:o,value:d}){return e.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/70 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-zinc-500 uppercase tracking-wider",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"truncate",children:o})]}),e.jsx("div",{className:"mt-1 text-xs font-medium text-zinc-100",children:d})]})}function ge({visibility:t}){const{t:o}=M("projects"),d=o(`visibility.${t}`);return t==="private"?e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx(me,{className:"w-3 h-3 shrink-0"}),d]}):t==="office"?e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx(ue,{className:"w-3 h-3 shrink-0"}),d]}):e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx(he,{className:"w-3 h-3 shrink-0"}),d]})}function je({project:t,active:o,onSelect:d,onOpenDetails:f,onOpenInAiTools:b}){var u;const{t:i}=M("projects"),g=t.last_activity_at||t.updated_at||t.created_at,j=t.type==="brand"?((u=t.brand)==null?void 0:u.name)||i("scope.brand"):t.type==="prospect"?t.client_name||i("scope.prospect"):i("scope.personal"),w=g?ie(g):"";return e.jsxs("div",{className:re("rounded-lg border bg-surface-2 p-4 transition-all",o?"border-accent/45 bg-accent/5":"border-zinc-800/60 hover:border-zinc-700"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("button",{type:"button",onClick:d,className:"text-left min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-100 truncate",children:t.name}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-zinc-500",children:[e.jsx(ge,{visibility:t.visibility}),e.jsx("span",{children:"â¢"}),e.jsx("span",{className:"whitespace-nowrap",children:i(`type.${t.type}`)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{className:"truncate",children:j})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.is_pinned&&e.jsx(ce,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400"}),t.is_archived&&e.jsx(le,{className:"w-3.5 h-3.5 text-zinc-500"}),e.jsx("button",{type:"button",onClick:f,className:"inline-flex items-center justify-center w-7 h-7 rounded border border-zinc-700 text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/70 transition-colors",title:i("card.settings"),"aria-label":i("card.settings"),children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]}),e.jsx("p",{className:"mt-3 text-xs leading-5 text-zinc-400 line-clamp-3",children:t.description||i("card.noDescription")}),e.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[e.jsx(_,{icon:e.jsx(de,{className:"w-3 h-3"}),label:i("card.chats"),value:t.session_count}),e.jsx(_,{icon:e.jsx(pe,{className:"w-3 h-3"}),label:i("card.memory"),value:t.memory_count}),e.jsx(_,{icon:e.jsx(xe,{className:"w-3 h-3"}),label:i("card.knowledge"),value:t.knowledge_count})]}),e.jsxs("div",{className:"mt-3 pt-2 border-t border-zinc-800/60 flex items-center justify-between",children:[e.jsx("div",{className:"text-[10px] text-zinc-500",children:w||i("card.noActivity")}),e.jsxs("button",{type:"button",onClick:b,className:"inline-flex items-center gap-1 text-[11px] text-accent hover:text-accent/80 transition-colors whitespace-nowrap",children:[i("card.openInAiToolbox"),e.jsx(F,{className:"w-3 h-3 shrink-0"})]})]})]})}export{ve 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.