// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ft as t,li as n,qi as r}from"./lucide-icons-BdRF0moN.js";import{t as i}from"./jsx-runtime-By8HlURe.js";import{r as a}from"./react-intl-eZirkCBg.js";import{t as o}from"./utils-BFSTDHdM.js";import{a as s,c,n as l,t as u}from"./dialog-C3CFmras.js";import{t as d}from"./scroll-area-D2CmkWvj.js";import{it as f,rt as p,st as m}from"./index-CYEZWNq6.js";var h=e(r(),1),g=i();function _({open:e,onOpenChange:r,currentWidgets:i,onAdd:_,onRemove:v}){let y=(0,h.useMemo)(()=>new Set(i.map(e=>e.id)),[i]),b=(0,h.useMemo)(()=>{let e={};for(let t of f)(e[t.category]??=[]).push(t);return e},[]);return(0,g.jsx)(u,{open:e,onOpenChange:r,children:(0,g.jsxs)(l,{className:`max-w-md`,children:[(0,g.jsx)(s,{children:(0,g.jsx)(c,{children:(0,g.jsx)(a,{id:`widgets.picker.title`,defaultMessage:`Add Widget`})})}),(0,g.jsx)(d,{className:`max-h-[60vh]`,children:(0,g.jsx)(`div`,{className:`space-y-5 pr-2`,children:Object.entries(b).map(([e,r])=>(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-1`,children:(0,g.jsx)(a,{id:`widgets.categories.${e}`,defaultMessage:p[e]??e})}),(0,g.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>{let r=y.has(e.id),i=e.icon;return(0,g.jsxs)(`button`,{onClick:()=>{r?v(e.id):_(e.id)},className:o(`flex items-center gap-3 w-full px-3 py-2.5 rounded-xl transition-colors text-left`,r?`bg-primary/10 hover:bg-primary/15`:`hover:bg-secondary/60`),children:[(0,g.jsx)(`div`,{className:o(`size-9 rounded-lg flex items-center justify-center shrink-0`,r?`bg-primary/20 text-primary`:`bg-secondary text-muted-foreground`),children:(0,g.jsx)(i,{className:`size-4`})}),(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`div`,{className:`text-sm font-medium`,children:(0,g.jsx)(a,{id:`widgets.${m(e.id)}.title`,defaultMessage:e.label})}),(0,g.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:(0,g.jsx)(a,{id:`widgets.${m(e.id)}.description`,defaultMessage:e.description})})]}),(0,g.jsx)(`div`,{className:o(`size-6 rounded-full flex items-center justify-center shrink-0 transition-colors`,r?`bg-primary text-primary-foreground`:`border border-border text-muted-foreground/50`),children:r?(0,g.jsx)(n,{className:`size-3.5`}):(0,g.jsx)(t,{className:`size-3.5`})})]},e.id)})})]},e))})})]})})}export{_ as WidgetPickerDialog};
// @license-end
