import{a as v,f as u,s as C}from"../chunks/BeONA6_G.js";import{p as de,a as m,b as ve,o as fe,d as ue,e as he,g as n,h as s,i as pe,$ as ge,c as r,s as f,f as N,n as me,r as a,u as O,t as _e}from"../chunks/tjbnEgXP.js";import{i as T}from"../chunks/Ona8oofC.js";import{h as ye,B as k,I as Ce,e as B,i as Se,P as xe,s as be}from"../chunks/DREFAyhX.js";import{g as Ie}from"../chunks/CHvUpVYv.js";import{g as Pe,s as je,S as $e}from"../chunks/CbqC9BW7.js";import{i as ke}from"../chunks/DSU1n5N_.js";import{E as z}from"../chunks/CojFyTPp.js";import"../chunks/ClK4wZbC.js";import{f as Me}from"../chunks/CGLrx-H5.js";var we=u('<meta name="description" content="Claude Code sessions across all projects"/>'),Ae=u("<!> Refresh",1),Ee=u('<div class="loading-container"></div>'),Le=u('<a class="session-card"><div class="session-card-header"><div><h3 class="session-card-title"> </h3> <div class="session-card-subtitle"> </div></div> <!></div> <div class="session-stats"><span><strong> </strong> </span></div></a>'),Re=u('<div style="text-align: center; padding: 1rem;"><!></div>'),Ke=u('<div class="projects-container svelte-1uha8ag"></div> <!>',1),Ne=u('<main class="main"><div class="page-header svelte-1uha8ag"><div class="page-header-content svelte-1uha8ag"><div><h1 class="page-title svelte-1uha8ag">Projects</h1> <p class="page-description svelte-1uha8ag">Claude Code sessions across all projects</p></div> <div class="page-actions svelte-1uha8ag"><!></div></div></div> <!></main>');function Ze(J,q){de(q,!0);const D=3e4,F=20;let i=m(ve([])),h=m(!1),S=!1,p=m(null),_=null,M=m(!1),w=m(0);fe(()=>{G();const e=Pe("shooter_projects");e&&(n(i,e,!0),n(h,!1)),y(),_=setInterval(()=>{s(p)?.apiKey&&y()},D)}),ue(()=>{_&&(clearInterval(_),_=null)});function G(){try{const e=localStorage.getItem("shooter_config");if(e){const t=JSON.parse(e);ke(t)?n(p,t,!0):(localStorage.removeItem("shooter_config"),n(p,null))}}catch{}}async function y(e=!1){if(!s(p)?.apiKey||S)return;S=!0,s(i).length===0&&n(h,!0);const t=e?s(w):0;try{const o=await fetch(`/api/sessions?limit=${F}&offset=${t}`,{headers:{Authorization:`Bearer ${s(p).apiKey}`}});if(!o.ok)return;const c=await o.json();e?n(i,[...s(i),...c.projects],!0):n(i,c.projects,!0),n(w,s(i).length,!0),n(M,c.total!==void 0?s(i).length<c.total:!1,!0),je("shooter_projects",s(i))}catch(o){console.error("Failed to fetch sessions:",o)}finally{n(h,!1),S=!1}}async function V(){await y(!0)}async function Z(){n(h,!0),sessionStorage.removeItem("shooter_projects"),await y()}function H(){Ie("/config")}function Q(){return s(i).reduce((e,t)=>e+t.sessionCount,0)}var x=Ne();ye("1uha8ag",e=>{var t=we();pe(()=>{ge.title="Projects - Shooter"}),v(e,t)});var b=r(x),A=r(b),E=f(r(A),2),U=r(E);k(U,{classes:"btn-secondary",onclick:Z,get disabled(){return s(h)},children:(e,t)=>{var o=Ae(),c=N(o);Ce(c,{name:"refresh",size:14}),me(),v(e,o)},$$slots:{default:!0}}),a(E),a(A),a(b);var W=f(b,2);{var X=e=>{var t=Ee();B(t,20,()=>Array(5),Se,(o,c)=>{$e(o,{classes:"shimmer-card"})}),a(t),v(e,t)},Y=e=>{z(e,{icon:"settings",title:"Configuration Required",description:"Set up your API credentials to start tracking sessions",children:(t,o)=>{k(t,{classes:"btn-primary",onclick:H,text:"Configure Settings"})}})},ee=e=>{z(e,{icon:"bell",title:"No sessions yet",description:"Claude Code sessions will appear here once JSONL files are found"})},se=O(()=>Q()===0),te=e=>{var t=Ke(),o=N(t);B(o,21,()=>s(i),d=>d.id,(d,l)=>{var g=Le(),I=r(g),P=r(I),j=r(P),oe=r(j,!0);a(j);var L=f(j,2),re=r(L,!0);a(L),a(P);var ie=f(P,2);{let ce=O(()=>Me(s(l).lastModified));xe(ie,{get text(){return s(ce)},classes:"pill-session-time"})}a(I);var R=f(I,2),K=r(R),$=r(K),ne=r($,!0);a($);var le=f($);a(K),a(R),a(g),_e(()=>{be(g,"href",`/project?id=${s(l).id??""}`),C(oe,s(l).name),C(re,s(l).fullPath),C(ne,s(l).sessionCount),C(le,` ${s(l).sessionCount===1?"session":"sessions"}`)}),v(d,g)}),a(o);var c=f(o,2);{var ae=d=>{var l=Re(),g=r(l);k(g,{classes:"btn-secondary",onclick:V,text:"Load More"}),a(l),v(d,l)};T(c,d=>{s(M)&&d(ae)})}v(e,t)};T(W,e=>{s(h)&&s(i).length===0?e(X):s(p)?.apiKey?s(se)?e(ee,2):e(te,-1):e(Y,1)})}a(x),v(J,x),he()}export{Ze as component};
