// @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 const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmojiPicker-DIvGQUn_.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BdRF0moN.js","assets/jsx-runtime-By8HlURe.js","assets/useTheme-B8n3R7ig.js","assets/useQuery-rCAlChE8.js","assets/useAppContext-Ughdk2-Z.js","assets/useEncryptedSettings-DPGHcvzd.js","assets/dist-DQ82bf9M.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useMutation-CgsR0O-3.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-C6OJJlWo.js","assets/preload-helper-CZgWQFsJ.js","assets/dist-DQ_zK-Nr.js","assets/fontLoader-C8ZADbrS.js","assets/sanitizeUrl-Bk5f35GN.js","assets/useNostrPublish-CrMjnYm4.js","assets/useIsMobile-B6g4lnSy.js","assets/native-GDBYL4Zp.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,F as n,Ft as r,Ni as i,a,ci as o,et as s,jn as c,qi as l,ti as u}from"./lucide-icons-BdRF0moN.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{t as f}from"./preload-helper-CZgWQFsJ.js";import{u as p}from"./esm-CRVqHnq2.js";import{r as ee}from"./sanitizeUrl-Bk5f35GN.js";import{t as m}from"./useCurrentUser-C6OJJlWo.js";import{t as h}from"./utils-BFSTDHdM.js";import{t as g}from"./button-Cs26nq0r.js";import{a as te,c as ne,l as re,n as _,r as v,t as y,u as b}from"./avatar--oX_CTF4.js";import{n as x}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{S,i as ie,o as C,t as w,x as ae,y as T}from"./BioContent-BjUPDB1O.js";import{t as oe}from"./FallbackImage-Dlnc8809.js";import{t as se}from"./ExternalFavicon-BWUhHW7H.js";import{t as E}from"./input-CM5Fnyvy.js";import{n as ce,r as le,t as ue}from"./collapsible-C12_mOsk.js";import{a as de,n as fe,r as D,t as pe}from"./dropdown-menu-ug3FLSAW.js";import{n as me,r as he,t as ge}from"./popover-Dw5E1auH.js";import{t as O}from"./skeleton-CVls4GW9.js";var k=e(l(),1),A=d();function j({items:e,maxVisible:n=12,thumbnailSize:r=48,showNames:a=!0,showEditButton:o,editPath:s=`/badges`,isLoading:c,gridCols:l=`grid-cols-4 sm:grid-cols-6`,className:u}){if(c)return(0,A.jsx)(`div`,{className:h(`grid gap-3`,l,u),children:Array.from({length:4}).map((e,t)=>(0,A.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,A.jsx)(O,{className:`rounded-lg`,style:{width:r,height:r}}),a&&(0,A.jsx)(O,{className:`h-3 w-12`})]},t))});if(e.length===0)return null;let d=e.slice(0,n),f=Math.max(0,e.length-n);return(0,A.jsxs)(`div`,{className:h(`space-y-2`,u),children:[(0,A.jsxs)(`div`,{className:h(`grid gap-3`,l),children:[d.map(e=>(0,A.jsxs)(x,{to:`/${p.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`,className:`flex flex-col items-center gap-1.5 group`,title:e.badge?.description||e.badge?.name||e.identifier,onClick:e=>e.stopPropagation(),children:[e.badge?(0,A.jsx)(T,{badge:e.badge,size:r}):(0,A.jsx)(`div`,{className:`rounded-lg border border-border bg-background flex items-center justify-center`,style:{width:r,height:r},children:(0,A.jsx)(i,{className:`size-6 text-muted-foreground`})}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground text-center leading-tight line-clamp-2 max-w-[4.5rem] group-hover:text-foreground transition-colors`,children:e.badge?.name||e.identifier})]},e.aTag)),f>0&&(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-1.5`,children:(0,A.jsxs)(`div`,{className:`rounded-lg bg-muted flex items-center justify-center text-muted-foreground text-xs font-medium`,style:{width:r,height:r},children:[`+`,f]})})]}),o&&s&&(0,A.jsx)(`div`,{className:`flex justify-end`,children:(0,A.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1 text-muted-foreground`,asChild:!0,children:(0,A.jsxs)(x,{to:s,children:[(0,A.jsx)(t,{className:`size-3`}),`Edit Badges`]})})})]})}var M=(0,k.lazy)(()=>f(()=>import(`./EmojiPicker-DIvGQUn_.js`).then(e=>({default:e.EmojiPicker})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))),N=[`rounded-lg px-2`,`border-2 border-transparent`,`bg-muted/40`,`hover:bg-muted/60 hover:border-border`,`focus:bg-transparent focus:border-primary`,`transition-colors duration-150`,`placeholder:text-muted-foreground/40`,`outline-none`].join(` `);function P({value:e,placeholder:t,onChange:n,className:r}){return(0,A.jsx)(`input`,{type:`text`,value:e,placeholder:t,onChange:e=>n(e.target.value),className:h(N,`w-full min-w-0 py-0.5`,r)})}function F({value:e,placeholder:t,onChange:n,className:r}){return(0,A.jsx)(`textarea`,{value:e,placeholder:t,onChange:e=>{n(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onFocus:e=>{e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},rows:1,className:h(N,`w-full min-w-0 py-1 resize-none overflow-hidden text-base md:text-sm text-muted-foreground leading-relaxed`,r)})}function I({pubkey:e,metadata:i,onChange:l,onPickImage:d,onAvatarShape:f,onRemoveAvatar:p,showNip05:x=!0,extraFields:T,onExtraFieldsChange:O}){let I=!!l,[L,R]=(0,k.useState)(!1),[_e,ve]=(0,k.useState)(!1),[ye,z]=(0,k.useState)(!1),{user:B}=m(),be=!!e&&!!B&&e===B.pubkey,{refs:V,isLoading:H}=C(e),{badgeMap:xe,isLoading:Se}=ie(V),U=i.name||i.display_name||`Anonymous`,W=U[0]?.toUpperCase()??`?`,G=e=>t=>l?.({[e]:t}),Ce=ee(i.banner),K=i.shape,q=re(K)?K:void 0,J=!!q&&ne(q),[Y,X]=(0,k.useState)(``);(0,k.useEffect)(()=>{if(!J||!q){X(``);return}let e=!1;return te(q).then(t=>{e||X(t)}),()=>{e=!0}},[J,q]);let we=(0,k.useMemo)(()=>{if(Y)return{WebkitMaskImage:`url(${Y})`,maskImage:`url(${Y})`,WebkitMaskSize:`contain`,maskSize:`contain`,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,WebkitMaskPosition:`center`,maskPosition:`center`}},[Y]),Z=i.nip05,Q=Z?S(Z):void 0,Te=()=>O?.([...T??[],{label:``,value:``}]),Ee=e=>O?.((T??[]).filter((t,n)=>n!==e)),$=(e,t,n)=>O?.((T??[]).map((r,i)=>i===e?{...r,[t]:n}:r));return(0,A.jsxs)(`div`,{className:`bg-card border rounded-xl overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:h(`relative h-36 bg-secondary`,I&&`cursor-pointer group`),onClick:()=>I&&d?.(`banner`),children:[(0,A.jsx)(oe,{src:Ce,className:`absolute inset-0 size-full object-cover`}),!i.banner&&(0,A.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-accent/10 via-transparent to-primary/5`}),I&&!i.banner&&(0,A.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,A.jsx)(r,{className:`size-6 text-muted-foreground`,strokeWidth:4})}),I&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center`,children:(0,A.jsxs)(`span`,{className:`opacity-0 group-hover:opacity-100 transition-opacity flex items-center gap-1.5 text-white text-xs font-medium bg-black/50 rounded-full px-3 py-1.5 backdrop-blur-sm`,children:[(0,A.jsx)(t,{className:`size-3.5`}),` `,i.banner?`Change banner`:`Add banner`]})}),i.banner&&(0,A.jsx)(`div`,{className:`absolute bottom-2 right-2 size-7 rounded-full bg-background border border-border shadow-sm flex items-center justify-center transition-opacity`,children:(0,A.jsx)(t,{className:`size-3.5 text-muted-foreground`})})]})]}),(0,A.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-between items-start -mt-12 mb-3`,children:I?(0,A.jsxs)(ge,{open:ye,onOpenChange:z,children:[(0,A.jsx)(me,{asChild:!0,children:(0,A.jsx)(`div`,{className:`shrink-0`,children:(0,A.jsxs)(pe,{children:[(0,A.jsx)(de,{asChild:!0,children:(0,A.jsxs)(`button`,{type:`button`,className:`relative shrink-0 cursor-pointer group outline-none`,children:[(0,A.jsx)(`div`,{style:J?b:void 0,children:(0,A.jsxs)(y,{shape:q,className:h(`shadow-sm`,J?`size-[88px]`:`size-24 border-4 border-background`),children:[(0,A.jsx)(v,{src:i.picture,alt:U,className:`object-cover`}),(0,A.jsx)(_,{className:`bg-primary/20 text-primary text-2xl font-bold`,children:i.picture?W:(0,A.jsx)(r,{className:`size-8 text-muted-foreground`,strokeWidth:4})})]})}),(0,A.jsx)(`div`,{className:h(`absolute inset-0 bg-black/0 group-hover:bg-black/45 transition-colors flex items-center justify-center`,!J&&`rounded-full`),style:we,children:(0,A.jsx)(t,{className:`size-6 text-white opacity-0 group-hover:opacity-100 transition-opacity drop-shadow`})}),i.picture&&(0,A.jsx)(`div`,{className:`absolute bottom-0 right-0 size-7 rounded-full bg-background border border-border shadow-sm flex items-center justify-center transition-opacity`,children:(0,A.jsx)(t,{className:`size-3.5 text-muted-foreground`})})]})}),(0,A.jsxs)(fe,{align:`start`,sideOffset:6,children:[(0,A.jsxs)(D,{onClick:()=>d?.(`picture`),children:[(0,A.jsx)(c,{className:`size-4 mr-2`}),`Change avatar`]}),(0,A.jsxs)(D,{onClick:()=>setTimeout(()=>z(!0),0),children:[(0,A.jsx)(s,{className:`size-4 mr-2`}),`Set avatar shape`]}),i.picture&&(0,A.jsxs)(D,{onClick:()=>p?.(),className:`text-destructive focus:text-destructive`,children:[(0,A.jsx)(a,{className:`size-4 mr-2`}),`Remove avatar`]})]})]})})}),(0,A.jsxs)(he,{align:`start`,sideOffset:8,className:`w-[340px] max-w-[calc(100vw-2rem)] p-0 overflow-hidden`,onOpenAutoFocus:e=>e.preventDefault(),onFocusOutside:e=>e.preventDefault(),children:[(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(`div`,{className:`h-[360px] flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`}),children:(0,A.jsx)(M,{height:360,onSelect:e=>{e.type===`native`&&(f?.(e.emoji),z(!1))}})}),J&&(0,A.jsx)(`div`,{className:`p-2 border-t`,children:(0,A.jsxs)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{f?.(``),z(!1)},children:[(0,A.jsx)(a,{className:`size-3.5 mr-1.5`}),`Remove avatar shape`]})})]})]}):(0,A.jsx)(`div`,{className:`relative shrink-0`,style:J?b:void 0,children:(0,A.jsxs)(y,{shape:q,className:h(`shadow-sm`,J?`size-[88px]`:`size-24 border-4 border-background`),children:[(0,A.jsx)(v,{src:i.picture,alt:U,className:`object-cover`}),(0,A.jsx)(_,{className:`bg-primary/20 text-primary text-2xl font-bold`,children:W})]})})}),I?(0,A.jsx)(P,{value:i.name??``,placeholder:`Your name`,onChange:G(`name`),className:`text-xl font-bold`}):(0,A.jsx)(`h2`,{className:`text-xl font-bold truncate`,children:U}),x&&(I||Z)&&(0,A.jsxs)(`div`,{className:`flex items-center gap-1 mt-2 min-w-0 text-sm text-muted-foreground ml-2`,children:[(0,A.jsx)(u,{className:`size-3.5 text-primary shrink-0`}),I&&L?(0,A.jsx)(`input`,{type:`text`,value:Z??``,placeholder:`you@domain.com`,autoFocus:!0,onChange:e=>G(`nip05`)(e.target.value),onBlur:()=>R(!1),size:Math.max((Z?.length??0)+1,4),className:h(N,`py-0.5 h-6 text-base md:text-sm text-muted-foreground border-primary bg-transparent`)}):(0,A.jsxs)(`span`,{className:h(`inline-flex items-center gap-1 min-w-0`,I&&h(N,`py-0.5 h-6 cursor-text`)),onClick:()=>I&&R(!0),children:[(0,A.jsx)(`span`,{className:`shrink min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:Z?ae(Z):I?`you@domain.com`:``}),Q&&(0,A.jsx)(se,{url:`https://${Q}`,size:14,className:`shrink-0`})]})]}),(0,A.jsx)(`div`,{className:`mt-2`,children:I?(0,A.jsx)(F,{value:i.about??``,placeholder:`Write a short bio…`,onChange:G(`about`)}):i.about?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,A.jsx)(w,{children:i.about})}):null}),T!==void 0&&(0,A.jsxs)(ue,{open:_e,onOpenChange:ve,className:`mt-3`,children:[(0,A.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,A.jsx)(le,{asChild:!0,children:(0,A.jsxs)(g,{type:`button`,variant:`ghost`,className:`w-full justify-between px-0 h-auto hover:bg-transparent text-sm font-medium text-muted-foreground`,children:[`Profile Fields`,(0,A.jsx)(o,{className:`size-4 transition-transform duration-200 [[data-state=open]_&]:rotate-180`,strokeWidth:4})]})})}),(0,A.jsxs)(ce,{className:`space-y-2 pt-2`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-[1fr,2fr] gap-2 items-center`,children:[(0,A.jsx)(`span`,{className:`text-sm text-muted-foreground px-1`,children:`Website`}),(0,A.jsx)(E,{placeholder:`https://yourwebsite.com`,value:i.website??``,onChange:e=>G(`website`)(e.target.value),className:`h-8 text-base md:text-sm`})]}),T.map((e,t)=>(0,A.jsxs)(`div`,{className:`grid grid-cols-[1fr,2fr,auto] gap-2 items-center`,children:[(0,A.jsx)(E,{placeholder:`Label`,value:e.label,onChange:e=>$(t,`label`,e.target.value),className:`h-8 text-base md:text-sm`}),(0,A.jsx)(E,{placeholder:`Value or URL`,value:e.value,onChange:e=>$(t,`value`,e.target.value),className:`h-8 text-base md:text-sm`}),(0,A.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>Ee(t),className:`h-8 w-8 text-destructive hover:text-destructive`,children:(0,A.jsx)(n,{className:`size-3.5`})})]},t)),(0,A.jsxs)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:Te,className:`w-full h-8 text-xs`,children:[(0,A.jsx)(r,{className:`size-3 mr-1`,strokeWidth:4}),` Add Field`]})]})]})]}),(V.length>0||H)&&(0,A.jsx)(`div`,{className:`px-4 pb-3`,children:(0,A.jsx)(j,{items:V.map(e=>({aTag:e.aTag,pubkey:e.pubkey,identifier:e.identifier,badge:xe.get(e.aTag)})),maxVisible:8,thumbnailSize:44,showEditButton:be,isLoading:H||Se,gridCols:`grid-cols-4 sm:grid-cols-5`})})]})}export{I as t}; // @license-end