1import{c as B,r as x,j as e,B as N,d as p}from"./index-B9xblx1X.js";import{C as M,a as V}from"./card-CK5sTH4r.js";import{I as C}from"./input-BgkJCVH0.js";import{L as k}from"./label-pqjvqnDT.js";import{S}from"./skeleton-DfJRheVQ.js";import{D,e as G,a as I,b as E,c as F}from"./dialog-XBgjYxRF.js";import{b as H,a as $,A as W,B as q}from"./use-data-DnQuw-J8.js";import{u as _,F as J,V as K}from"./AddToCollectionDialog-k6YBsrf0.js";import{I as Q}from"./ItemCard-pen3hEki.js";import{E as X}from"./EmptyState-DUv8vX9o.js";import{P as v}from"./plus-BdXsW8q0.js";import{A as Y}from"./arrow-left-bJDptuwE.js";import{A as Z}from"./arrow-right-CCjxHTA9.js";import{G as L}from"./globe-L41XxYgC.js";import{F as A}from"./file-text-CqCzlVtS.js";import{M as ee}from"./mail-CduvjoWU.js";import"./index-CaFA2jif.js";import"./index-D45U-z8e.js";import"./Combination-R_zhYWsV.js";import"./checkbox-Bp09YZP1.js";import"./index-fou4DczH.js";import"./check-BUi6PNNz.js";import"./folder-open-DdVDU1ka.js";import"./StatusBadge-CJs5Fb83.js";import"./badge-4Ub-F2rG.js";import"./circle-check-Bam9U-dU.js";import"./triangle-alert-D0ZXp46o.js";import"./ConnectExtensionButton-6V13zcPK.js";import"./refresh-cw-Dd5mVq7Z.js";import"./puzzle-C4d1Jhky.js";import"./auto-organize-s2MOFVhk.js";import"./book-open-lG7trVMX.js";import"./external-link-BKp7hCh4.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 R=B("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function ze(){const{data:o=[],isLoading:l}=H(),{data:d=[]}=$(),c=W(),m=q(),[r,u]=x.useState(null),[f,h]=x.useState(!1),[g,i]=x.useState(!1),[t,n]=x.useState(""),[j,b]=x.useState(""),T=()=>{t.trim()&&c.mutate({name:t,description:j||void 0},{onSuccess:()=>{n(""),b(""),i(!1),p.success("Collection created")},onError:s=>{p.error("Failed to create collection",{description:s instanceof Error?s.message:"Unknown error"})}})},y=o.find(s=>s.id===r),z=r?d.filter(s=>s.collections.some(a=>a.id===r)):[],O=r?d.filter(s=>!s.collections.some(a=>a.id===r)):[];if(l)return e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto space-y-8",children:[e.jsx(S,{className:"h-8 w-40"}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((s,a)=>e.jsx(S,{className:"h-28"},a))})]});if(y&&r)return e.jsx(se,{collection:y,items:z,availableItems:O,addItemDialogOpen:f,onAddItemDialogOpenChange:h,onBack:()=>u(null)});const w=o.filter(s=>s.is_pinned),U=o.filter(s=>!s.is_pinned);return e.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-6xl animate-fade-in space-y-8 p-4 sm:p-6 lg:p-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"Collections"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o.length," collections"]})]}),e.jsxs(D,{open:g,onOpenChange:i,children:[e.jsx(G,{asChild:!0,children:e.jsxs(N,{size:"sm",className:"gap-1.5 shadow-soft font-medium",children:[e.jsx(v,{className:"h-3.5 w-3.5"})," New collection"]})}),e.jsxs(I,{className:"sm:max-w-sm",children:[e.jsx(E,{children:e.jsx(F,{children:"Create Collection"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"Name"}),e.jsx(C,{value:t,onChange:s=>n(s.target.value),placeholder:"e.g. React Resources",className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"Description (optional)"}),e.jsx(C,{value:j,onChange:s=>b(s.target.value),placeholder:"What's this collection for?",className:"h-9"})]}),e.jsx(N,{onClick:T,className:"w-full font-medium",disabled:c.isPending,children:"Create collection"})]})]})]})]}),w.length>0&&e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-widest mb-3 flex items-center gap-1.5",children:[e.jsx(R,{className:"h-3 w-3"})," Pinned"]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(s=>e.jsx(P,{collection:s,onTogglePin:()=>m.mutate({id:s.id,is_pinned:!s.is_pinned},{onError:a=>p.error("Failed to update pin",{description:a instanceof Error?a.message:"Unknown error"})}),onClick:()=>u(s.id)},s.id))})]}),e.jsxs("div",{children:[w.length>0&&e.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-widest mb-3",children:"All Collections"}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:U.map(s=>e.jsx(P,{collection:s,onTogglePin:()=>m.mutate({id:s.id,is_pinned:!s.is_pinned},{onError:a=>p.error("Failed to update pin",{description:a instanceof Error?a.message:"Unknown error"})}),onClick:()=>u(s.id)},s.id))})]})]})}function se({collection:o,items:l,availableItems:d,addItemDialogOpen:c,onAddItemDialogOpenChange:m,onBack:r}){const{removeFromCollection:u}=_(),[f,h]=x.useState(new Set),g=async i=>{h(t=>new Set(t).add(i));try{await u.mutateAsync({itemId:i,collectionId:o.id}),p.success("Removed from collection")}catch(t){p.error("Failed to remove",{description:t instanceof Error?t.message:"Unknown error"})}finally{h(t=>{const n=new Set(t);return n.delete(i),n})}};return e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto
6space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors mb-5 group",children:[e.jsx(Y,{className:"h-4 w-4 group-hover:-translate-x-0.5 transition-transform"})," Collections"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-accent flex items-center justify-center text-lg",children:o.icon||"ð"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:o.description})]})]}),e.jsxs(N,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>m(!0),children:[e.jsx(v,{className:"h-3.5 w-3.5"})," Add items"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:[l.length," items"]})]}),l.length>0?e.jsx("div",{className:"space-y-2",children:l.map(i=>e.jsx(Q,{item:i,variant:"list",onRemoveFromCollection:()=>void g(i.id),removingFromCollection:f.has(i.id)},i.id))}):e.jsx(X,{icon:J,title:"No items yet",description:"Add items to this collection from your library or using the button above.",action:e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[e.jsx(v,{className:"h-3.5 w-3.5 mr-1.5"})," Add items"]}),className:"py-16"}),e.jsx(oe,{open:c,onOpenChange:m,collectionId:o.id,availableItems:d})]})}function P({collection:o,onTogglePin:l,onClick:d}){return e.jsxs(M,{className:"group relative min-w-0 overflow-hidden border-border/60 shadow-soft hover:shadow-medium transition-all duration-300",children:[e.jsx("button",{type:"button",onClick:d,className:"absolute inset-0 z-0 rounded-[inherit] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open collection ${o.name}`}),e.jsxs(V,{className:"p-5 relative z-10 pointer-events-none",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 shrink-0 rounded-xl bg-accent flex items-center justify-center text-lg",children:o.icon||"ð"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:o.name}),o.description&&e.jsx("p",{className:"mt-0.5 line-clamp-1 text-2xs text-muted-foreground",children:o.description})]})]}),e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),l()},className:"pointer-events-auto p-1 rounded-md hover:bg-accent transition-colors","aria-label":o.is_pinned?"Unpin collection":"Pin collection",children:e.jsx(R,{className:`h-3.5 w-3.5 transition-colors ${o.is_pinned?"text-primary fill-primary":"text-muted-foreground group-hover:text-foreground"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-3 border-t border-border/40",children:[e.jsxs("span",{className:"text-2xs text-muted-foreground font-medium",children:[o.item_count," items"]}),e.jsx(Z,{className:"h-3.5 w-3.5 text-muted-foreground group-hover:text-foreground transition-all group-hover:translate-x-0.5"})]})]})]})}const te={webpage:L,pdf:A,video:K,newsletter:ee,article:A};function oe({open:o,onOpenChange:l,collectionId:d,availableItems:c}){const{addToCollection:m}=_(),[r,u]=x.useState(""),[f,h]=x.useState(new Set),g=c.filter(t=>t.title.toLowerCase().includes(r.toLowerCase())||t.source_domain.toLowerCase().includes(r.toLowerCase())),i=async t=>{h(n=>new Set(n).add(t));try{await m.mutateAsync({itemId:t,collectionId:d}),p.success("Added to collection")}catch(n){p.error("Failed",{description:n instanceof Error?n.message:"Unknown error"})}finally{h(n=>{const j=new Set(n);return j.delete(t),j})}};return e.jsx(D,{open:o,onOpenChange:l,children:e.jsxs(I,{className:"sm:max-w-md",children:[e.jsx(E,{children:e.jsx(F,{children:"Add Items to Collection"})}),e.jsx(C,{placeholder:"Search items...",value:r,onChange:t=>u(t.target.value),className:"h-9"}),e.jsxs("div",{className:"space-y-1 max-h-72 overflow-y-auto",children:[g.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:c.length===0?"All items are already in this collection.":"No matching items."}),g.map(t=>{const n=te[t.type]||L;return e.jsxs("button",{onClick:()=>void i(t.id),disabled:f.has(t.id),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg hover:bg-accent/60 transition-colors text-left disabled:opacity-50",children:[e.jsx(n,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title}),e.jsx("p",{className:"truncate text-2xs text-muted-foreground",children:t.source_domain})]}),e.jsx(v,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},t.id)})]})]})})}export{ze 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.