1import{c as y,j as s}from"./index-B9xblx1X.js";import{C as l,b as n,c as r,a as o}from"./card-CK5sTH4r.js";import{S as b}from"./skeleton-DfJRheVQ.js";import{a as D}from"./use-data-DnQuw-J8.js";import{E as z}from"./EmptyState-DUv8vX9o.js";import{C as T}from"./chart-column-B6r1YfpP.js";import{R as c,B as f,X as j,Y as u,T as d,a as g,C as A}from"./BarChart-tFXqlJI2.js";import{P as K,a as R}from"./PieChart-BhkrGhaI.js";import{G as I}from"./globe-L41XxYgC.js";/** 2 * @license lucide-react v0.462.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 M=y("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** 7 * @license lucide-react v0.462.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 O=y("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const P=y("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),m=["hsl(234, 62%, 52%)","hsl(152, 58%, 38%)","hsl(38, 92%, 50%)","hsl(0, 72%, 51%)","hsl(205, 78%, 50%)"],x={contentStyle:{borderRadius:"8px",border:"1px solid hsl(220, 13%, 91%)",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.04)",fontSize:"12px",fontFamily:"Inter, sans-serif"}};function W(){const{data:t=[],isLoading:w}=D();if(w)return s.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto space-y-6",children:[s.jsx(b,{className:"h-8 w-32"}),s.jsx("div",{className:"grid lg:grid-cols-2 gap-5",children:[...Array(4)].map((e,a)=>s.jsx(b,{className:"h-72"},a))})]});if(t.length===0)return s.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto",children:[s.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:"Analytics"}),s.jsx(z,{icon:T,title:"No data yet",description:"Start saving items to see analytics about your archive."})]});const k=t.reduce((e,a)=>{const i=new Date(a.saved_at).toLocaleDateString("en-US",{month:"short",day:"numeric"});return e[i]=(e[i]||0)+1,e},{}),C=Object.entries(k).map(([e,a])=>({date:e,count:a})).slice(-10),h=new Map;for(const e of t)for(const a of e.tags){const i=h.get(a.id);i?i.count+=1:h.set(a.id,{name:a.name,count:1})}const N=[...h.values()].sort((e,a)=>a.count-e.count).slice(0,8).map(e=>({name:e.name,count:e.count})),v=t.reduce((e,a)=>(e[a.source_domain]=(e[a.source_domain]||0)+1,e),{}),S=Object.entries(v).sort((e,a)=>a[1]-e[1]).slice(0,6).map(([e,a])=>({domain:e,count:a})),L=t.reduce((e,a)=>(e[a.type]=(e[a.type]||0)+1,e),{}),p=Object.entries(L).map(([e,a])=>({name:e,value:a}));return s.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto space-y-6 animate-fade-in",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"Analytics"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Insights into your archive activity"})]}),s.jsxs("div",{className:"grid lg:grid-cols-2 gap-5",children:[s.jsxs(l,{className:"border-border/60 shadow-soft",children:[s.jsx(n,{className:"pb-2",children:s.jsxs(r,{className:"text-sm font-semibold flex items-center gap-2",children:[s.jsx(P,{className:"h-4 w-4 text-primary"})," Items Saved Over Time"]})}),s.jsx(o,{className:"pt-2",children:s.jsx(c,{width:"100%",height:240,children:s.jsxs(f,{data:C,children:[s.jsx(j,{dataKey:"date",tick:{fontSize:10,fill:"hsl(220, 10%, 46%)"},axisLine:!1,tickLine:!1}),s.jsx(u,{tick:{fontSize:10,fill:"hsl(220, 10%, 46%)"}
16,allowDecimals:!1,axisLine:!1,tickLine:!1}),s.jsx(d,{...x}),s.jsx(g,{dataKey:"count",fill:"hsl(234, 62%, 52%)",radius:[6,6,0,0]})]})})})]}),s.jsxs(l,{className:"border-border/60 shadow-soft",children:[s.jsx(n,{className:"pb-2",children:s.jsxs(r,{className:"text-sm font-semibold flex items-center gap-2",children:[s.jsx(M,{className:"h-4 w-4 text-primary"})," Media Type Distribution"]})}),s.jsxs(o,{className:"flex flex-col items-center gap-3 pt-2",children:[s.jsx(c,{width:"100%",height:200,children:s.jsxs(K,{children:[s.jsx(R,{data:p,cx:"50%",cy:"50%",outerRadius:80,innerRadius:40,dataKey:"value",strokeWidth:2,stroke:"hsl(0, 0%, 100%)",children:p.map((e,a)=>s.jsx(A,{fill:m[a%m.length]},a))}),s.jsx(d,{...x,formatter:(e,a)=>[`${e}`,a]})]})}),s.jsx("ul",{className:"flex flex-wrap justify-center gap-x-4 gap-y-1.5 px-1",children:p.map((e,a)=>s.jsxs("li",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:m[a%m.length]}}),s.jsx("span",{className:"capitalize text-foreground",children:e.name}),s.jsxs("span",{children:["(",e.value,")"]})]},e.name))})]})]}),N.length>0&&s.jsxs(l,{className:"border-border/60 shadow-soft",children:[s.jsx(n,{className:"pb-2",children:s.jsxs(r,{className:"text-sm font-semibold flex items-center gap-2",children:[s.jsx(O,{className:"h-4 w-4 text-success"})," Most Used Tags"]})}),s.jsx(o,{className:"pt-2",children:s.jsx(c,{width:"100%",height:240,children:s.jsxs(f,{data:N,layout:"vertical",children:[s.jsx(j,{type:"number",tick:{fontSize:10,fill:"hsl(220, 10%, 46%)"},allowDecimals:!1,axisLine:!1,tickLine:!1}),s.jsx(u,{type:"category",dataKey:"name",tick:{fontSize:11,fill:"hsl(220, 10%, 46%)"},width:80,axisLine:!1,tickLine:!1}),s.jsx(d,{...x}),s.jsx(g,{dataKey:"count",fill:"hsl(152, 58%, 38%)",radius:[0,6,6,0]})]})})})]}),s.jsxs(l,{className:"border-border/60 shadow-soft",children:[s.jsx(n,{className:"pb-2",children:s.jsxs(r,{className:"text-sm font-semibold flex items-center gap-2",children:[s.jsx(I,{className:"h-4 w-4 text-warning"})," Top Source Domains"]})}),s.jsx(o,{className:"pt-2",children:s.jsx(c,{width:"100%",height:240,children:s.jsxs(f,{data:S,layout:"vertical",children:[s.jsx(j,{type:"number",tick:{fontSize:10,fill:"hsl(220, 10%, 46%)"},allowDecimals:!1,axisLine:!1,tickLine:!1}),s.jsx(u,{type:"category",dataKey:"domain",tick:{fontSize:10,fill:"hsl(220, 10%, 46%)"},width:130,axisLine:!1,tickLine:!1}),s.jsx(d,{...x}),s.jsx(g,{dataKey:"count",fill:"hsl(38, 92%, 50%)",radius:[0,6,6,0]})]})})})]})]})]})}export{W 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.