// @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{Ar as t,Fr as n,Gi as r,Hr as i,Ht as a,It as o,Nt as s,Oi as c,R as l,Sr as u,Vr as d,Xt as f,c as p,d as m,fn as h,li as g,mt as ee,qi as te,rr as ne}from"./lucide-icons-BdRF0moN.js";import{t as re}from"./jsx-runtime-By8HlURe.js";import{t as _}from"./dist-DQ82bf9M.js";import{u as v}from"./esm-CRVqHnq2.js";import{t as y}from"./useQuery-rCAlChE8.js";import{$ as ie,L as ae,N as oe,P as se,R as ce,h as le,m as ue,p as de,t as b,x as fe}from"./EmbeddedNote-BKfkvcrg.js";import{t as pe}from"./useLocalStorage-DLDvi0Ge.js";import{t as x}from"./useAppContext-Ughdk2-Z.js";import{r as me}from"./sanitizeUrl-Bk5f35GN.js";import{s as S}from"./useCurrentUser-C6OJJlWo.js";import{t as C}from"./utils-BFSTDHdM.js";import{t as he}from"./button-Cs26nq0r.js";import{t as ge}from"./nostrId-DuqQCAdJ.js";import{n as _e}from"./appBlossom-CsMDSd4h.js";import{t as ve}from"./useBlossomFallback-DY_46Uqi.js";import{n as w}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{t as ye}from"./ExternalFavicon-BWUhHW7H.js";import{t as T}from"./skeleton-CVls4GW9.js";import{t as be}from"./storageKey-Hu6452Ya.js";import{a as E,c as D,l as O,n as k,t as A}from"./dialog-C3CFmras.js";import{t as j}from"./timeAgo-BXjjbyXp.js";import{t as M}from"./browser-B_X_RtOd.js";import{i as N,n as xe,o as Se}from"./imeta-83Lqxs5-.js";import{t as P}from"./formatTime-CT4ZmnVr.js";import{t as Ce}from"./contentWarning-CNDzjeMP.js";import{D as we}from"./index-CYEZWNq6.js";import{i as F,n as Te,o as Ee,s as De,t as Oe}from"./select-DRTcxeFR.js";import{n as I}from"./mediaUtils-CTfIfTcv.js";var ke=e(M(),1),L=e(te(),1),R=re();function z({src:e,label:t,className:n}){let r=(0,L.useRef)(null),i=(0,L.useRef)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(0),[d,f]=(0,L.useState)(0),p=d>0?l/d:0;(0,L.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>c(!0),n=()=>c(!1),i=()=>c(!1),a=()=>u(e.currentTime),o=()=>{e.duration&&isFinite(e.duration)&&f(e.duration)};return e.addEventListener(`play`,t),e.addEventListener(`pause`,n),e.addEventListener(`ended`,i),e.addEventListener(`timeupdate`,a),e.addEventListener(`durationchange`,o),e.addEventListener(`loadedmetadata`,o),()=>{e.removeEventListener(`play`,t),e.removeEventListener(`pause`,n),e.removeEventListener(`ended`,i),e.removeEventListener(`timeupdate`,a),e.removeEventListener(`durationchange`,o),e.removeEventListener(`loadedmetadata`,o)}},[]);let m=(0,L.useCallback)(e=>{e.stopPropagation();let t=r.current;t&&(t.paused?t.play():t.pause())},[]),h=(0,L.useCallback)(e=>{e.stopPropagation();let t=r.current,n=i.current;if(!t||!n||!d)return;let a=n.getBoundingClientRect();t.currentTime=Math.max(0,Math.min(1,(e.clientX-a.left)/a.width))*d},[d]);return(0,R.jsxs)(`div`,{className:C(`flex items-center gap-2.5 rounded-lg border border-border bg-muted/30 px-3 py-2`,n),children:[(0,R.jsx)(`audio`,{ref:r,preload:`metadata`,className:`hidden`,children:(0,R.jsx)(`source`,{src:e})}),(0,R.jsx)(`button`,{onClick:m,className:C(`shrink-0 size-7 rounded-full flex items-center justify-center transition-colors`,s?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":s?`Pause`:`Play`,children:s?(0,R.jsx)(a,{className:`size-3`,fill:`currentColor`}):(0,R.jsx)(o,{className:`size-3 ml-px`,fill:`currentColor`})}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[t&&(0,R.jsx)(`span`,{className:`block text-xs font-medium truncate`,children:t}),(0,R.jsx)(`div`,{ref:i,className:`h-1 w-full rounded-full bg-primary/15 cursor-pointer`,onClick:h,children:(0,R.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width] duration-150`,style:{width:`${p*100}%`}})})]}),(0,R.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground shrink-0`,children:[P(l),`/`,d>0?P(d):`--:--`]})]})}var Ae=/\.(mp3|mpga|ogg|oga|wav|flac|aac|m4a|opus|weba|webm|spx|caf)(\?.*)?$/i,je=/\.(jpe?g|png|gif|webp|svg|avif)(\?.*)?$/i,Me=/\.(mp4|webm|mov|qt)(\?.*)?$/i;function B(e){return!e.startsWith(`http://`)&&!e.startsWith(`https://`)?!1:Ae.test(e)}function V(e){return!e.startsWith(`http://`)&&!e.startsWith(`https://`)?!1:je.test(e)}function H(e){return!e.startsWith(`http://`)&&!e.startsWith(`https://`)?!1:Me.test(e)}var Ne=16158,U=4223;function W(e){let t=e.trim().toLowerCase();return t===`weather`||t===`weather station`}function G(e){let t=e.trim();if(!t)return null;let n=t.startsWith(`nostr:`)?t.slice(6):t,r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1).trim():``,o=ge(i)?i:void 0;if(o)return{pubkey:o,stationId:a||void 0,raw:e};try{let t=v.decode(i);if(t.type===`npub`)return{pubkey:t.data,stationId:a||void 0,raw:e};if(t.type===`nprofile`)return{pubkey:t.data.pubkey,stationId:a||void 0,raw:e};if(t.type===`naddr`){let n=a||t.data.identifier||void 0;return{pubkey:t.data.pubkey,stationId:n,raw:e}}}catch{return null}return null}function Pe(e){let t=e.match(/-?\d+(\.\d+)?/);if(!t)return null;let n=Number.parseFloat(t[0]);return Number.isFinite(n)?n:null}function Fe(e){return/[a-z%]/i.test(e.replace(/-?\d+(\.\d+)?/g,``))}function K(e,t){return e.toFixed(t).replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function Ie(e){return e.trim().toLowerCase().replace(/[\s-]+/g,`_`)}function Le(e,t,n){let r=Ie(e),i=Pe(t);if(i===null)return t;let a=Fe(t);return r===`temperature`||r===`temp`?n===`hamburger`?`${K(i*9/5+32,1)}${a?``:`°F`}`:`${K(i,1)}${a?``:`°C`}`:r===`pressure`?n===`hamburger`?`${K(i*.0295299831,2)}${a?``:` inHg`}`:`${K(i,1)}${a?``:` hPa`}`:r===`rain`||r===`precipitation`?n===`hamburger`?`${K(i/25.4,2)}${a?``:` in`}`:`${K(i,1)}${a?``:` mm`}`:r===`wind_speed`||r===`windspeed`?n===`hamburger`?`${K(i*2.2369362921,1)}${a?``:` mph`}`:`${K(i,1)}${a?``:` m/s`}`:r===`wave_height`?n===`hamburger`?`${K(i*3.280839895,1)}${a?``:` ft`}`:`${K(i,1)}${a?``:` m`}`:r===`humidity`?`${K(i,0)}${a?``:`%`}`:t}var Re={temperature:`Temperature`,humidity:`Humidity`,pressure:`Pressure`,wind_speed:`Wind speed`,wind_direction:`Wind direction`,rain:`Rain`,wave_height:`Wave height`,wave_period:`Wave period`,wave_direction:`Wave direction`,air_quality:`Air quality`},ze=new Set([`id`,`alt`,`client`,`s`,`d`,`g`,`p`,`e`,`a`,`t`,`nonce`,`expiration`,`observed_at`,`sensor_status`]);function q(e,t){return e.tags.find(([e])=>e===t)?.[1]}function Be(e){let t=q(e,`observed_at`),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)&&n>0?n:e.created_at}function Ve(e){let t=[];for(let[n,r,i]of e.tags){if(!r)continue;let e=Re[n];if(e){t.push({key:n,label:e,value:r,model:i});continue}ze.has(n)||/^[a-z0-9_]+$/i.test(n)&&/^-?\d+(\.\d+)?([a-z%/]+)?$/i.test(r)&&t.push({key:n,label:n.replace(/_/g,` `),value:r,model:i})}return t}function He(e,t){return[...t?e.filter(e=>{let n=q(e,`s`),r=q(e,`d`);return n===t||r===t}):e].sort((e,t)=>t.created_at-e.created_at)[0]}function Ue(e){let{nostr:t}=_(),n=G(e);return y({queryKey:[`weather-station`,n?.pubkey??``,n?.stationId??``,e],enabled:!!n,staleTime:3e4,queryFn:async({signal:e})=>{if(!n)return null;let r=n.stationId?[{kinds:[U],authors:[n.pubkey],"#s":[n.stationId],limit:20},{kinds:[U],authors:[n.pubkey],"#d":[n.stationId],limit:20}]:[{kinds:[U],authors:[n.pubkey],limit:20}],i=He(await t.query(r,{signal:e}),n.stationId);if(!i)return null;let a={kinds:[Ne],authors:[n.pubkey],limit:1};n.stationId&&(a[`#d`]=[n.stationId]);let[o]=await t.query([a],{signal:e});return{stationName:q(o??i,`name`),stationDescription:q(o??i,`description`),observedAt:Be(i),eventId:i.id,sensors:Ve(i)}}})}function We(e){let n=e.toLowerCase();return n===`temperature`||n===`temp`?l:n===`humidity`?t:n===`pressure`?ne:n===`wind_speed`||n===`windspeed`?p:n===`wind_direction`||n===`wdir`?f:n===`rain`||n===`precipitation`?i:n===`wave_height`||n===`wave_period`||n===`wave_direction`?m:n===`air_quality`||n.startsWith(`pm`)?r:d}function J({value:e,compact:t=!1}){let{config:n}=x(),r=G(e),{data:i,isPending:a}=Ue(e),[o,s]=pe(be(n.appId,`weather-units`),`normal`);if(!r)return(0,R.jsxs)(`div`,{className:t?`flex items-center gap-1.5 min-w-0`:`rounded-xl border border-primary/10 bg-gradient-to-br from-sky-500/10 via-blue-500/5 to-indigo-500/10 p-3`,children:[(0,R.jsx)(d,{className:`size-4 shrink-0 text-primary`}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Weather`}),(0,R.jsx)(`span`,{className:`text-sm truncate`,children:`Invalid station reference`})]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm`,children:`Weather`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Invalid station reference`})]})]});if(a)return(0,R.jsxs)(`div`,{className:t?`flex items-center gap-1.5 min-w-0`:`rounded-xl border border-primary/10 bg-gradient-to-br from-sky-500/10 via-blue-500/5 to-indigo-500/10 p-3`,children:[(0,R.jsx)(d,{className:`size-4 shrink-0 text-primary`}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Weather`}),(0,R.jsx)(`span`,{className:`text-sm truncate`,children:`Loading latest reading...`})]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm`,children:`Weather`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Loading latest reading...`})]})]});if(!i)return(0,R.jsxs)(`div`,{className:t?`flex items-center gap-1.5 min-w-0`:`rounded-xl border border-primary/10 bg-gradient-to-br from-sky-500/10 via-blue-500/5 to-indigo-500/10 p-3`,children:[(0,R.jsx)(d,{className:`size-4 shrink-0 text-primary`}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Weather`}),(0,R.jsx)(`span`,{className:`text-sm truncate`,children:`No reading found yet`})]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm`,children:`Weather`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`No reading found yet`})]})]});let c=t?i.sensors.slice(0,4):i.sensors.slice(0,6);return(0,R.jsxs)(`div`,{className:t?`min-w-0 rounded-xl border border-primary/10 bg-gradient-to-br from-sky-500/10 via-blue-500/5 to-indigo-500/10 p-2.5`:`rounded-xl border border-primary/10 bg-gradient-to-br from-sky-500/10 via-blue-500/5 to-indigo-500/10 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,R.jsx)(d,{className:`size-4 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:t?`text-sm text-muted-foreground truncate`:`font-semibold text-sm truncate`,children:i.stationName||`Weather`})]}),(0,R.jsxs)(Oe,{value:o,onValueChange:e=>s(e),children:[(0,R.jsx)(Ee,{className:t?`h-7 w-[102px] rounded-full bg-background/80 text-[11px]`:`h-7 w-[106px] rounded-full bg-background/80 text-[11px]`,children:(0,R.jsx)(De,{})}),(0,R.jsxs)(Te,{children:[(0,R.jsx)(F,{value:`normal`,children:`Normal`}),(0,R.jsx)(F,{value:`hamburger`,children:`Hamburger`})]})]})]}),(0,R.jsxs)(`p`,{className:t?`text-xs text-muted-foreground mt-0.5`:`text-xs text-muted-foreground mt-1`,children:[`Updated `,j(i.observedAt),` ago`]}),c.length>0?(0,R.jsx)(`div`,{className:t?`mt-2 grid grid-cols-2 gap-1.5`:`mt-2 grid grid-cols-2 gap-1.5 text-xs`,children:c.map(e=>{let n=We(e.key);return(0,R.jsxs)(`div`,{className:t?`rounded-md border border-primary/10 bg-background/70 px-2 py-1.5`:`rounded-lg border border-primary/10 bg-background/70 px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:t?`flex items-center gap-1 text-muted-foreground text-[11px]`:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,R.jsx)(n,{className:t?`size-3 shrink-0`:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:t?`truncate`:`truncate text-[11px]`,children:e.label})]}),(0,R.jsx)(`div`,{className:t?`text-xs font-semibold truncate`:`font-semibold truncate text-sm mt-0.5`,children:Le(e.key,e.value,o)})]},e.key)})}):(0,R.jsx)(`p`,{className:t?`text-sm truncate mt-0.5`:`text-xs text-muted-foreground mt-2`,children:`No sensor tags in latest reading`})]})}var Ge=[20,21,22,34236,36787,34139,30054,30055],Y=9,Ke=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,qe=RegExp(`^nostr:(note1|nevent1|naddr1|npub1|nprofile1)[023456789acdefghjklmnpqrstuvwxyz]+$`);function Je(e){let t=e.trim();if(!qe.test(t))return null;try{let e=t.slice(6),n=v.decode(e);switch(n.type){case`note`:return{type:`note`,eventId:n.data};case`nevent`:return{type:`nevent`,eventId:n.data.id,relays:n.data.relays,author:n.data.author};case`naddr`:return{type:`naddr`,addr:n.data};case`npub`:return{type:`profile`,pubkey:n.data};case`nprofile`:return{type:`profile`,pubkey:n.data.pubkey};default:return null}}catch{return null}}function Ye(e){return e.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp|svg)(\?[^\s]*)?/gi)||[]}function Xe(e){return e.match(/https?:\/\/[^\s]+\.(mp4|webm|mov|qt)(\?[^\s]*)?/gi)||[]}function X(e,t){for(let n of xe(e.tags))if(!(t&&n.url!==t))return{url:n.url,blurhash:n.blurhash,dim:n.dim,mime:n.mime,encryption:n.encryption};return{}}function Z(e,t,n){let r=[],i=new Set;for(let a of e){let e=Ce(a)!==void 0;if(e&&t===`hide`)continue;if(a.kind!==1){let{url:t,blurhash:o,dim:s,mime:c,encryption:l}=X(a),u=t?le(t,n):void 0;if(u&&!i.has(u)){i.add(u);let t=a.tags.find(([e])=>e===`d`)?.[1];r.push({url:u,blurhash:o,dim:s,mime:c,encryption:l,eventId:a.id,authorPubkey:a.pubkey,kind:a.kind,dTag:t,hasContentWarning:e})}continue}let o=Ye(a.content),s=Xe(a.content);for(let t of[...o,...s])if(!i.has(t)){i.add(t);let{blurhash:n,dim:o,mime:s,encryption:c}=X(a,t);r.push({url:t,blurhash:n,dim:o,mime:s,encryption:c,eventId:a.id,authorPubkey:a.pubkey,hasContentWarning:e})}for(let{uri:t,raw:o}of de(a.content)){let s=fe(t.ext);if(!/^(image|video|audio)\//.test(s))continue;let[c]=ue(t,n);if(!c||i.has(c))continue;i.add(c);let{blurhash:l,dim:u,encryption:d}=X(a,o);r.push({url:c,blurhash:l,dim:u,mime:s,encryption:d,eventId:a.id,authorPubkey:a.pubkey,hasContentWarning:e})}}return r.slice(0,9)}var Ze=new Set([34236,21,22]);function Qe(e){return!!(e.mime?.startsWith(`video/`)||/\.(mp4|webm|mov|qt)(\?.*)?$/i.test(e.url)||e.kind!==void 0&&Ze.has(e.kind))}function Q({item:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null),{config:i}=x(),a=ve(e.url),o=Se(e.url,e.encryption),s=o.encrypted?o.src:a.src,c=o.encrypted?void 0:a.onError,l=Qe(e);return(0,L.useEffect)(()=>{r.current?.complete&&r.current.naturalWidth>0&&n(!0)},[]),(0,R.jsxs)(`div`,{className:`relative w-full h-full`,children:[o.encrypted&&!o.src&&(0,R.jsx)(N,{fill:!0,loading:o.loading,unsupported:o.unsupported,tooLarge:o.tooLarge,byteSize:o.byteSize,onDecryptAnyway:o.decryptAnyway}),!t&&!o.error&&!o.tooLarge&&(ae(e.blurhash)?(0,R.jsx)(ce,{hash:e.blurhash,width:32,height:32,resolutionX:32,resolutionY:32,punch:1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`}}):(0,R.jsx)(T,{className:`absolute inset-0 w-full h-full rounded-none`})),l?(0,R.jsx)(`video`,{src:s,"data-no-native-poster":``,poster:se,className:`absolute inset-0 w-full h-full object-cover`,muted:!0,autoPlay:i.autoplayVideos,loop:!0,playsInline:!0,preload:`metadata`,onLoadedData:()=>n(!0),onError:c}):(0,R.jsx)(`img`,{ref:r,src:s,alt:``,className:`absolute inset-0 w-full h-full object-cover`,loading:`lazy`,onLoad:()=>n(!0),onError:c,decoding:`async`})]})}function $(e){return e.kind&&e.kind>=3e4&&e.kind<4e4&&e.dTag!==void 0?`/${v.naddrEncode({kind:e.kind,pubkey:e.authorPubkey,identifier:e.dTag})}`:`/${v.neventEncode({id:e.eventId,author:e.authorPubkey})}`}function $e({address:e}){let[t,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),{toast:o}=S();return(0,L.useEffect)(()=>{ke.toDataURL(`bitcoin:${e}`,{width:280,margin:2,color:{dark:`#000000`,light:`#FFFFFF`}}).then(r).catch(console.error)},[e]),(0,R.jsx)(k,{className:`sm:max-w-[360px] p-6 overflow-hidden rounded-2xl [&>button]:top-6 [&>button]:right-6`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(E,{children:(0,R.jsxs)(D,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`size-7 rounded-full bg-orange-500 flex items-center justify-center shrink-0`,children:(0,R.jsx)(c,{className:`size-4 text-white`})}),(0,R.jsx)(`span`,{children:`Bitcoin`})]})}),(0,R.jsx)(`div`,{className:`flex justify-center my-5`,children:(0,R.jsx)(`div`,{className:`bg-white p-3 rounded-xl`,children:t?(0,R.jsx)(`img`,{src:t,alt:`Bitcoin QR`,className:`size-[220px]`,decoding:`async`}):(0,R.jsx)(`div`,{className:`size-[220px] bg-muted animate-pulse rounded`})})}),(0,R.jsxs)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(e),a(!0),o({title:`Copied`,description:`Bitcoin address copied to clipboard`}),setTimeout(()=>a(!1),2e3)},className:`flex items-center gap-2 w-full bg-secondary/60 hover:bg-secondary/80 transition-colors rounded-lg pl-3 pr-2.5 py-2.5 text-left cursor-pointer overflow-hidden`,children:[(0,R.jsx)(`span`,{className:`min-w-0 font-mono text-xs truncate`,children:e}),(0,R.jsx)(`span`,{className:`shrink-0 ml-auto`,children:i?(0,R.jsx)(g,{className:`size-4 text-green-500`}):(0,R.jsx)(n,{className:`size-4 text-muted-foreground`})})]})]})})}function et({field:e}){let[t,n]=(0,L.useState)(!1),{toast:r}=S(),i=e.label===`$BTC`,a=async()=>{await navigator.clipboard.writeText(e.value),n(!0),r({title:`Copied`,description:`Bitcoin address copied to clipboard`}),setTimeout(()=>n(!1),2e3)};if(i)return(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`size-5 rounded-full bg-orange-500 flex items-center justify-center shrink-0`,children:(0,R.jsx)(c,{className:`size-3 text-white`})}),(0,R.jsx)(`span`,{className:`font-semibold text-sm`,children:`Bitcoin`}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,R.jsxs)(A,{children:[(0,R.jsx)(O,{asChild:!0,children:(0,R.jsx)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors text-muted-foreground hover:text-primary`,children:(0,R.jsx)(s,{className:`size-4`})})}),(0,R.jsx)($e,{address:e.value})]}),(0,R.jsx)(`a`,{href:`https://mempool.space/address/${e.value}`,target:`_blank`,rel:`noopener noreferrer`,className:`p-1 rounded hover:bg-secondary transition-colors text-muted-foreground hover:text-primary`,children:(0,R.jsx)(u,{className:`size-4`})})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`flex-1 bg-secondary/60 rounded-lg px-3 py-2 font-mono text-xs truncate`,children:e.value}),(0,R.jsx)(he,{onClick:a,size:`sm`,className:`shrink-0 rounded-lg font-semibold text-xs h-8`,children:t?(0,R.jsx)(g,{className:`size-3.5`}):`Copy`})]})]});if(W(e.label))return(0,R.jsx)(tt,{value:e.value});let o=Je(e.value);if(o)return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm mb-1.5`,children:e.label}),o.type===`note`&&(0,R.jsx)(b,{eventId:o.eventId}),o.type===`nevent`&&(0,R.jsx)(b,{eventId:o.eventId,relays:o.relays,authorHint:o.author}),o.type===`naddr`&&(0,R.jsx)(ie,{addr:o.addr}),o.type===`profile`&&(0,R.jsxs)(w,{to:`/${v.npubEncode(o.pubkey)}`,className:`text-sm text-primary hover:underline`,children:[v.npubEncode(o.pubkey).slice(0,16),`...`]})]});if(e.label.toLowerCase()===`email`&&Ke.test(e.value))return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm`,children:e.label}),(0,R.jsxs)(`a`,{href:`mailto:${e.value}`,className:`flex items-center gap-1.5 text-sm text-primary hover:underline truncate mt-0.5`,children:[(0,R.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.value})]})]});let l=me(e.value);return l&&B(l)?(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm mb-1.5`,children:e.label}),(0,R.jsx)(z,{src:l})]}):l&&V(l)?(0,R.jsxs)(`div`,{children:[e.label&&(0,R.jsx)(`div`,{className:`font-semibold text-sm mb-1.5`,children:e.label}),(0,R.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`block`,children:(0,R.jsx)(`img`,{src:l,alt:e.label||`Profile image`,className:`w-full rounded-lg object-cover`,loading:`lazy`,decoding:`async`})})]}):l&&H(l)?(0,R.jsxs)(`div`,{children:[e.label&&(0,R.jsx)(`div`,{className:`font-semibold text-sm mb-1.5`,children:e.label}),(0,R.jsx)(`div`,{className:`rounded-lg overflow-hidden`,children:(0,R.jsx)(oe,{src:l})})]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-semibold text-sm`,children:e.label}),l?(0,R.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-sm text-primary hover:underline truncate mt-0.5`,children:[(0,R.jsx)(ye,{url:l,size:16,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:l.replace(/^https?:\/\//,``)})]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.value})]})}function tt({value:e}){return(0,R.jsx)(J,{value:e})}function nt(e){if(e.length===0)return[];let t=[],n=[],r=0,i=.35;for(let a of e){let e=I(a.dim);n.push(a),r+=e;let o=1/r;(o<=i||n.length>=4)&&(t.push({items:[...n],heightFraction:o}),n=[],r=0)}if(n.length>1){let e=1/r;t.push({items:n,heightFraction:Math.min(e,i)})}return t}function rt({fields:e,pubkey:t,onMediaClick:n,className:r}){let{config:i}=x(),{nostr:a}=_(),{data:o,isPending:s}=y({queryKey:[`sidebar-media`,t??``],queryFn:async({signal:e})=>{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=Math.floor(Date.now()/1e3),i=(await a.query([{kinds:Ge,authors:[t],limit:Y}],{signal:n})).filter(e=>e.created_at<=r).sort((e,t)=>t.created_at-e.created_at);if(i.length>=Y)return i;let o=(await a.query([{kinds:[1],authors:[t],search:`media:true`,limit:Y}],{signal:n})).filter(e=>e.created_at<=r).sort((e,t)=>t.created_at-e.created_at);return[...i,...o]},enabled:!!t,staleTime:3e4}),c=(0,L.useMemo)(()=>Z(o??[],i.contentWarningPolicy,_e(i.blossomServerMetadata,i.useAppBlossomServers)),[o,i.contentWarningPolicy,i.blossomServerMetadata,i.useAppBlossomServers]),l=(0,L.useMemo)(()=>nt(c),[c]);return(0,R.jsxs)(`aside`,{className:C(`w-1/4 max-w-[300px] shrink-0 hidden lg:flex flex-col sticky top-0 h-screen overflow-y-auto pt-2 pb-3 px-3`,r),children:[t!==void 0&&(0,R.jsxs)(`section`,{className:`mb-6 bg-background/85 rounded-xl p-3 -mx-1`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-bold mb-3`,style:{fontFamily:`var(--title-font-family, inherit)`},children:`Media`}),s?(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:[[1.5,.8,1.2],[1,1.3,.9],[.75,1.5,1]].map((e,t)=>(0,R.jsx)(`div`,{className:`flex gap-0.5`,style:{aspectRatio:`${e.reduce((e,t)=>e+t,0)}`},children:e.map((e,t)=>(0,R.jsx)(T,{className:`rounded-lg h-full`,style:{flexGrow:e,flexBasis:0}},t))},t))}):c&&c.length>0?(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:l.map((e,t)=>(0,R.jsx)(`div`,{className:`flex gap-0.5`,style:{aspectRatio:`${e.items.reduce((e,t)=>e+I(t.dim),0)}`},children:e.items.map((e,t)=>{let r={flexGrow:I(e.dim),flexBasis:0,position:`relative`};if(e.hasContentWarning&&i.contentWarningPolicy===`blur`){let i=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`absolute inset-0 bg-muted/60 blur-lg`}),(0,R.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,R.jsx)(ee,{className:`size-5 text-muted-foreground`})})]});return n?(0,R.jsx)(`div`,{style:r,className:`rounded-lg overflow-hidden h-full`,children:(0,R.jsx)(`button`,{className:`absolute inset-0 w-full h-full`,onClick:()=>n(e.url),children:i})},t):(0,R.jsx)(`div`,{style:r,className:`rounded-lg overflow-hidden h-full`,children:(0,R.jsx)(w,{to:$(e),className:`absolute inset-0 block`,children:i})},t)}return n?(0,R.jsx)(`div`,{style:r,className:`rounded-lg overflow-hidden h-full`,children:(0,R.jsx)(`button`,{className:`absolute inset-0 hover:opacity-80 transition-opacity w-full h-full`,onClick:()=>n(e.url),children:(0,R.jsx)(Q,{item:e})})},t):(0,R.jsx)(`div`,{style:r,className:`rounded-lg overflow-hidden h-full`,children:(0,R.jsx)(w,{to:$(e),className:`absolute inset-0 hover:opacity-80 transition-opacity block`,children:(0,R.jsx)(Q,{item:e})})},t)})},t))}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No media yet.`})]}),e&&e.length>0&&(0,R.jsxs)(`section`,{className:`mb-6 bg-background/85 rounded-xl p-3 -mx-1`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-bold mb-3`,style:{fontFamily:`var(--title-font-family, inherit)`},children:`Profile fields`}),(0,R.jsx)(`div`,{className:`space-y-4`,children:e.map((e,t)=>(0,R.jsx)(et,{field:e},t))})]}),t!==void 0&&(0,R.jsx)(we,{})]})}export{V as a,B as i,J as n,H as o,W as r,z as s,rt as t}; // @license-end