birdclaw 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cli/birdclaw.js +8 -9
  3. package/dist/client/assets/ProfilePreview-DQX6_xc3.js +1 -0
  4. package/dist/client/assets/{SavedTimelineView-BIS7HKpp.js → SavedTimelineView-BhSiVyR1.js} +1 -1
  5. package/dist/client/assets/{TimelineRouteFrame-CyGPj0eM.js → TimelineRouteFrame-9NDLnXzH.js} +1 -1
  6. package/dist/client/assets/{blocks-7UDKQp8H.js → blocks-CFp_njvG.js} +1 -1
  7. package/dist/client/assets/{bookmarks-CbBkMvXk.js → bookmarks-LbYOsoKf.js} +1 -1
  8. package/dist/client/assets/{client-stream-contracts-ys3XhWG4.js → client-stream-contracts-sR4xMQxY.js} +1 -1
  9. package/dist/client/assets/{data-sources-Cm2bpNvg.js → data-sources-euTr6T_L.js} +1 -1
  10. package/dist/client/assets/{discuss-DTjaOugw.js → discuss-BWKu_p7B.js} +1 -1
  11. package/dist/client/assets/{dms-CGd6Eogq.js → dms-SLXMtC4v.js} +1 -1
  12. package/dist/client/assets/{inbox-BHlGuOy2.js → inbox-BybSI5Vf.js} +1 -1
  13. package/dist/client/assets/{index-CEIG7S6s.js → index-DZVisyna.js} +3 -3
  14. package/dist/client/assets/{likes-cLrcAQem.js → likes-dyh9p8y_.js} +1 -1
  15. package/dist/client/assets/{links-CM9QO1LC.js → links-CIwqK_dX.js} +1 -1
  16. package/dist/client/assets/{mapbox-BxTlqXt9.js → mapbox-B4zqX7r0.js} +2 -2
  17. package/dist/client/assets/{mapbox-gl-dgf_hX3a.js → mapbox-gl-DYNcLcll.js} +1 -1
  18. package/dist/client/assets/{mentions-CxKCgzIf.js → mentions-BoVVAIT7.js} +1 -1
  19. package/dist/client/assets/{network-map-B5a3whqj.js → network-map-zRysIY_b.js} +2 -2
  20. package/dist/client/assets/{profile-analyze-CRtNEwlb.js → profile-analyze-C_yDeX6-.js} +1 -1
  21. package/dist/client/assets/{profiles._handle-C82_HoKX.js → profiles._handle-DdIVPqU-.js} +1 -1
  22. package/dist/client/assets/{rate-limits-ScaEwdVK.js → rate-limits-BWPmPOSh.js} +1 -1
  23. package/dist/client/assets/{routes-q7ZaW4En.js → routes-CiLuYpZr.js} +1 -1
  24. package/dist/client/assets/{today-CeG1O7Py.js → today-BoO64YoY.js} +1 -1
  25. package/dist/client/assets/{useTimelineRouteData-1HsqgvUi.js → useTimelineRouteData-BaO3Rna1.js} +1 -1
  26. package/dist/server/assets/{ProfileAnalysisStream-BFvhVdhn.js → ProfileAnalysisStream-L7bs6IHH.js} +1 -1
  27. package/dist/server/assets/{ProfilePreview-C6gAor_j.js → ProfilePreview-Cg-AOHBE.js} +5 -6
  28. package/dist/server/assets/{SavedTimelineView-BG1jnBp1.js → SavedTimelineView-BtCq1dHk.js} +1 -1
  29. package/dist/server/assets/{TimelineRouteFrame-CU7ilM7U.js → TimelineRouteFrame-CjMIh63G.js} +1 -1
  30. package/dist/server/assets/{TweetRichText-DhCVv1-6.js → TweetRichText-DDywESRF.js} +1 -1
  31. package/dist/server/assets/{_tanstack-start-manifest_v-C-ZRnG_n.js → _tanstack-start-manifest_v-aLWUdbAc.js} +19 -19
  32. package/dist/server/assets/{bookmarks-BJN8tykY.js → bookmarks-D_YkmCK3.js} +1 -1
  33. package/dist/server/assets/{client-stream-contracts-C2xbWVjm.js → client-stream-contracts-Bq6kMmhh.js} +1 -1
  34. package/dist/server/assets/{discuss-QTo08NCN.js → discuss-C1QMBBSk.js} +2 -2
  35. package/dist/server/assets/{discuss-CJ1dau1j.js → discuss-DAq6ehL9.js} +2 -2
  36. package/dist/server/assets/{likes-DBOAtsJU.js → likes-BMm2JWYI.js} +1 -1
  37. package/dist/server/assets/{links-DmH5lxHO.js → links-Da4tjWtI.js} +2 -2
  38. package/dist/server/assets/{links-DAhSjynu.js → links-dqXb35YM.js} +2 -2
  39. package/dist/server/assets/{mentions-BH2MzKtB.js → mentions-CEyEcOFw.js} +1 -1
  40. package/dist/server/assets/{profile-analyze-BP65PED0.js → profile-analyze-CGCj4VFd.js} +2 -2
  41. package/dist/server/assets/{profile-analyze-C1NoM0tV.js → profile-analyze-DH1TSBkT.js} +1 -1
  42. package/dist/server/assets/{profiles._handle-DsLNj2Ca.js → profiles._handle-B5V-huoo.js} +3 -3
  43. package/dist/server/assets/{profiles._handle-DjwlN_ac.js → profiles._handle-CJ6rgzt8.js} +4 -4
  44. package/dist/server/assets/{router-DqkwSPiM.js → router-C4cz9ypd.js} +14 -14
  45. package/dist/server/assets/{routes-A9c9ZhwN.js → routes-B9aikOdB.js} +1 -1
  46. package/dist/server/assets/{today-fvGiZ7ud.js → today-B_TA16QG.js} +2 -2
  47. package/dist/server/assets/{today-B5hVM57Z.js → today-JkxZXdBt.js} +2 -2
  48. package/dist/server/assets/{useTimelineRouteData-27cxynxa.js → useTimelineRouteData-BLXvMGb2.js} +2 -2
  49. package/dist/server/server.js +2 -2
  50. package/package.json +1 -1
  51. package/dist/client/assets/ProfilePreview-BejAuYsJ.js +0 -1
@@ -1 +1 @@
1
- import{Ln as e}from"./schemas-I9r6F6ya.js";import{t}from"./TimelineRouteFrame-CyGPj0eM.js";var n=e();function r(e){return e?`${String(e.stats.mentions)} mention/reply items in local store`:`Loading mentions...`}function i(){return(0,n.jsx)(t,{emptyDetail:`Try All, search less narrowly, or sync mentions.`,emptyLabel:`No mentions in this view`,errorFallback:`Mentions unavailable`,errorTitle:`Could not load mentions`,initialReplyFilter:`unreplied`,loadingDetail:`Checking local mentions and reply context`,loadingLabel:`Loading mentions`,resource:`mentions`,searchPlaceholder:`Search mentions`,subtitle:r,syncKind:`mentions`,syncLabel:`Sync mentions`,title:`Mentions`})}export{i as component};
1
+ import{Ln as e}from"./schemas-I9r6F6ya.js";import{t}from"./TimelineRouteFrame-9NDLnXzH.js";var n=e();function r(e){return e?`${String(e.stats.mentions)} mention/reply items in local store`:`Loading mentions...`}function i(){return(0,n.jsx)(t,{emptyDetail:`Try All, search less narrowly, or sync mentions.`,emptyLabel:`No mentions in this view`,errorFallback:`Mentions unavailable`,errorTitle:`Could not load mentions`,initialReplyFilter:`unreplied`,loadingDetail:`Checking local mentions and reply context`,loadingLabel:`Loading mentions`,resource:`mentions`,searchPlaceholder:`Search mentions`,subtitle:r,syncKind:`mentions`,syncLabel:`Sync mentions`,title:`Mentions`})}export{i as component};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mapbox-BxTlqXt9.js","assets/chunk-C0phanGV.js","assets/index-CEIG7S6s.js","assets/query-client-fYu2rzRC.js","assets/schemas-I9r6F6ya.js","assets/react-nBylq1U5.js","assets/createLucideIcon-JV8isFFR.js","assets/circle-check-C_Vq3ElD.js","assets/client-stream-contracts-ys3XhWG4.js","assets/AvatarChip-DLoqM5xD.js","assets/ProfilePreview-BejAuYsJ.js","assets/SmartTimestamp-BR0-9se2.js","assets/sparkles-CQVlvHsZ.js","assets/react-dom-DHl6Ug7F.js","assets/profile-hydration-client-YEtJsNTv.js","assets/index-bpFrQ5yG.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,an as l,cn as u,dn as d,dt as f,on as p,sn as m,un as h,wn as g}from"./schemas-I9r6F6ya.js";import{t as _}from"./createLucideIcon-JV8isFFR.js";import{t as v}from"./search-Dq5kYsxA.js";import{t as ee}from"./users-CHbKlqUr.js";import{B as y,F as b,G as x,H as S,I as C,K as w,L as T,N as E,P as D,R as O,U as k,V as A,W as j,X as M,Y as N,_t as P,ft as F,nt as I,z as L}from"./index-CEIG7S6s.js";var R=_(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),z=_(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),B=e(t()),V=a();M();function H({icon:e,label:t,value:n}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-b border-[var(--line)] px-4 py-3 sm:border-r`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,V.jsx)(e,{className:`size-4`,strokeWidth:1.8}),(0,V.jsx)(`span`,{children:t})]}),(0,V.jsx)(`div`,{className:`truncate text-[24px] font-bold tracking-tight text-[var(--ink)]`,children:A(n)})]})}function U(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=!1;return N(()=>import(`./mapbox-BxTlqXt9.js`).then(n=>{e||t(n)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])).catch(t=>{e||r(t instanceof Error?t.message:`Map failed`)}),()=>{e=!0}},[]),{module:e,error:n}}function W({feature:e,size:t=36,className:n,style:r}){let i=T(e),[a,s]=(0,B.useState)(null),c=i&&a!==i;return(0,V.jsx)(`div`,{className:o(`relative grid shrink-0 place-items-center overflow-hidden rounded-full bg-[var(--accent-soft)] text-[12px] font-bold text-[var(--accent)] ring-2 ring-white`,n),style:{width:t,height:t,...r},children:c?(0,V.jsx)(`img`,{src:i,alt:``,className:`h-full w-full object-cover`,loading:`lazy`,onError:()=>s(i)}):(0,V.jsx)(`span`,{children:C(e)})})}function G({feature:e}){let t=w(e.properties.relationship);return(0,V.jsxs)(`button`,{type:`button`,className:`group relative grid size-11 place-items-center rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-110`,"aria-label":`Open @${e.properties.handle}`,title:`@${e.properties.handle}`,children:[(0,V.jsx)(`span`,{className:`absolute inset-0 rounded-full opacity-90 shadow-[0_10px_28px_rgba(15,20,25,0.28)]`,style:{backgroundColor:t}}),(0,V.jsx)(W,{feature:e,size:34,className:`relative ring-[3px]`})]})}function K({count:e,features:t,stats:n}){let r=Math.min(82,Math.max(52,44+Math.log2(e)*7)),i=r>=72?30:25;return(0,V.jsxs)(`button`,{type:`button`,className:`group relative rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-105`,"aria-label":`${A(e)} located profiles`,title:`${A(e)} profiles`,style:{width:r,height:r},children:[(0,V.jsx)(`span`,{className:`absolute inset-0 rounded-full opacity-95 shadow-[0_18px_42px_rgba(15,20,25,0.32)]`,style:{background:L(n)}}),(0,V.jsx)(`span`,{className:`absolute inset-[4px] rounded-full bg-white/88 backdrop-blur-sm`}),(0,V.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:t.slice(0,4).map((e,t)=>(0,V.jsx)(W,{feature:e,size:i,className:`absolute`,style:{transform:`translate(${[-10,10,-7,8][t]??0}px, ${[-9,-8,11,10][t]??0}px)`}},e.properties.profileId))}),(0,V.jsx)(`span`,{className:`absolute -right-1 -top-1 min-w-7 rounded-full bg-[#0f1419] px-1.5 py-0.5 text-center text-[11px] font-bold leading-5 text-white ring-2 ring-white`,children:e>99?`99+`:A(e)})]})}function q({data:e,onViewportChange:t}){let{module:n,error:r}=U(),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(b),[s,c]=(0,B.useState)(null),l=(0,B.useMemo)(()=>O(e.features),[e]),u=(0,B.useMemo)(()=>l.getClusters(a.bounds,Math.max(0,Math.floor(a.zoom))),[l,a]);(0,B.useEffect)(()=>{c(null)},[e]);let d=(0,B.useCallback)(e=>{let n=x(e.target);n&&(o(n),t(n))},[t]);if(!e.config.mapboxToken)return(0,V.jsx)(J,{data:e});if(r)return(0,V.jsxs)(`div`,{className:g,children:[(0,V.jsx)(z,{className:`mr-2 inline size-4`,strokeWidth:1.8}),r]});if(!n)return(0,V.jsx)(`div`,{className:g,children:`Loading map...`});let{default:f,Marker:p,NavigationControl:m,Popup:h}=n;return(0,V.jsx)(`div`,{className:`min-h-[520px] flex-1 overflow-hidden bg-[var(--bg-active)] min-[1180px]:min-h-0`,children:(0,V.jsxs)(f,{ref:i,initialViewState:{longitude:9,latitude:24,zoom:1.2},mapStyle:document.documentElement.dataset.theme===`dark`?`mapbox://styles/mapbox/dark-v11`:`mapbox://styles/mapbox/light-v11`,mapboxAccessToken:e.config.mapboxToken,onClick:()=>c(null),onLoad:d,onMoveEnd:d,projection:`mercator`,style:{width:`100%`,height:`100%`},children:[(0,V.jsx)(m,{position:`top-right`,showCompass:!1}),u.map(t=>{let[n,r]=t.geometry.coordinates;if(j(t)){let n=t.geometry.coordinates,r=l.getLeaves(t.properties.cluster_id,48).map(t=>e.features[t.properties.featureIndex]).filter(e=>!!e).sort(y),[o,s]=k(r,n);return(0,V.jsx)(p,{longitude:o,latitude:s,anchor:`center`,onClick:e=>{e.originalEvent?.stopPropagation();let n=Math.min(l.getClusterExpansionZoom(t.properties.cluster_id),12);i.current?.flyTo?.({center:[o,s],zoom:Math.max(a.zoom+.85,n-.6),duration:520}),c({kind:`cluster`,coordinates:[o,s],count:t.properties.point_count,features:r,stats:t.properties})},children:(0,V.jsx)(K,{count:t.properties.point_count,features:r,stats:t.properties})},`cluster-${String(t.properties.cluster_id)}`)}let o=e.features[t.properties.featureIndex];return o?(0,V.jsx)(p,{longitude:n,latitude:r,anchor:`center`,onClick:e=>{e.originalEvent?.stopPropagation(),c({kind:`profile`,feature:o})},children:(0,V.jsx)(G,{feature:o})},o.properties.profileId):null}),s?(0,V.jsx)(h,{longitude:s.kind===`profile`?s.feature.geometry.coordinates[0]:s.coordinates[0],latitude:s.kind===`profile`?s.feature.geometry.coordinates[1]:s.coordinates[1],closeButton:!1,offset:12,onClose:()=>c(null),children:s.kind===`profile`?(0,V.jsx)(Y,{feature:s.feature}):(0,V.jsx)(X,{count:s.count,features:s.features,stats:s.stats})}):null]})})}function J({data:e}){let t=e.features.slice(0,1500).map(e=>{let[t,n]=e.geometry.coordinates;return{feature:e,x:(t+180)/360*1e3,y:(90-n)/180*500}});return(0,V.jsx)(`div`,{className:`border-b border-[var(--line)] bg-[var(--bg-active)] px-4 py-4`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 1000 500`,className:`h-auto w-full rounded-md border border-[var(--line)] bg-[var(--bg)]`,role:`img`,"aria-label":`Network map`,children:[(0,V.jsx)(`defs`,{children:(0,V.jsx)(`pattern`,{id:`map-grid`,width:`100`,height:`100`,patternUnits:`userSpaceOnUse`,children:(0,V.jsx)(`path`,{d:`M 100 0 L 0 0 0 100`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.08`,strokeWidth:`1`})})}),(0,V.jsx)(`rect`,{width:`1000`,height:`500`,fill:`url(#map-grid)`}),(0,V.jsx)(`path`,{d:`M60 205 C145 155 210 145 280 178 C352 212 424 186 495 194 C594 206 665 157 746 178 C836 201 907 227 952 282`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.18`,strokeWidth:`36`,strokeLinecap:`round`}),t.map(({feature:e,x:t,y:n})=>(0,V.jsx)(`circle`,{cx:t,cy:n,r:e.properties.relationship===`mutual`?4.5:3.5,fill:e.properties.relationship===`mutual`?`#22c55e`:e.properties.relationship===`following`?`#f59e0b`:`#1d9bf0`,opacity:`0.86`},e.properties.profileId))]})})}function Y({feature:e}){return(0,V.jsxs)(`div`,{className:`flex max-w-[280px] gap-3 text-[13px] text-[#0f1419]`,children:[(0,V.jsx)(W,{feature:e,size:48,className:`ring-[#d9e2ea]`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate font-bold`,children:e.properties.name}),(0,V.jsxs)(`div`,{className:`truncate text-[#536471]`,children:[`@`,e.properties.handle]}),(0,V.jsx)(`div`,{className:`mt-1 line-clamp-2`,children:e.properties.location}),e.properties.resolvedLocation?(0,V.jsx)(`div`,{className:`truncate text-[#536471]`,children:e.properties.resolvedLocation}):null]})]})}function X({count:e,features:t,stats:n}){return(0,V.jsxs)(`div`,{className:`w-[290px] text-[13px] text-[#0f1419]`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`font-bold`,children:[A(e),` profiles here`]}),(0,V.jsxs)(`div`,{className:`text-[#536471]`,children:[A(n.mutual),` mutual ·`,` `,A(n.following),` following ·`,` `,A(n.followers),` followers`]})]}),(0,V.jsx)(`div`,{className:`size-11 shrink-0 rounded-full ring-2 ring-[#d9e2ea]`,style:{background:L(n)}})]}),(0,V.jsx)(`div`,{className:`mt-3 flex -space-x-2`,children:t.slice(0,6).map(e=>(0,V.jsx)(W,{feature:e,size:36,className:`ring-[#ffffff]`},e.properties.profileId))}),(0,V.jsx)(`div`,{className:`mt-3 divide-y divide-[#eff3f4]`,children:t.slice(0,5).map(e=>(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-2`,children:[(0,V.jsx)(W,{feature:e,size:28,className:`ring-[#ffffff]`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-semibold`,children:e.properties.name}),(0,V.jsxs)(`div`,{className:`truncate text-[#536471]`,children:[`@`,e.properties.handle]})]}),(0,V.jsx)(`div`,{className:`size-2 rounded-full`,style:{backgroundColor:w(e.properties.relationship)}})]},e.properties.profileId))})]})}function Z({feature:e}){return(0,V.jsxs)(`a`,{className:`flex min-w-0 gap-3 border-b border-[var(--line)] px-4 py-3 transition-colors hover:bg-[var(--bg-hover)]`,href:`/profiles/${encodeURIComponent(e.properties.handle)}`,children:[(0,V.jsx)(W,{feature:e,size:40,className:`ring-[var(--bg)]`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`truncate font-bold text-[var(--ink)]`,children:e.properties.name}),(0,V.jsxs)(`span`,{className:`truncate text-[var(--ink-soft)]`,children:[`@`,e.properties.handle]})]}),(0,V.jsxs)(`div`,{className:`truncate text-[13px] text-[var(--ink-soft)]`,children:[e.properties.location,e.properties.resolvedLocation?` -> ${e.properties.resolvedLocation}`:``]}),(0,V.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2 text-[12px] text-[var(--ink-soft)]`,children:[(0,V.jsx)(`span`,{children:S(e.properties.relationship)}),(0,V.jsxs)(`span`,{children:[A(e.properties.followersCount),` followers`]})]})]})]})}function Q({features:e,search:t,onSearchChange:n,totalVisible:r,zoom:i}){return(0,V.jsxs)(`aside`,{className:`flex min-h-[420px] min-w-0 flex-col border-t border-[var(--line)] bg-[var(--bg)] min-[1180px]:h-full min-[1180px]:border-t-0 min-[1180px]:border-l`,children:[(0,V.jsxs)(`header`,{className:`sticky top-0 z-10 border-b border-[var(--line)] bg-[color:color-mix(in_srgb,var(--bg)_88%,transparent)] px-4 py-3 backdrop-blur`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`truncate text-[16px] font-bold text-[var(--ink)]`,children:`Who's In View`}),(0,V.jsxs)(`p`,{className:`truncate text-[13px] text-[var(--ink-soft)]`,children:[A(r),` in this map view · zoom`,` `,i.toFixed(1)]})]}),(0,V.jsx)(`div`,{className:`rounded-full border border-[var(--line)] px-2 py-1 text-[12px] font-semibold text-[var(--ink-soft)]`,children:A(e.length)})]}),(0,V.jsxs)(`label`,{className:o(m,`mt-3 h-10`),children:[(0,V.jsx)(v,{className:l,strokeWidth:2}),(0,V.jsx)(`input`,{className:p,onChange:e=>n(e.target.value),placeholder:`Search visible people`,value:t})]})]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.length>0?e.map(e=>(0,V.jsx)(Z,{feature:e},e.properties.profileId)):(0,V.jsx)(`div`,{className:g,children:t.trim()?`No visible profiles match that search.`:`Pan or zoom the map to see profiles in this area.`})})]})}function te(){let e=E.useSearch(),t=E.useNavigate();return(0,V.jsx)($,{searchState:e,onSearchChange:(e,n)=>void t({search:e,replace:n?.replace})})}function $({searchState:e,onSearchChange:t}={}){let[a,l]=(0,B.useState)(()=>I({})),{type:p,setType:m,viewport:_,setViewport:v,visibleSearch:y,setVisibleSearch:b,data:x,loading:S,error:C,refresh:w,visibleFeatures:T,filteredVisibleFeatures:E,mapTypes:O}=D(e??a,(e,n)=>t?t(e,n):l(e));return(0,V.jsxs)(`section`,{className:`flex min-h-screen flex-col min-[1180px]:h-screen min-[1180px]:min-h-0 min-[1180px]:overflow-hidden`,children:[(0,V.jsxs)(`header`,{className:s,children:[(0,V.jsxs)(`div`,{className:c,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:i,children:`Network Map`}),(0,V.jsx)(`div`,{className:n,children:x?`${A(x.meta.locatedProfiles)} located · ${A(x.meta.meaningfulProfiles)} with usable locations`:`Loading network geography...`})]}),(0,V.jsx)(`div`,{className:r,children:(0,V.jsxs)(`button`,{className:u,type:`button`,onClick:()=>w(),disabled:S,children:[(0,V.jsx)(F,{className:o(`size-4`,S&&`animate-spin`)}),`Refresh`]})})]}),(0,V.jsx)(`div`,{className:`border-t border-[var(--line)] px-4 py-3`,children:(0,V.jsx)(`div`,{className:d,children:O.map(e=>(0,V.jsx)(`button`,{type:`button`,className:o(h,p===e.value&&`bg-[var(--bg-active)] text-[var(--ink)]`),onClick:()=>m(e.value),children:e.label},e.value))})})]}),C?(0,V.jsx)(`div`,{className:f,children:C}):null,x?(0,V.jsxs)(`div`,{className:`grid min-h-[620px] flex-1 grid-cols-1 min-[1180px]:min-h-0 min-[1180px]:grid-cols-[minmax(0,1fr)_390px] min-[1180px]:overflow-hidden min-[1500px]:grid-cols-[minmax(0,1fr)_430px]`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsxs)(`div`,{className:`grid sm:grid-cols-4`,children:[(0,V.jsx)(H,{icon:ee,label:`Profiles`,value:x.meta.totalProfiles}),(0,V.jsx)(H,{icon:R,label:`Locations`,value:x.meta.meaningfulProfiles}),(0,V.jsx)(H,{icon:P,label:`Located`,value:x.meta.locatedProfiles}),(0,V.jsx)(H,{icon:F,label:`Geocoded`,value:x.meta.geocodedThisRun})]}),!x.meta.opencageConfigured&&x.meta.missingGeocodes>0?(0,V.jsx)(`div`,{className:g,children:`OpenCage key missing; showing cached and coordinate locations only.`}):null,x.meta.mapboxTokenConfigured?null:(0,V.jsx)(`div`,{className:g,children:`Mapbox token missing; showing the lightweight map.`}),(0,V.jsx)(q,{data:x,onViewportChange:v})]}),(0,V.jsx)(Q,{features:E,onSearchChange:b,search:y,totalVisible:T.length,zoom:_.zoom})]}):S?(0,V.jsx)(`div`,{className:g,children:`Loading map...`}):null]})}export{$ as NetworkMapRouteView,te as component};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mapbox-B4zqX7r0.js","assets/chunk-C0phanGV.js","assets/index-DZVisyna.js","assets/query-client-fYu2rzRC.js","assets/schemas-I9r6F6ya.js","assets/react-nBylq1U5.js","assets/createLucideIcon-JV8isFFR.js","assets/circle-check-C_Vq3ElD.js","assets/client-stream-contracts-sR4xMQxY.js","assets/AvatarChip-DLoqM5xD.js","assets/ProfilePreview-DQX6_xc3.js","assets/SmartTimestamp-BR0-9se2.js","assets/sparkles-CQVlvHsZ.js","assets/react-dom-DHl6Ug7F.js","assets/profile-hydration-client-YEtJsNTv.js","assets/index-bpFrQ5yG.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,an as l,cn as u,dn as d,dt as f,on as p,sn as m,un as h,wn as g}from"./schemas-I9r6F6ya.js";import{t as _}from"./createLucideIcon-JV8isFFR.js";import{t as v}from"./search-Dq5kYsxA.js";import{t as ee}from"./users-CHbKlqUr.js";import{B as y,F as b,G as x,H as S,I as C,K as w,L as T,N as E,P as D,R as O,U as k,V as A,W as j,X as M,Y as N,_t as P,ft as F,nt as I,z as L}from"./index-DZVisyna.js";var R=_(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),z=_(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),B=e(t()),V=a();M();function H({icon:e,label:t,value:n}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-b border-[var(--line)] px-4 py-3 sm:border-r`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,V.jsx)(e,{className:`size-4`,strokeWidth:1.8}),(0,V.jsx)(`span`,{children:t})]}),(0,V.jsx)(`div`,{className:`truncate text-[24px] font-bold tracking-tight text-[var(--ink)]`,children:A(n)})]})}function U(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(null);return(0,B.useEffect)(()=>{let e=!1;return N(()=>import(`./mapbox-B4zqX7r0.js`).then(n=>{e||t(n)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])).catch(t=>{e||r(t instanceof Error?t.message:`Map failed`)}),()=>{e=!0}},[]),{module:e,error:n}}function W({feature:e,size:t=36,className:n,style:r}){let i=T(e),[a,s]=(0,B.useState)(null),c=i&&a!==i;return(0,V.jsx)(`div`,{className:o(`relative grid shrink-0 place-items-center overflow-hidden rounded-full bg-[var(--accent-soft)] text-[12px] font-bold text-[var(--accent)] ring-2 ring-white`,n),style:{width:t,height:t,...r},children:c?(0,V.jsx)(`img`,{src:i,alt:``,className:`h-full w-full object-cover`,loading:`lazy`,onError:()=>s(i)}):(0,V.jsx)(`span`,{children:C(e)})})}function G({feature:e}){let t=w(e.properties.relationship);return(0,V.jsxs)(`button`,{type:`button`,className:`group relative grid size-11 place-items-center rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-110`,"aria-label":`Open @${e.properties.handle}`,title:`@${e.properties.handle}`,children:[(0,V.jsx)(`span`,{className:`absolute inset-0 rounded-full opacity-90 shadow-[0_10px_28px_rgba(15,20,25,0.28)]`,style:{backgroundColor:t}}),(0,V.jsx)(W,{feature:e,size:34,className:`relative ring-[3px]`})]})}function K({count:e,features:t,stats:n}){let r=Math.min(82,Math.max(52,44+Math.log2(e)*7)),i=r>=72?30:25;return(0,V.jsxs)(`button`,{type:`button`,className:`group relative rounded-full border-0 bg-transparent p-0 transition-transform hover:z-10 hover:scale-105`,"aria-label":`${A(e)} located profiles`,title:`${A(e)} profiles`,style:{width:r,height:r},children:[(0,V.jsx)(`span`,{className:`absolute inset-0 rounded-full opacity-95 shadow-[0_18px_42px_rgba(15,20,25,0.32)]`,style:{background:L(n)}}),(0,V.jsx)(`span`,{className:`absolute inset-[4px] rounded-full bg-white/88 backdrop-blur-sm`}),(0,V.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:t.slice(0,4).map((e,t)=>(0,V.jsx)(W,{feature:e,size:i,className:`absolute`,style:{transform:`translate(${[-10,10,-7,8][t]??0}px, ${[-9,-8,11,10][t]??0}px)`}},e.properties.profileId))}),(0,V.jsx)(`span`,{className:`absolute -right-1 -top-1 min-w-7 rounded-full bg-[#0f1419] px-1.5 py-0.5 text-center text-[11px] font-bold leading-5 text-white ring-2 ring-white`,children:e>99?`99+`:A(e)})]})}function q({data:e,onViewportChange:t}){let{module:n,error:r}=U(),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(b),[s,c]=(0,B.useState)(null),l=(0,B.useMemo)(()=>O(e.features),[e]),u=(0,B.useMemo)(()=>l.getClusters(a.bounds,Math.max(0,Math.floor(a.zoom))),[l,a]);(0,B.useEffect)(()=>{c(null)},[e]);let d=(0,B.useCallback)(e=>{let n=x(e.target);n&&(o(n),t(n))},[t]);if(!e.config.mapboxToken)return(0,V.jsx)(J,{data:e});if(r)return(0,V.jsxs)(`div`,{className:g,children:[(0,V.jsx)(z,{className:`mr-2 inline size-4`,strokeWidth:1.8}),r]});if(!n)return(0,V.jsx)(`div`,{className:g,children:`Loading map...`});let{default:f,Marker:p,NavigationControl:m,Popup:h}=n;return(0,V.jsx)(`div`,{className:`min-h-[520px] flex-1 overflow-hidden bg-[var(--bg-active)] min-[1180px]:min-h-0`,children:(0,V.jsxs)(f,{ref:i,initialViewState:{longitude:9,latitude:24,zoom:1.2},mapStyle:document.documentElement.dataset.theme===`dark`?`mapbox://styles/mapbox/dark-v11`:`mapbox://styles/mapbox/light-v11`,mapboxAccessToken:e.config.mapboxToken,onClick:()=>c(null),onLoad:d,onMoveEnd:d,projection:`mercator`,style:{width:`100%`,height:`100%`},children:[(0,V.jsx)(m,{position:`top-right`,showCompass:!1}),u.map(t=>{let[n,r]=t.geometry.coordinates;if(j(t)){let n=t.geometry.coordinates,r=l.getLeaves(t.properties.cluster_id,48).map(t=>e.features[t.properties.featureIndex]).filter(e=>!!e).sort(y),[o,s]=k(r,n);return(0,V.jsx)(p,{longitude:o,latitude:s,anchor:`center`,onClick:e=>{e.originalEvent?.stopPropagation();let n=Math.min(l.getClusterExpansionZoom(t.properties.cluster_id),12);i.current?.flyTo?.({center:[o,s],zoom:Math.max(a.zoom+.85,n-.6),duration:520}),c({kind:`cluster`,coordinates:[o,s],count:t.properties.point_count,features:r,stats:t.properties})},children:(0,V.jsx)(K,{count:t.properties.point_count,features:r,stats:t.properties})},`cluster-${String(t.properties.cluster_id)}`)}let o=e.features[t.properties.featureIndex];return o?(0,V.jsx)(p,{longitude:n,latitude:r,anchor:`center`,onClick:e=>{e.originalEvent?.stopPropagation(),c({kind:`profile`,feature:o})},children:(0,V.jsx)(G,{feature:o})},o.properties.profileId):null}),s?(0,V.jsx)(h,{longitude:s.kind===`profile`?s.feature.geometry.coordinates[0]:s.coordinates[0],latitude:s.kind===`profile`?s.feature.geometry.coordinates[1]:s.coordinates[1],closeButton:!1,offset:12,onClose:()=>c(null),children:s.kind===`profile`?(0,V.jsx)(Y,{feature:s.feature}):(0,V.jsx)(X,{count:s.count,features:s.features,stats:s.stats})}):null]})})}function J({data:e}){let t=e.features.slice(0,1500).map(e=>{let[t,n]=e.geometry.coordinates;return{feature:e,x:(t+180)/360*1e3,y:(90-n)/180*500}});return(0,V.jsx)(`div`,{className:`border-b border-[var(--line)] bg-[var(--bg-active)] px-4 py-4`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 1000 500`,className:`h-auto w-full rounded-md border border-[var(--line)] bg-[var(--bg)]`,role:`img`,"aria-label":`Network map`,children:[(0,V.jsx)(`defs`,{children:(0,V.jsx)(`pattern`,{id:`map-grid`,width:`100`,height:`100`,patternUnits:`userSpaceOnUse`,children:(0,V.jsx)(`path`,{d:`M 100 0 L 0 0 0 100`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.08`,strokeWidth:`1`})})}),(0,V.jsx)(`rect`,{width:`1000`,height:`500`,fill:`url(#map-grid)`}),(0,V.jsx)(`path`,{d:`M60 205 C145 155 210 145 280 178 C352 212 424 186 495 194 C594 206 665 157 746 178 C836 201 907 227 952 282`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.18`,strokeWidth:`36`,strokeLinecap:`round`}),t.map(({feature:e,x:t,y:n})=>(0,V.jsx)(`circle`,{cx:t,cy:n,r:e.properties.relationship===`mutual`?4.5:3.5,fill:e.properties.relationship===`mutual`?`#22c55e`:e.properties.relationship===`following`?`#f59e0b`:`#1d9bf0`,opacity:`0.86`},e.properties.profileId))]})})}function Y({feature:e}){return(0,V.jsxs)(`div`,{className:`flex max-w-[280px] gap-3 text-[13px] text-[#0f1419]`,children:[(0,V.jsx)(W,{feature:e,size:48,className:`ring-[#d9e2ea]`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate font-bold`,children:e.properties.name}),(0,V.jsxs)(`div`,{className:`truncate text-[#536471]`,children:[`@`,e.properties.handle]}),(0,V.jsx)(`div`,{className:`mt-1 line-clamp-2`,children:e.properties.location}),e.properties.resolvedLocation?(0,V.jsx)(`div`,{className:`truncate text-[#536471]`,children:e.properties.resolvedLocation}):null]})]})}function X({count:e,features:t,stats:n}){return(0,V.jsxs)(`div`,{className:`w-[290px] text-[13px] text-[#0f1419]`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`font-bold`,children:[A(e),` profiles here`]}),(0,V.jsxs)(`div`,{className:`text-[#536471]`,children:[A(n.mutual),` mutual ·`,` `,A(n.following),` following ·`,` `,A(n.followers),` followers`]})]}),(0,V.jsx)(`div`,{className:`size-11 shrink-0 rounded-full ring-2 ring-[#d9e2ea]`,style:{background:L(n)}})]}),(0,V.jsx)(`div`,{className:`mt-3 flex -space-x-2`,children:t.slice(0,6).map(e=>(0,V.jsx)(W,{feature:e,size:36,className:`ring-[#ffffff]`},e.properties.profileId))}),(0,V.jsx)(`div`,{className:`mt-3 divide-y divide-[#eff3f4]`,children:t.slice(0,5).map(e=>(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-2`,children:[(0,V.jsx)(W,{feature:e,size:28,className:`ring-[#ffffff]`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-semibold`,children:e.properties.name}),(0,V.jsxs)(`div`,{className:`truncate text-[#536471]`,children:[`@`,e.properties.handle]})]}),(0,V.jsx)(`div`,{className:`size-2 rounded-full`,style:{backgroundColor:w(e.properties.relationship)}})]},e.properties.profileId))})]})}function Z({feature:e}){return(0,V.jsxs)(`a`,{className:`flex min-w-0 gap-3 border-b border-[var(--line)] px-4 py-3 transition-colors hover:bg-[var(--bg-hover)]`,href:`/profiles/${encodeURIComponent(e.properties.handle)}`,children:[(0,V.jsx)(W,{feature:e,size:40,className:`ring-[var(--bg)]`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`truncate font-bold text-[var(--ink)]`,children:e.properties.name}),(0,V.jsxs)(`span`,{className:`truncate text-[var(--ink-soft)]`,children:[`@`,e.properties.handle]})]}),(0,V.jsxs)(`div`,{className:`truncate text-[13px] text-[var(--ink-soft)]`,children:[e.properties.location,e.properties.resolvedLocation?` -> ${e.properties.resolvedLocation}`:``]}),(0,V.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2 text-[12px] text-[var(--ink-soft)]`,children:[(0,V.jsx)(`span`,{children:S(e.properties.relationship)}),(0,V.jsxs)(`span`,{children:[A(e.properties.followersCount),` followers`]})]})]})]})}function Q({features:e,search:t,onSearchChange:n,totalVisible:r,zoom:i}){return(0,V.jsxs)(`aside`,{className:`flex min-h-[420px] min-w-0 flex-col border-t border-[var(--line)] bg-[var(--bg)] min-[1180px]:h-full min-[1180px]:border-t-0 min-[1180px]:border-l`,children:[(0,V.jsxs)(`header`,{className:`sticky top-0 z-10 border-b border-[var(--line)] bg-[color:color-mix(in_srgb,var(--bg)_88%,transparent)] px-4 py-3 backdrop-blur`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`truncate text-[16px] font-bold text-[var(--ink)]`,children:`Who's In View`}),(0,V.jsxs)(`p`,{className:`truncate text-[13px] text-[var(--ink-soft)]`,children:[A(r),` in this map view · zoom`,` `,i.toFixed(1)]})]}),(0,V.jsx)(`div`,{className:`rounded-full border border-[var(--line)] px-2 py-1 text-[12px] font-semibold text-[var(--ink-soft)]`,children:A(e.length)})]}),(0,V.jsxs)(`label`,{className:o(m,`mt-3 h-10`),children:[(0,V.jsx)(v,{className:l,strokeWidth:2}),(0,V.jsx)(`input`,{className:p,onChange:e=>n(e.target.value),placeholder:`Search visible people`,value:t})]})]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.length>0?e.map(e=>(0,V.jsx)(Z,{feature:e},e.properties.profileId)):(0,V.jsx)(`div`,{className:g,children:t.trim()?`No visible profiles match that search.`:`Pan or zoom the map to see profiles in this area.`})})]})}function te(){let e=E.useSearch(),t=E.useNavigate();return(0,V.jsx)($,{searchState:e,onSearchChange:(e,n)=>void t({search:e,replace:n?.replace})})}function $({searchState:e,onSearchChange:t}={}){let[a,l]=(0,B.useState)(()=>I({})),{type:p,setType:m,viewport:_,setViewport:v,visibleSearch:y,setVisibleSearch:b,data:x,loading:S,error:C,refresh:w,visibleFeatures:T,filteredVisibleFeatures:E,mapTypes:O}=D(e??a,(e,n)=>t?t(e,n):l(e));return(0,V.jsxs)(`section`,{className:`flex min-h-screen flex-col min-[1180px]:h-screen min-[1180px]:min-h-0 min-[1180px]:overflow-hidden`,children:[(0,V.jsxs)(`header`,{className:s,children:[(0,V.jsxs)(`div`,{className:c,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:i,children:`Network Map`}),(0,V.jsx)(`div`,{className:n,children:x?`${A(x.meta.locatedProfiles)} located · ${A(x.meta.meaningfulProfiles)} with usable locations`:`Loading network geography...`})]}),(0,V.jsx)(`div`,{className:r,children:(0,V.jsxs)(`button`,{className:u,type:`button`,onClick:()=>w(),disabled:S,children:[(0,V.jsx)(F,{className:o(`size-4`,S&&`animate-spin`)}),`Refresh`]})})]}),(0,V.jsx)(`div`,{className:`border-t border-[var(--line)] px-4 py-3`,children:(0,V.jsx)(`div`,{className:d,children:O.map(e=>(0,V.jsx)(`button`,{type:`button`,className:o(h,p===e.value&&`bg-[var(--bg-active)] text-[var(--ink)]`),onClick:()=>m(e.value),children:e.label},e.value))})})]}),C?(0,V.jsx)(`div`,{className:f,children:C}):null,x?(0,V.jsxs)(`div`,{className:`grid min-h-[620px] flex-1 grid-cols-1 min-[1180px]:min-h-0 min-[1180px]:grid-cols-[minmax(0,1fr)_390px] min-[1180px]:overflow-hidden min-[1500px]:grid-cols-[minmax(0,1fr)_430px]`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsxs)(`div`,{className:`grid sm:grid-cols-4`,children:[(0,V.jsx)(H,{icon:ee,label:`Profiles`,value:x.meta.totalProfiles}),(0,V.jsx)(H,{icon:R,label:`Locations`,value:x.meta.meaningfulProfiles}),(0,V.jsx)(H,{icon:P,label:`Located`,value:x.meta.locatedProfiles}),(0,V.jsx)(H,{icon:F,label:`Geocoded`,value:x.meta.geocodedThisRun})]}),!x.meta.opencageConfigured&&x.meta.missingGeocodes>0?(0,V.jsx)(`div`,{className:g,children:`OpenCage key missing; showing cached and coordinate locations only.`}):null,x.meta.mapboxTokenConfigured?null:(0,V.jsx)(`div`,{className:g,children:`Mapbox token missing; showing the lightweight map.`}),(0,V.jsx)(q,{data:x,onViewportChange:v})]}),(0,V.jsx)(Q,{features:E,onSearchChange:b,search:y,totalVisible:T.length,zoom:_.zoom})]}):S?(0,V.jsx)(`div`,{className:g,children:`Loading map...`}):null]})}export{$ as NetworkMapRouteView,te as component};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,Xt as l,an as u,cn as d,on as f,sn as p}from"./schemas-I9r6F6ya.js";import{s as m}from"./client-stream-contracts-ys3XhWG4.js";import{t as h}from"./search-Dq5kYsxA.js";import{a as g,dt as _,ft as v,i as y,n as b,o as x,q as S,r as C}from"./index-CEIG7S6s.js";var w=e(t()),T=a();function E(){let e=S.useSearch(),[t,a]=(0,w.useState)(g(e.handle)),E=(0,w.useMemo)(()=>g(t),[t]),D=y(E),O=(0,w.useRef)(``),k=(0,w.useRef)(D.run);return(0,w.useEffect)(()=>{k.current=D.run},[D.run]),(0,w.useEffect)(()=>{let t=g(e.handle);a(t),t&&O.current!==t&&(O.current=t,k.current(!1,t))},[e.handle]),(0,T.jsxs)(`section`,{className:`flex min-h-screen flex-col gap-6 px-4 py-8`,children:[(0,T.jsxs)(`header`,{className:o(s,`border-b-0`),children:[(0,T.jsxs)(`div`,{className:c,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h1`,{className:i,children:`Profile Analyse`}),(0,T.jsx)(`p`,{className:n,children:x(D.context)})]}),(0,T.jsx)(`div`,{className:r,children:(0,T.jsxs)(`button`,{className:d,disabled:!E||D.loading,onClick:()=>D.run(!0),type:`button`,children:[(0,T.jsx)(v,{className:`size-4`,strokeWidth:1.8}),`Refresh`]})})]}),(0,T.jsxs)(`form`,{className:`mt-5 flex flex-col gap-3 sm:flex-row`,onSubmit:e=>{e.preventDefault(),D.run(!1)},children:[(0,T.jsxs)(`label`,{className:o(p,`min-w-0 flex-1`),children:[(0,T.jsx)(h,{className:u,strokeWidth:1.8}),(0,T.jsx)(`input`,{className:f,onChange:e=>a(e.target.value),placeholder:`handle`,value:t})]}),(0,T.jsxs)(`button`,{className:l,disabled:!E||D.loading,type:`submit`,children:[D.loading?(0,T.jsx)(m,{className:`size-4 animate-spin`,strokeWidth:1.8}):(0,T.jsx)(_,{className:`size-4`,strokeWidth:1.8}),`Analyse`]})]})]}),(0,T.jsx)(C,{analysis:D}),(0,T.jsx)(b,{analysis:D})]})}export{E as component};
1
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,Xt as l,an as u,cn as d,on as f,sn as p}from"./schemas-I9r6F6ya.js";import{s as m}from"./client-stream-contracts-sR4xMQxY.js";import{t as h}from"./search-Dq5kYsxA.js";import{a as g,dt as _,ft as v,i as y,n as b,o as x,q as S,r as C}from"./index-DZVisyna.js";var w=e(t()),T=a();function E(){let e=S.useSearch(),[t,a]=(0,w.useState)(g(e.handle)),E=(0,w.useMemo)(()=>g(t),[t]),D=y(E),O=(0,w.useRef)(``),k=(0,w.useRef)(D.run);return(0,w.useEffect)(()=>{k.current=D.run},[D.run]),(0,w.useEffect)(()=>{let t=g(e.handle);a(t),t&&O.current!==t&&(O.current=t,k.current(!1,t))},[e.handle]),(0,T.jsxs)(`section`,{className:`flex min-h-screen flex-col gap-6 px-4 py-8`,children:[(0,T.jsxs)(`header`,{className:o(s,`border-b-0`),children:[(0,T.jsxs)(`div`,{className:c,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h1`,{className:i,children:`Profile Analyse`}),(0,T.jsx)(`p`,{className:n,children:x(D.context)})]}),(0,T.jsx)(`div`,{className:r,children:(0,T.jsxs)(`button`,{className:d,disabled:!E||D.loading,onClick:()=>D.run(!0),type:`button`,children:[(0,T.jsx)(v,{className:`size-4`,strokeWidth:1.8}),`Refresh`]})})]}),(0,T.jsxs)(`form`,{className:`mt-5 flex flex-col gap-3 sm:flex-row`,onSubmit:e=>{e.preventDefault(),D.run(!1)},children:[(0,T.jsxs)(`label`,{className:o(p,`min-w-0 flex-1`),children:[(0,T.jsx)(h,{className:u,strokeWidth:1.8}),(0,T.jsx)(`input`,{className:f,onChange:e=>a(e.target.value),placeholder:`handle`,value:t})]}),(0,T.jsxs)(`button`,{className:l,disabled:!E||D.loading,type:`submit`,children:[D.loading?(0,T.jsx)(m,{className:`size-4 animate-spin`,strokeWidth:1.8}):(0,T.jsx)(_,{className:`size-4`,strokeWidth:1.8}),`Analyse`]})]})]}),(0,T.jsx)(C,{analysis:D}),(0,T.jsx)(b,{analysis:D})]})}export{E as component};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Ln as n}from"./schemas-I9r6F6ya.js";import{s as r}from"./client-stream-contracts-ys3XhWG4.js";import{r as i,t as a}from"./AvatarChip-DLoqM5xD.js";import{l as o}from"./ProfilePreview-BejAuYsJ.js";import{a as s,ft as c,gt as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./index-CEIG7S6s.js";var g=e(t()),_=n(),v=`inline-flex items-center justify-center gap-1.5 rounded-full border border-[var(--line-strong)] bg-[var(--bg)] px-4 py-1.5 text-[14px] font-bold text-[var(--ink)] shadow-sm transition-colors duration-150 hover:bg-[var(--bg-hover)] disabled:cursor-default disabled:opacity-55`,y=/(^|[^\w@./])@([A-Za-z0-9_]{1,15})\b/g;function b(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return t}function x(){let{handle:e}=h.useParams();return(0,_.jsx)(T,{handle:e})}function S(e){let t=new Map;if(!e)return t;t.set(e.profile.handle.toLowerCase(),e.profile);for(let n of e.profiles??[])t.set(n.handle.toLowerCase(),n);for(let n of e.conversations)t.set(n.author.toLowerCase(),{id:n.profileId,handle:n.author,displayName:n.name||n.author,bio:n.bio,followersCount:n.followersCount,avatarHue:210,avatarUrl:n.avatarUrl,createdAt:n.createdAt});return t}function C(e,t){let n=o(e.entities),r=n.mentions??[],i=new Set(r.map(e=>`${e.start}:${e.end}`));for(let n of e.bio.matchAll(y)){let e=(n.index??0)+n[1].length,a=n[2],o=e+a.length+1,s=`${e}:${o}`;if(i.has(s))continue;let c=t.get(a.toLowerCase());r.push({username:a,start:e,end:o,...c?{profile:c}:{}})}return{...n,...r.length?{mentions:r}:{}}}function w({profile:e,profilesByHandle:t}){return(0,_.jsx)(m,{className:`m-0 max-w-2xl whitespace-pre-wrap text-[15px] leading-[1.45] text-[var(--ink)] [overflow-wrap:anywhere]`,entities:C(e,t),text:e.bio,urlLabel:`expanded`})}function T({handle:e}){let t=s(e),n=u(t),o=(0,g.useRef)(``),m=(0,g.useRef)(n.run),h=n.context?.profile,y=h?.displayName||`@${t}`,x=h?.bio??``,C=S(n.context);return(0,g.useEffect)(()=>{m.current=n.run},[n.run]),(0,g.useEffect)(()=>{t&&o.current!==t&&(o.current=t,m.current(!1,t))},[t]),(0,_.jsxs)(`section`,{className:`flex min-h-screen flex-col`,children:[(0,_.jsxs)(`header`,{className:`border-b border-[var(--line)] bg-[var(--bg)]`,children:[(0,_.jsx)(`div`,{className:`h-32 bg-[linear-gradient(135deg,color-mix(in_srgb,var(--bg-active)_68%,var(--accent)_32%),color-mix(in_srgb,var(--bg)_70%,var(--accent)_30%))]`,"data-testid":`profile-cover`}),(0,_.jsx)(`div`,{className:`px-4 pb-5`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsxs)(`div`,{className:`-mt-8 flex items-start justify-between gap-3`,"data-testid":`profile-avatar-overlap`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,_.jsx)(`span`,{className:`inline-grid rounded-full ring-4 ring-[var(--bg)]`,children:(0,_.jsx)(a,{avatarUrl:h?.avatarUrl??void 0,hue:h?.avatarHue??b(t),name:y,profileId:h?.id,size:`large`})}),(0,_.jsxs)(`div`,{className:`min-w-0 pb-1 pt-9`,children:[(0,_.jsx)(`h1`,{className:`m-0 truncate text-[24px] font-bold text-[var(--ink)]`,children:y}),(0,_.jsxs)(`div`,{className:`truncate text-[14px] text-[var(--ink-soft)]`,children:[`@`,h?.handle??t]})]})]}),(0,_.jsxs)(`div`,{className:`mt-10 flex shrink-0 items-center gap-2`,children:[(0,_.jsxs)(`a`,{className:v,href:`https://x.com/${encodeURIComponent(h?.handle??t)}`,rel:`noreferrer`,target:`_blank`,children:[(0,_.jsx)(l,{className:`size-4`,strokeWidth:1.8}),`X`]}),(0,_.jsxs)(`button`,{className:v,disabled:!t||n.loading,onClick:()=>n.run(!0,t),type:`button`,children:[n.loading?(0,_.jsx)(r,{className:`size-4 animate-spin`,strokeWidth:1.8}):(0,_.jsx)(c,{className:`size-4`,strokeWidth:1.8}),`Refresh`]})]})]}),h&&x?(0,_.jsx)(w,{profile:h,profilesByHandle:C}):null,(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[13px] text-[var(--ink-soft)]`,children:[h?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{className:`text-[var(--ink)]`,children:i(h.followersCount)}),` `,`followers`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{className:`text-[var(--ink)]`,children:i(h.followingCount??0)}),` `,`following`]})]}):null,(0,_.jsx)(`span`,{children:f(n.context)})]})]})})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-5 px-4 py-5`,children:[(0,_.jsx)(p,{analysis:n}),(0,_.jsx)(d,{analysis:n,emptyLabel:`Preparing @${t}.`})]})]})}export{T as ProfileRouteView,x as component};
1
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Ln as n}from"./schemas-I9r6F6ya.js";import{s as r}from"./client-stream-contracts-sR4xMQxY.js";import{r as i,t as a}from"./AvatarChip-DLoqM5xD.js";import{l as o}from"./ProfilePreview-DQX6_xc3.js";import{a as s,ft as c,gt as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./index-DZVisyna.js";var g=e(t()),_=n(),v=`inline-flex items-center justify-center gap-1.5 rounded-full border border-[var(--line-strong)] bg-[var(--bg)] px-4 py-1.5 text-[14px] font-bold text-[var(--ink)] shadow-sm transition-colors duration-150 hover:bg-[var(--bg-hover)] disabled:cursor-default disabled:opacity-55`,y=/(^|[^\w@./])@([A-Za-z0-9_]{1,15})\b/g;function b(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return t}function x(){let{handle:e}=h.useParams();return(0,_.jsx)(T,{handle:e})}function S(e){let t=new Map;if(!e)return t;t.set(e.profile.handle.toLowerCase(),e.profile);for(let n of e.profiles??[])t.set(n.handle.toLowerCase(),n);for(let n of e.conversations)t.set(n.author.toLowerCase(),{id:n.profileId,handle:n.author,displayName:n.name||n.author,bio:n.bio,followersCount:n.followersCount,avatarHue:210,avatarUrl:n.avatarUrl,createdAt:n.createdAt});return t}function C(e,t){let n=o(e.entities),r=n.mentions??[],i=new Set(r.map(e=>`${e.start}:${e.end}`));for(let n of e.bio.matchAll(y)){let e=(n.index??0)+n[1].length,a=n[2],o=e+a.length+1,s=`${e}:${o}`;if(i.has(s))continue;let c=t.get(a.toLowerCase());r.push({username:a,start:e,end:o,...c?{profile:c}:{}})}return{...n,...r.length?{mentions:r}:{}}}function w({profile:e,profilesByHandle:t}){return(0,_.jsx)(m,{className:`m-0 max-w-2xl whitespace-pre-wrap text-[15px] leading-[1.45] text-[var(--ink)] [overflow-wrap:anywhere]`,entities:C(e,t),text:e.bio,urlLabel:`expanded`})}function T({handle:e}){let t=s(e),n=u(t),o=(0,g.useRef)(``),m=(0,g.useRef)(n.run),h=n.context?.profile,y=h?.displayName||`@${t}`,x=h?.bio??``,C=S(n.context);return(0,g.useEffect)(()=>{m.current=n.run},[n.run]),(0,g.useEffect)(()=>{t&&o.current!==t&&(o.current=t,m.current(!1,t))},[t]),(0,_.jsxs)(`section`,{className:`flex min-h-screen flex-col`,children:[(0,_.jsxs)(`header`,{className:`border-b border-[var(--line)] bg-[var(--bg)]`,children:[(0,_.jsx)(`div`,{className:`h-32 bg-[linear-gradient(135deg,color-mix(in_srgb,var(--bg-active)_68%,var(--accent)_32%),color-mix(in_srgb,var(--bg)_70%,var(--accent)_30%))]`,"data-testid":`profile-cover`}),(0,_.jsx)(`div`,{className:`px-4 pb-5`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsxs)(`div`,{className:`-mt-8 flex items-start justify-between gap-3`,"data-testid":`profile-avatar-overlap`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,_.jsx)(`span`,{className:`inline-grid rounded-full ring-4 ring-[var(--bg)]`,children:(0,_.jsx)(a,{avatarUrl:h?.avatarUrl??void 0,hue:h?.avatarHue??b(t),name:y,profileId:h?.id,size:`large`})}),(0,_.jsxs)(`div`,{className:`min-w-0 pb-1 pt-9`,children:[(0,_.jsx)(`h1`,{className:`m-0 truncate text-[24px] font-bold text-[var(--ink)]`,children:y}),(0,_.jsxs)(`div`,{className:`truncate text-[14px] text-[var(--ink-soft)]`,children:[`@`,h?.handle??t]})]})]}),(0,_.jsxs)(`div`,{className:`mt-10 flex shrink-0 items-center gap-2`,children:[(0,_.jsxs)(`a`,{className:v,href:`https://x.com/${encodeURIComponent(h?.handle??t)}`,rel:`noreferrer`,target:`_blank`,children:[(0,_.jsx)(l,{className:`size-4`,strokeWidth:1.8}),`X`]}),(0,_.jsxs)(`button`,{className:v,disabled:!t||n.loading,onClick:()=>n.run(!0,t),type:`button`,children:[n.loading?(0,_.jsx)(r,{className:`size-4 animate-spin`,strokeWidth:1.8}):(0,_.jsx)(c,{className:`size-4`,strokeWidth:1.8}),`Refresh`]})]})]}),h&&x?(0,_.jsx)(w,{profile:h,profilesByHandle:C}):null,(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[13px] text-[var(--ink-soft)]`,children:[h?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{className:`text-[var(--ink)]`,children:i(h.followersCount)}),` `,`followers`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{className:`text-[var(--ink)]`,children:i(h.followingCount??0)}),` `,`following`]})]}):null,(0,_.jsx)(`span`,{children:f(n.context)})]})]})})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-5 px-4 py-5`,children:[(0,_.jsx)(p,{analysis:n}),(0,_.jsx)(d,{analysis:n,emptyLabel:`Preparing @${t}.`})]})]})}export{T as ProfileRouteView,x as component};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,cn as l,dt as u,wn as d}from"./schemas-I9r6F6ya.js";import{t as f}from"./createLucideIcon-JV8isFFR.js";import{t as p}from"./triangle-alert-CBL7s2pf.js";import{n as m,r as h,y as g}from"./query-client-fYu2rzRC.js";import{ct as _,ft as v,ht as y}from"./index-CEIG7S6s.js";var b=f(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),x=f(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),S=f(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),C=e(t()),w=a();async function T(){return h(`/api/xurl-rate-limits`,void 0,g,`Rate limits request failed`)}function E(e){return new Intl.NumberFormat().format(e)}function D(e,t){if(!e)return`never`;let n=new Date(e).getTime();if(!Number.isFinite(n))return`unknown`;let r=Math.max(0,Math.round((t-n)/1e3));if(r<60)return`${String(r)}s ago`;let i=Math.round(r/60);if(i<60)return`${String(i)}m ago`;let a=Math.round(i/60);return`${String(a)}h ago`}function O(e,t){if(!e)return`idle`;let n=new Date(e).getTime();if(!Number.isFinite(n))return`unknown`;let r=Math.max(0,Math.round((n-t)/1e3));return r<60?`${String(r)}s`:`${String(Math.round(r/60))}m`}function k(e){return e===`critical`?`border-[color:color-mix(in_srgb,var(--alert)_55%,var(--line))] bg-[var(--alert-soft)] text-[var(--alert)]`:e===`warning`?`border-[color:color-mix(in_srgb,#f59e0b_55%,var(--line))] bg-[color:color-mix(in_srgb,#f59e0b_13%,var(--bg))] text-[color:color-mix(in_srgb,#f59e0b_85%,var(--ink))]`:e===`quiet`?`border-[var(--line)] bg-[var(--bg-active)] text-[var(--ink-soft)]`:`border-[color:color-mix(in_srgb,#22c55e_45%,var(--line))] bg-[color:color-mix(in_srgb,#22c55e_12%,var(--bg))] text-[color:color-mix(in_srgb,#22c55e_80%,var(--ink))]`}function A(e){return e===`critical`?p:e===`warning`?x:e===`quiet`?y:S}function j({icon:e,label:t,value:n}){return(0,w.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-b border-[var(--line)] px-4 py-3 sm:border-r`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,w.jsx)(e,{className:`size-4`,strokeWidth:1.8}),(0,w.jsx)(`span`,{children:t})]}),(0,w.jsx)(`div`,{className:`truncate text-[24px] font-bold tracking-tight text-[var(--ink)]`,children:n})]})}function M({endpoint:e,nowMs:t}){let n=A(e.status);return(0,w.jsxs)(`div`,{className:`grid gap-3 border-b border-[var(--line)] px-4 py-4 min-[760px]:grid-cols-[minmax(0,1.25fr)_minmax(180px,0.75fr)_92px]`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[12px] font-bold capitalize`,k(e.status)),children:[(0,w.jsx)(n,{className:`size-3.5`,strokeWidth:1.9}),e.status]}),(0,w.jsx)(`span`,{className:`font-bold text-[var(--ink)]`,children:e.label})]}),(0,w.jsxs)(`div`,{className:`mt-1 font-mono text-[12px] text-[var(--ink-soft)]`,children:[e.method,` `,e.path]}),(0,w.jsx)(`div`,{className:`mt-1 text-[13px] text-[var(--ink-soft)]`,children:e.description})]}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 text-[13px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[E(e.callsLastWindow),` calls`]}),(0,w.jsxs)(`span`,{children:[E(e.estimatedRemaining),` est. left`]})]}),(0,w.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-[var(--bg-active)]`,children:(0,w.jsx)(`div`,{className:`h-full rounded-full bg-[var(--accent)]`,style:{width:`${String(e.usagePercent)}%`}})}),(0,w.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[12px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[E(e.perUserLimit),`/user`]}),(0,w.jsxs)(`span`,{children:[E(e.perAppLimit),`/app`]}),(0,w.jsxs)(`span`,{children:[String(e.rateLimitedLastWindow),` 429s`]}),(0,w.jsxs)(`span`,{children:[String(e.errorsLastWindow),` errors`]})]})]}),(0,w.jsxs)(`div`,{className:`flex min-[760px]:flex-col gap-2 text-[12px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[`last `,D(e.lastEventAt,t)]}),(0,w.jsxs)(`span`,{children:[`reset `,O(e.estimatedResetAt,t)]})]})]})}function N({event:e,nowMs:t}){return(0,w.jsxs)(`div`,{className:`grid gap-2 border-b border-[var(--line)] px-4 py-3 text-[13px] min-[760px]:grid-cols-[120px_minmax(0,1fr)_120px]`,children:[(0,w.jsx)(`div`,{className:`font-bold capitalize text-[var(--ink)]`,children:e.status.replace(`_`,` `)}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`truncate font-mono text-[12px] text-[var(--ink-soft)]`,children:e.endpoint}),(0,w.jsxs)(`div`,{className:`truncate text-[var(--ink-soft)]`,children:[e.source,e.handle?` · @${e.handle}`:``]}),e.detail?(0,w.jsx)(`div`,{className:`mt-1 line-clamp-2 break-words text-[var(--ink-soft)]`,children:e.detail}):null]}),(0,w.jsx)(`div`,{className:`text-[var(--ink-soft)]`,children:D(e.at,t)})]})}function P(){let e=_({queryKey:m.rateLimits,queryFn:T,staleTime:6e4}),t=e.data??null,a=e.isFetching,f=e.error,h=(0,C.useMemo)(()=>Date.now(),[t]);return(0,w.jsxs)(`section`,{className:`flex min-h-screen flex-col`,children:[(0,w.jsx)(`header`,{className:s,children:(0,w.jsxs)(`div`,{className:c,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h1`,{className:i,children:`Rate Limits`}),(0,w.jsx)(`p`,{className:n,children:`Observed xurl calls with X API 15-minute windows.`})]}),(0,w.jsxs)(`div`,{className:r,children:[(0,w.jsxs)(`a`,{className:l,href:t?.docsUrl??`https://docs.x.com/x-api/fundamentals/rate-limits`,rel:`noreferrer`,target:`_blank`,children:[(0,w.jsx)(y,{className:`size-4`,strokeWidth:1.8}),`Docs`]}),(0,w.jsxs)(`button`,{className:l,disabled:a,onClick:()=>void e.refetch(),type:`button`,children:[(0,w.jsx)(v,{className:o(`size-4`,a&&`animate-spin`),strokeWidth:1.8}),`Refresh`]})]})]})}),f?(0,w.jsx)(`div`,{className:u,children:f instanceof Error?f.message:`Rate limits failed`}):null,t?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`grid border-b border-[var(--line)] sm:grid-cols-2 min-[1040px]:grid-cols-4`,children:[(0,w.jsx)(j,{icon:b,label:`Calls in window`,value:E(t.summary.totalCallsLastWindow)}),(0,w.jsx)(j,{icon:p,label:`429s in window`,value:E(t.summary.rateLimitedLastWindow)}),(0,w.jsx)(j,{icon:x,label:`Retry policy`,value:`${String(t.throttle.rateLimitMaxRetries)} x ${String(Math.round(t.throttle.rateLimitRetryMs/1e3))}s`}),(0,w.jsx)(j,{icon:y,label:`Conversation delay`,value:`${String(t.throttle.conversationDelayMs)}ms`})]}),(0,w.jsx)(`div`,{className:`border-b border-[var(--line)]`,children:t.endpoints.map(e=>(0,w.jsx)(M,{endpoint:e,nowMs:h},e.key))}),(0,w.jsx)(`div`,{className:`px-4 py-3 text-[13px] font-bold text-[var(--ink)]`,children:`Recent xurl events`}),t.events.length>0?(0,w.jsx)(`div`,{children:t.events.slice(0,30).map(e=>(0,w.jsx)(N,{event:e,nowMs:h},e.id))}):(0,w.jsx)(`p`,{className:d,children:`No observed xurl calls yet.`})]}):a?(0,w.jsx)(`p`,{className:d,children:`Loading rate limits...`}):null]})}export{P as component};
1
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,cn as l,dt as u,wn as d}from"./schemas-I9r6F6ya.js";import{t as f}from"./createLucideIcon-JV8isFFR.js";import{t as p}from"./triangle-alert-CBL7s2pf.js";import{n as m,r as h,y as g}from"./query-client-fYu2rzRC.js";import{ct as _,ft as v,ht as y}from"./index-DZVisyna.js";var b=f(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),x=f(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),S=f(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),C=e(t()),w=a();async function T(){return h(`/api/xurl-rate-limits`,void 0,g,`Rate limits request failed`)}function E(e){return new Intl.NumberFormat().format(e)}function D(e,t){if(!e)return`never`;let n=new Date(e).getTime();if(!Number.isFinite(n))return`unknown`;let r=Math.max(0,Math.round((t-n)/1e3));if(r<60)return`${String(r)}s ago`;let i=Math.round(r/60);if(i<60)return`${String(i)}m ago`;let a=Math.round(i/60);return`${String(a)}h ago`}function O(e,t){if(!e)return`idle`;let n=new Date(e).getTime();if(!Number.isFinite(n))return`unknown`;let r=Math.max(0,Math.round((n-t)/1e3));return r<60?`${String(r)}s`:`${String(Math.round(r/60))}m`}function k(e){return e===`critical`?`border-[color:color-mix(in_srgb,var(--alert)_55%,var(--line))] bg-[var(--alert-soft)] text-[var(--alert)]`:e===`warning`?`border-[color:color-mix(in_srgb,#f59e0b_55%,var(--line))] bg-[color:color-mix(in_srgb,#f59e0b_13%,var(--bg))] text-[color:color-mix(in_srgb,#f59e0b_85%,var(--ink))]`:e===`quiet`?`border-[var(--line)] bg-[var(--bg-active)] text-[var(--ink-soft)]`:`border-[color:color-mix(in_srgb,#22c55e_45%,var(--line))] bg-[color:color-mix(in_srgb,#22c55e_12%,var(--bg))] text-[color:color-mix(in_srgb,#22c55e_80%,var(--ink))]`}function A(e){return e===`critical`?p:e===`warning`?x:e===`quiet`?y:S}function j({icon:e,label:t,value:n}){return(0,w.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-b border-[var(--line)] px-4 py-3 sm:border-r`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,w.jsx)(e,{className:`size-4`,strokeWidth:1.8}),(0,w.jsx)(`span`,{children:t})]}),(0,w.jsx)(`div`,{className:`truncate text-[24px] font-bold tracking-tight text-[var(--ink)]`,children:n})]})}function M({endpoint:e,nowMs:t}){let n=A(e.status);return(0,w.jsxs)(`div`,{className:`grid gap-3 border-b border-[var(--line)] px-4 py-4 min-[760px]:grid-cols-[minmax(0,1.25fr)_minmax(180px,0.75fr)_92px]`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[12px] font-bold capitalize`,k(e.status)),children:[(0,w.jsx)(n,{className:`size-3.5`,strokeWidth:1.9}),e.status]}),(0,w.jsx)(`span`,{className:`font-bold text-[var(--ink)]`,children:e.label})]}),(0,w.jsxs)(`div`,{className:`mt-1 font-mono text-[12px] text-[var(--ink-soft)]`,children:[e.method,` `,e.path]}),(0,w.jsx)(`div`,{className:`mt-1 text-[13px] text-[var(--ink-soft)]`,children:e.description})]}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 text-[13px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[E(e.callsLastWindow),` calls`]}),(0,w.jsxs)(`span`,{children:[E(e.estimatedRemaining),` est. left`]})]}),(0,w.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-[var(--bg-active)]`,children:(0,w.jsx)(`div`,{className:`h-full rounded-full bg-[var(--accent)]`,style:{width:`${String(e.usagePercent)}%`}})}),(0,w.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[12px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[E(e.perUserLimit),`/user`]}),(0,w.jsxs)(`span`,{children:[E(e.perAppLimit),`/app`]}),(0,w.jsxs)(`span`,{children:[String(e.rateLimitedLastWindow),` 429s`]}),(0,w.jsxs)(`span`,{children:[String(e.errorsLastWindow),` errors`]})]})]}),(0,w.jsxs)(`div`,{className:`flex min-[760px]:flex-col gap-2 text-[12px] text-[var(--ink-soft)]`,children:[(0,w.jsxs)(`span`,{children:[`last `,D(e.lastEventAt,t)]}),(0,w.jsxs)(`span`,{children:[`reset `,O(e.estimatedResetAt,t)]})]})]})}function N({event:e,nowMs:t}){return(0,w.jsxs)(`div`,{className:`grid gap-2 border-b border-[var(--line)] px-4 py-3 text-[13px] min-[760px]:grid-cols-[120px_minmax(0,1fr)_120px]`,children:[(0,w.jsx)(`div`,{className:`font-bold capitalize text-[var(--ink)]`,children:e.status.replace(`_`,` `)}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`truncate font-mono text-[12px] text-[var(--ink-soft)]`,children:e.endpoint}),(0,w.jsxs)(`div`,{className:`truncate text-[var(--ink-soft)]`,children:[e.source,e.handle?` · @${e.handle}`:``]}),e.detail?(0,w.jsx)(`div`,{className:`mt-1 line-clamp-2 break-words text-[var(--ink-soft)]`,children:e.detail}):null]}),(0,w.jsx)(`div`,{className:`text-[var(--ink-soft)]`,children:D(e.at,t)})]})}function P(){let e=_({queryKey:m.rateLimits,queryFn:T,staleTime:6e4}),t=e.data??null,a=e.isFetching,f=e.error,h=(0,C.useMemo)(()=>Date.now(),[t]);return(0,w.jsxs)(`section`,{className:`flex min-h-screen flex-col`,children:[(0,w.jsx)(`header`,{className:s,children:(0,w.jsxs)(`div`,{className:c,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h1`,{className:i,children:`Rate Limits`}),(0,w.jsx)(`p`,{className:n,children:`Observed xurl calls with X API 15-minute windows.`})]}),(0,w.jsxs)(`div`,{className:r,children:[(0,w.jsxs)(`a`,{className:l,href:t?.docsUrl??`https://docs.x.com/x-api/fundamentals/rate-limits`,rel:`noreferrer`,target:`_blank`,children:[(0,w.jsx)(y,{className:`size-4`,strokeWidth:1.8}),`Docs`]}),(0,w.jsxs)(`button`,{className:l,disabled:a,onClick:()=>void e.refetch(),type:`button`,children:[(0,w.jsx)(v,{className:o(`size-4`,a&&`animate-spin`),strokeWidth:1.8}),`Refresh`]})]})]})}),f?(0,w.jsx)(`div`,{className:u,children:f instanceof Error?f.message:`Rate limits failed`}):null,t?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`grid border-b border-[var(--line)] sm:grid-cols-2 min-[1040px]:grid-cols-4`,children:[(0,w.jsx)(j,{icon:b,label:`Calls in window`,value:E(t.summary.totalCallsLastWindow)}),(0,w.jsx)(j,{icon:p,label:`429s in window`,value:E(t.summary.rateLimitedLastWindow)}),(0,w.jsx)(j,{icon:x,label:`Retry policy`,value:`${String(t.throttle.rateLimitMaxRetries)} x ${String(Math.round(t.throttle.rateLimitRetryMs/1e3))}s`}),(0,w.jsx)(j,{icon:y,label:`Conversation delay`,value:`${String(t.throttle.conversationDelayMs)}ms`})]}),(0,w.jsx)(`div`,{className:`border-b border-[var(--line)]`,children:t.endpoints.map(e=>(0,w.jsx)(M,{endpoint:e,nowMs:h},e.key))}),(0,w.jsx)(`div`,{className:`px-4 py-3 text-[13px] font-bold text-[var(--ink)]`,children:`Recent xurl events`}),t.events.length>0?(0,w.jsx)(`div`,{children:t.events.slice(0,30).map(e=>(0,w.jsx)(N,{event:e,nowMs:h},e.id))}):(0,w.jsx)(`p`,{className:d,children:`No observed xurl calls yet.`})]}):a?(0,w.jsx)(`p`,{className:d,children:`Loading rate limits...`}):null]})}export{P as component};
@@ -1 +1 @@
1
- import{Ln as e}from"./schemas-I9r6F6ya.js";import{t}from"./TimelineRouteFrame-CyGPj0eM.js";var n=e();function r(e){return e?`${String(e.stats.home)} items · ${String(e.stats.needsReply)} waiting · ${e.transport.statusText}`:`Loading local context...`}function i(){return(0,n.jsx)(t,{emptyDetail:`Try a different filter or sync the timeline again.`,emptyLabel:`No posts in this view`,errorFallback:`Timeline unavailable`,errorTitle:`Could not load posts`,initialReplyFilter:`all`,loadingDetail:`Reading the local timeline store`,loadingLabel:`Loading posts`,resource:`home`,searchPlaceholder:`Search local timeline`,subtitle:r,syncKind:`timeline`,syncLabel:`Sync timeline`,title:`Home`})}export{i as component};
1
+ import{Ln as e}from"./schemas-I9r6F6ya.js";import{t}from"./TimelineRouteFrame-9NDLnXzH.js";var n=e();function r(e){return e?`${String(e.stats.home)} items · ${String(e.stats.needsReply)} waiting · ${e.transport.statusText}`:`Loading local context...`}function i(){return(0,n.jsx)(t,{emptyDetail:`Try a different filter or sync the timeline again.`,emptyLabel:`No posts in this view`,errorFallback:`Timeline unavailable`,errorTitle:`Could not load posts`,initialReplyFilter:`all`,loadingDetail:`Reading the local timeline store`,loadingLabel:`Loading posts`,resource:`home`,searchPlaceholder:`Search local timeline`,subtitle:r,syncKind:`timeline`,syncLabel:`Sync timeline`,title:`Home`})}export{i as component};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,cn as l,dn as u,dt as d,un as f}from"./schemas-I9r6F6ya.js";import{t as p}from"./circle-check-C_Vq3ElD.js";import{a as m,n as h,o as g,s as _,t as v}from"./client-stream-contracts-ys3XhWG4.js";import{t as y}from"./sparkles-CQVlvHsZ.js";import{b}from"./query-client-fYu2rzRC.js";import{n as x,t as S}from"./profile-hydration-client-YEtJsNTv.js";import{J as C,ft as w,rt as T}from"./index-CEIG7S6s.js";var E=e(t()),D=a(),O=12,k=300,A={524:`Digest startup timed out at Cloudflare (524). Retry to open a new stream.`},j=[{value:`today`,label:`Today`},{value:`24h`,label:`24h`},{value:`yesterday`,label:`Yesterday`},{value:`week`,label:`Week`}];function M(e,t,n){let r=new URL(`/api/period-digest`,window.location.origin);return r.searchParams.set(`period`,e),r.searchParams.set(`includeDms`,String(t)),r.searchParams.set(`maxTweets`,`5000`),r.searchParams.set(`maxLinks`,`20`),r.searchParams.set(`liveSync`,`false`),n&&r.searchParams.set(`refresh`,`true`),r}function N(e,t){let n=e instanceof Error?e.message:String(e);return e instanceof TypeError&&/network error|failed to fetch|load failed/i.test(n)?`Digest connection was interrupted while ${t.toLowerCase()}. Retry to continue.`:e instanceof SyntaxError?`Digest stream returned invalid data while ${t.toLowerCase()}. Retry to continue.`:n||`Digest failed`}function P(e){if(!e)return`Local Twitter memory, summarized as it streams.`;let t=e.counts;return[`${String(t.home)} home`,`${String(t.mentions)} mentions`,`${String(t.links)} links`,e.includeDms?`${String(t.dms)} DMs`:null].filter(Boolean).join(` · `)}function F(e){let t=new Set,n=new Set;for(let t of e.digest.sourceTweetIds)n.add(t);for(let t of e.digest.keyTopics)for(let e of t.tweetIds)n.add(e);for(let t of e.digest.notableLinks)for(let e of t.sourceTweetIds)n.add(e);for(let t of e.digest.actionItems)t.tweetId&&n.add(t.tweetId);let r=new Map(e.context.tweets.flatMap(e=>[[e.id,e],[`tweet_${e.id}`,e]]));for(let e of n){let n=r.get(e);if(!n)continue;let i=x(n.author);i&&t.add(i)}for(let n of e.context.tweets){let e=x(n.author);e&&t.add(e)}return[...t]}function I(e,t){let n=!1,r=e.tweets.map(e=>{let r=t.get(x(e.author));return!r||r===e.authorProfile?e:(n=!0,{...e,author:r.handle,name:r.displayName,authorProfile:r})});return n?{...e,tweets:r}:e}function L(e,t){let n=new Map(t.map(e=>[x(e.handle),e]));if(n.size===0)return e;let r=I(e.context,n);return r===e.context?e:{...e,context:r}}function R(e,t){let n=b(),[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)(`Starting digest`),d=(0,E.useRef)(`Starting digest`),f=(0,E.useCallback)(()=>{i(``),o(null),c(null),u(`Starting digest`),d.current=`Starting digest`},[]),{error:p,loading:g,run:_}=m({schema:h,request:(0,E.useCallback)((n,r)=>fetch(M(e,t,r),{cache:`no-store`,signal:n}),[t,e]),onStart:f,onEvent:(0,E.useCallback)(e=>{if(e.type===`status`)d.current=e.detail?`${e.label} · ${e.detail}`:e.label,u(d.current);else if(e.type===`start`)o(e.context);else if(e.type===`delta`)d.current=`Streaming AI summary`,u(d.current),i(t=>t+e.delta);else if(e.type===`done`)c(e.result),o(e.result.context),i(e.result.markdown),u(e.result.cached?`Loaded cached report`:`Ready`);else if(e.type===`error`)throw Error(e.error)},[]),onError:(0,E.useCallback)(()=>u(`Digest failed`),[]),isTerminal:v,errorLabel:`Digest request failed`,emptyBodyMessage:`Digest request failed: empty response body`,prematureEofError:(0,E.useCallback)(()=>Error(`Digest connection closed while ${d.current.toLowerCase()}. Retry to continue.`),[]),formatError:(0,E.useCallback)(e=>N(e,d.current),[]),statusMessages:A});return(0,E.useEffect)(()=>{_(!1)},[_]),(0,E.useEffect)(()=>{if(!s)return;let e=F(s);if(e.length===0)return;let t=!0,r=null,i=()=>{S(n,e,{limit:O}).then(e=>{if(!t)return;let{profiles:n}=e;if(n.length===0)return;c(e=>e&&L(e,n));let r=new Map(n.map(e=>[x(e.handle),e]));o(e=>e&&I(e,r))}).catch(e=>{t&&console.warn(`Profile hydration failed`,e)})},a=window.setTimeout(()=>{`requestIdleCallback`in window?r=window.requestIdleCallback(i,{timeout:2500}):i()},k);return()=>{t=!1,window.clearTimeout(a),r!==null&&`cancelIdleCallback`in window&&window.cancelIdleCallback(r)}},[n,s]),{context:a,error:p,loading:g,markdown:r,result:s,run:_,status:l}}function z(){let e=C.useSearch(),t=C.useNavigate();return(0,D.jsx)(B,{searchState:e,onSearchChange:(e,n)=>void t({search:e,replace:n?.replace})})}function B({searchState:e,onSearchChange:t}={}){let[a,m]=(0,E.useState)(()=>T({})),h=e??a,v=(e,n)=>t?t(e,n):m(e),{period:b,includeDms:x}=h,{context:S,error:C,loading:O,markdown:k,result:A,run:M,status:N}=R(b,x),F=(0,E.useMemo)(()=>P(A?.context??S),[S,A]);return(0,D.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,D.jsxs)(`header`,{className:s,children:[(0,D.jsxs)(`div`,{className:c,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:i,children:`What happened`}),(0,D.jsx)(`p`,{className:n,children:F})]}),(0,D.jsx)(`div`,{className:r,children:(0,D.jsxs)(`button`,{type:`button`,className:l,onClick:()=>M(!0),disabled:O,children:[(0,D.jsx)(w,{className:o(`size-4`,O&&`animate-spin`),"aria-hidden":`true`}),`Refresh`]})})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-3`,children:[(0,D.jsx)(`div`,{className:u,"aria-label":`Digest period`,children:j.map(e=>(0,D.jsx)(`button`,{type:`button`,className:o(f,b===e.value&&`bg-[var(--bg-active)] text-[var(--ink)]`),onClick:()=>v({...h,period:e.value}),children:e.label},e.value))}),(0,D.jsxs)(`label`,{className:`inline-flex items-center gap-2 rounded-full border border-[var(--line)] px-3 py-1 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>v({...h,includeDms:e.currentTarget.checked})}),`DMs`]})]})]}),C?(0,D.jsxs)(`div`,{className:o(d,`flex items-center justify-between gap-3`),role:`alert`,children:[(0,D.jsx)(`span`,{children:C}),(0,D.jsx)(`button`,{className:`shrink-0 font-semibold underline underline-offset-2`,onClick:()=>M(!0),type:`button`,children:`Retry`})]}):null,(0,D.jsx)(`div`,{className:`border-b border-[var(--line)] px-4 py-2 text-[13px] text-[var(--ink-soft)]`,children:(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[O?(0,D.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":`true`}):k?(0,D.jsx)(p,{className:`size-4`,"aria-hidden":`true`}):(0,D.jsx)(y,{className:`size-4`,"aria-hidden":`true`}),O?N:A?`${A.cached?`Cached`:`Ready`} · ${A.context.window.label}`:C?`Digest failed`:`Ready`]})}),k?(0,D.jsx)(g,{context:A?.context??S,markdown:k}):(0,D.jsx)(`div`,{className:`px-4 py-5 text-[14px] text-[var(--ink-soft)]`,children:O?N:C?`No digest was generated. Retry to start a new run.`:`Waiting for the first tokens...`})]})}export{B as TodayRouteView,z as component};
1
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{Gt as n,Ht as r,Kt as i,Ln as a,M as o,Ut as s,Wt as c,cn as l,dn as u,dt as d,un as f}from"./schemas-I9r6F6ya.js";import{t as p}from"./circle-check-C_Vq3ElD.js";import{a as m,n as h,o as g,s as _,t as v}from"./client-stream-contracts-sR4xMQxY.js";import{t as y}from"./sparkles-CQVlvHsZ.js";import{b}from"./query-client-fYu2rzRC.js";import{n as x,t as S}from"./profile-hydration-client-YEtJsNTv.js";import{J as C,ft as w,rt as T}from"./index-DZVisyna.js";var E=e(t()),D=a(),O=12,k=300,A={524:`Digest startup timed out at Cloudflare (524). Retry to open a new stream.`},j=[{value:`today`,label:`Today`},{value:`24h`,label:`24h`},{value:`yesterday`,label:`Yesterday`},{value:`week`,label:`Week`}];function M(e,t,n){let r=new URL(`/api/period-digest`,window.location.origin);return r.searchParams.set(`period`,e),r.searchParams.set(`includeDms`,String(t)),r.searchParams.set(`maxTweets`,`5000`),r.searchParams.set(`maxLinks`,`20`),r.searchParams.set(`liveSync`,`false`),n&&r.searchParams.set(`refresh`,`true`),r}function N(e,t){let n=e instanceof Error?e.message:String(e);return e instanceof TypeError&&/network error|failed to fetch|load failed/i.test(n)?`Digest connection was interrupted while ${t.toLowerCase()}. Retry to continue.`:e instanceof SyntaxError?`Digest stream returned invalid data while ${t.toLowerCase()}. Retry to continue.`:n||`Digest failed`}function P(e){if(!e)return`Local Twitter memory, summarized as it streams.`;let t=e.counts;return[`${String(t.home)} home`,`${String(t.mentions)} mentions`,`${String(t.links)} links`,e.includeDms?`${String(t.dms)} DMs`:null].filter(Boolean).join(` · `)}function F(e){let t=new Set,n=new Set;for(let t of e.digest.sourceTweetIds)n.add(t);for(let t of e.digest.keyTopics)for(let e of t.tweetIds)n.add(e);for(let t of e.digest.notableLinks)for(let e of t.sourceTweetIds)n.add(e);for(let t of e.digest.actionItems)t.tweetId&&n.add(t.tweetId);let r=new Map(e.context.tweets.flatMap(e=>[[e.id,e],[`tweet_${e.id}`,e]]));for(let e of n){let n=r.get(e);if(!n)continue;let i=x(n.author);i&&t.add(i)}for(let n of e.context.tweets){let e=x(n.author);e&&t.add(e)}return[...t]}function I(e,t){let n=!1,r=e.tweets.map(e=>{let r=t.get(x(e.author));return!r||r===e.authorProfile?e:(n=!0,{...e,author:r.handle,name:r.displayName,authorProfile:r})});return n?{...e,tweets:r}:e}function L(e,t){let n=new Map(t.map(e=>[x(e.handle),e]));if(n.size===0)return e;let r=I(e.context,n);return r===e.context?e:{...e,context:r}}function R(e,t){let n=b(),[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)(`Starting digest`),d=(0,E.useRef)(`Starting digest`),f=(0,E.useCallback)(()=>{i(``),o(null),c(null),u(`Starting digest`),d.current=`Starting digest`},[]),{error:p,loading:g,run:_}=m({schema:h,request:(0,E.useCallback)((n,r)=>fetch(M(e,t,r),{cache:`no-store`,signal:n}),[t,e]),onStart:f,onEvent:(0,E.useCallback)(e=>{if(e.type===`status`)d.current=e.detail?`${e.label} · ${e.detail}`:e.label,u(d.current);else if(e.type===`start`)o(e.context);else if(e.type===`delta`)d.current=`Streaming AI summary`,u(d.current),i(t=>t+e.delta);else if(e.type===`done`)c(e.result),o(e.result.context),i(e.result.markdown),u(e.result.cached?`Loaded cached report`:`Ready`);else if(e.type===`error`)throw Error(e.error)},[]),onError:(0,E.useCallback)(()=>u(`Digest failed`),[]),isTerminal:v,errorLabel:`Digest request failed`,emptyBodyMessage:`Digest request failed: empty response body`,prematureEofError:(0,E.useCallback)(()=>Error(`Digest connection closed while ${d.current.toLowerCase()}. Retry to continue.`),[]),formatError:(0,E.useCallback)(e=>N(e,d.current),[]),statusMessages:A});return(0,E.useEffect)(()=>{_(!1)},[_]),(0,E.useEffect)(()=>{if(!s)return;let e=F(s);if(e.length===0)return;let t=!0,r=null,i=()=>{S(n,e,{limit:O}).then(e=>{if(!t)return;let{profiles:n}=e;if(n.length===0)return;c(e=>e&&L(e,n));let r=new Map(n.map(e=>[x(e.handle),e]));o(e=>e&&I(e,r))}).catch(e=>{t&&console.warn(`Profile hydration failed`,e)})},a=window.setTimeout(()=>{`requestIdleCallback`in window?r=window.requestIdleCallback(i,{timeout:2500}):i()},k);return()=>{t=!1,window.clearTimeout(a),r!==null&&`cancelIdleCallback`in window&&window.cancelIdleCallback(r)}},[n,s]),{context:a,error:p,loading:g,markdown:r,result:s,run:_,status:l}}function z(){let e=C.useSearch(),t=C.useNavigate();return(0,D.jsx)(B,{searchState:e,onSearchChange:(e,n)=>void t({search:e,replace:n?.replace})})}function B({searchState:e,onSearchChange:t}={}){let[a,m]=(0,E.useState)(()=>T({})),h=e??a,v=(e,n)=>t?t(e,n):m(e),{period:b,includeDms:x}=h,{context:S,error:C,loading:O,markdown:k,result:A,run:M,status:N}=R(b,x),F=(0,E.useMemo)(()=>P(A?.context??S),[S,A]);return(0,D.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,D.jsxs)(`header`,{className:s,children:[(0,D.jsxs)(`div`,{className:c,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:i,children:`What happened`}),(0,D.jsx)(`p`,{className:n,children:F})]}),(0,D.jsx)(`div`,{className:r,children:(0,D.jsxs)(`button`,{type:`button`,className:l,onClick:()=>M(!0),disabled:O,children:[(0,D.jsx)(w,{className:o(`size-4`,O&&`animate-spin`),"aria-hidden":`true`}),`Refresh`]})})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-3`,children:[(0,D.jsx)(`div`,{className:u,"aria-label":`Digest period`,children:j.map(e=>(0,D.jsx)(`button`,{type:`button`,className:o(f,b===e.value&&`bg-[var(--bg-active)] text-[var(--ink)]`),onClick:()=>v({...h,period:e.value}),children:e.label},e.value))}),(0,D.jsxs)(`label`,{className:`inline-flex items-center gap-2 rounded-full border border-[var(--line)] px-3 py-1 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>v({...h,includeDms:e.currentTarget.checked})}),`DMs`]})]})]}),C?(0,D.jsxs)(`div`,{className:o(d,`flex items-center justify-between gap-3`),role:`alert`,children:[(0,D.jsx)(`span`,{children:C}),(0,D.jsx)(`button`,{className:`shrink-0 font-semibold underline underline-offset-2`,onClick:()=>M(!0),type:`button`,children:`Retry`})]}):null,(0,D.jsx)(`div`,{className:`border-b border-[var(--line)] px-4 py-2 text-[13px] text-[var(--ink-soft)]`,children:(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[O?(0,D.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":`true`}):k?(0,D.jsx)(p,{className:`size-4`,"aria-hidden":`true`}):(0,D.jsx)(y,{className:`size-4`,"aria-hidden":`true`}),O?N:A?`${A.cached?`Cached`:`Ready`} · ${A.context.window.label}`:C?`Digest failed`:`Ready`]})}),k?(0,D.jsx)(g,{context:A?.context??S,markdown:k}):(0,D.jsx)(`div`,{className:`px-4 py-5 text-[14px] text-[var(--ink-soft)]`,children:O?N:C?`No digest was generated. Retry to start a new run.`:`Waiting for the first tokens...`})]})}export{B as TodayRouteView,z as component};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{At as n,Ct as r,Dt as i,Et as a,Fn as o,Gt as s,Kt as c,Ln as l,M as u,Mt as d,Pn as f,St as p,Tt as m,Ut as h,Wt as g,_t as _,an as v,at as y,bt as b,ct as x,ft as S,gt as C,ht as w,it as T,jt as E,kt as D,lt as O,mt as k,on as ee,ot as te,pt as A,rt as ne,sn as re,st as ie,vt as ae,wt as j,xt as oe,yt as se}from"./schemas-I9r6F6ya.js";import{t as M}from"./createLucideIcon-JV8isFFR.js";import{t as ce}from"./circle-check-C_Vq3ElD.js";import{t as le}from"./repeat-2-xCwHM9hD.js";import{t as ue}from"./search-Dq5kYsxA.js";import{C as de,a as fe,b as N,i as pe,l as me,m as he,n as P,o as ge,r as _e,s as ve,v as ye,w as be}from"./query-client-fYu2rzRC.js";import{r as F,t as xe}from"./AvatarChip-DLoqM5xD.js";import{c as Se,i as I,s as Ce,t as L}from"./ProfilePreview-BejAuYsJ.js";import{t as R}from"./SmartTimestamp-BR0-9se2.js";import{A as we,M as Te,O as Ee,at as De,ct as z,d as Oe,dt as ke,gt as B,it as Ae,k as je,lt as Me,mt as Ne,ot as Pe,pt as V,s as H,st as Fe,ut as Ie,yt as Le}from"./index-CEIG7S6s.js";var Re=M(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),ze=M(`bookmark-check`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]),Be=M(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Ve=M(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),He=class extends Ie{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:de(t,n.data),hasPreviousPage:be(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Ue(e){return e}function We(e,t){return Me(e,He,t)}var U=e(t(),1),Ge=(0,U.createContext)(null);function Ke(e){return Ue({queryKey:[...P.conversations,e],queryFn:()=>me(pe(`/api/conversation?tweetId=${encodeURIComponent(e)}`,void 0,ye,`Conversation unavailable`)).then(e=>e.items),staleTime:1/0})}function qe({children:e}){let[t,n]=(0,U.useState)(null),r=(0,U.useMemo)(()=>({expandedSurfaceId:t,setExpandedSurfaceId:n}),[t]);return(0,U.createElement)(Ge.Provider,{value:r},e)}function Je(e,t=e){let n=(0,U.useContext)(Ge),[r,i]=(0,U.useState)(null),a=n?.expandedSurfaceId??r,o=n?.setExpandedSurfaceId??i,s=a===e,c=N(),l=z({...Ke(t),enabled:s}),u=(0,U.useCallback)(()=>{o(s?null:e)},[s,o,e]),d=(0,U.useCallback)(()=>{c.prefetchQuery(Ke(t))},[c,t]),f=l.isError?`error`:l.isFetching?`loading`:l.data?`ready`:`idle`;return{error:l.error instanceof Error?l.error.message:null,isOpen:s,items:l.data??[],loading:l.isFetching,prefetch:d,status:f,toggle:u}}var W=l();function Ye(e){let t=I(e);if(!t)return null;try{return new URL(t).hostname===`pbs.twimg.com`?t:null}catch{return null}}function G({article:e}){let t=I(e.url);if(!t)return null;let r=Ye(e.coverImageUrl);return(0,W.jsxs)(`a`,{"aria-label":`Read article: ${e.title}`,className:D,"data-perf":`tweet-article-card`,href:t,rel:`noreferrer`,target:`_blank`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(Re,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)]`,strokeWidth:1.8}),(0,W.jsx)(`span`,{className:E,children:`Article on X`}),(0,W.jsx)(B,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)] opacity-0 transition-opacity group-hover/link-preview:opacity-100`,strokeWidth:1.8})]}),(0,W.jsx)(`span`,{className:d,children:e.title}),e.previewText?(0,W.jsx)(`span`,{className:n,children:e.previewText}):null]}),r?(0,W.jsx)(`div`,{className:`flex aspect-[1.45] w-40 shrink-0 overflow-hidden border-l border-[var(--line)] bg-[var(--bg-soft)] max-[720px]:w-28`,children:(0,W.jsx)(`img`,{alt:``,className:`size-full object-cover transition-transform duration-200 group-hover/link-preview:scale-[1.03]`,loading:`lazy`,src:r})}):null]})}function K({items:e}){let[t,n]=(0,U.useState)(null);if(e.length===0)return null;let r=e.slice(0,4),i=t===null?null:r[t]??null,a=i?.type===`video`||i?.type===`gif`?i.variants?.[0]?.url??Ze(i.url):null,s=r.length===1&&r[0]?.type===`image`?r[0]:null;return(0,W.jsxs)(W.Fragment,{children:[s?(0,W.jsx)(`button`,{"aria-label":`Open tweet media 1`,className:u(`tweet-media-single mt-2 max-w-full overflow-hidden rounded-2xl border border-[var(--line)] bg-[var(--bg-active)] p-0 text-left`,s.width&&s.height?`block`:`inline-block align-top`),onClick:e=>{e.stopPropagation(),n(0)},style:Xe(s),type:`button`,children:(0,W.jsx)(`img`,{alt:s.altText??`Tweet media 1`,className:u(`tweet-media-image block max-h-[720px] max-w-full`,s.width&&s.height?`size-full object-cover`:`h-auto w-auto object-contain`),height:s.height,loading:`lazy`,src:s.thumbnailUrl??s.url,width:s.width})}):(0,W.jsx)(`div`,{className:f(Math.min(e.length,4)),children:r.map((t,i)=>(0,W.jsx)(`button`,{"aria-label":`Open tweet media ${String(i+1)}`,className:o(i,Math.min(e.length,4)),onClick:e=>{e.stopPropagation(),n(i)},style:r.length===1&&t.width&&t.height?{aspectRatio:`${String(t.width)} / ${String(t.height)}`}:void 0,type:`button`,children:t.type===`image`?(0,W.jsx)(`img`,{alt:t.altText??`Tweet media ${String(i+1)}`,className:`tweet-media-image block size-full object-contain`,loading:`lazy`,src:t.thumbnailUrl??t.url}):(0,W.jsx)(`span`,{className:`tweet-media-fallback grid min-h-40 place-items-center font-semibold text-[var(--ink-soft)]`,children:t.type===`video`?`Video`:t.type===`gif`?`GIF`:`Media`})},t.url+String(i)))}),i?(0,W.jsxs)(`div`,{"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/85 p-4`,onClick:e=>{e.stopPropagation(),n(null)},role:`dialog`,children:[(0,W.jsx)(`button`,{"aria-label":`Close media viewer`,className:`absolute right-4 top-4 grid size-10 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20`,onClick:e=>{e.stopPropagation(),n(null)},type:`button`,children:(0,W.jsx)(Ve,{className:`size-5`,strokeWidth:1.8})}),i.type===`image`?(0,W.jsx)(`img`,{alt:i.altText??`Tweet media`,className:`max-h-[92vh] max-w-[92vw] object-contain`,onClick:e=>e.stopPropagation(),src:i.url}):a?(0,W.jsx)(`video`,{autoPlay:i.type===`gif`,className:`max-h-[92vh] max-w-[92vw]`,controls:!0,loop:i.type===`gif`,muted:i.type===`gif`,onClick:e=>e.stopPropagation(),playsInline:!0,poster:i.thumbnailUrl,src:a}):(0,W.jsxs)(`div`,{className:`grid min-h-64 min-w-80 place-items-center gap-3 rounded-2xl border border-white/20 bg-black p-6 text-white`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{children:i.type===`video`?`Video`:i.type===`gif`?`GIF`:`Media`}),(0,W.jsx)(`a`,{className:`rounded-full bg-white/10 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-white/20`,href:i.url,rel:`noreferrer`,target:`_blank`,children:`Open media`})]})]}):null]})}function Xe(e){if(!e.width||!e.height)return;let t=Math.min(e.width,Math.round(e.width/e.height*720));return{aspectRatio:`${String(e.width)} / ${String(e.height)}`,width:`${String(t)}px`}}function Ze(e){try{let t=new URL(e);return t.hostname===`video.twimg.com`||/\.(?:mp4|m3u8)(?:$|[?#])/i.test(t.pathname)?e:void 0}catch{return/\.(?:mp4|m3u8)(?:$|[?#])/i.test(e)?e:void 0}}function Qe({anchorId:e,error:t,items:n,loading:r}){return r?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--line)] bg-[var(--bg-card)]`,children:(0,W.jsx)(De,{detail:`Finding archived replies around this post`,label:`Loading conversation`})}):t?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--alert)] bg-[var(--alert-soft)] px-4 py-3 text-[14px] text-[var(--alert)]`,children:t}):n.length<=1?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--line)]`,children:(0,W.jsx)(Ae,{detail:`This post has no other archived replies locally.`,label:`No thread context yet`})}):(0,W.jsxs)(`section`,{"aria-label":`Conversation`,className:`mt-3 overflow-hidden rounded-2xl border border-[var(--line)] bg-[var(--bg-card)]`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--line)] px-4 py-2.5 text-[13px] font-bold text-[var(--ink)]`,children:[(0,W.jsx)(V,{className:A,strokeWidth:1.8}),(0,W.jsxs)(`span`,{children:[n.length,` tweets in conversation`]})]}),(0,W.jsx)(`div`,{className:`flex flex-col`,children:n.map((t,r)=>{let a=t.id===e;return(0,W.jsxs)(`div`,{className:u(`flex gap-3 px-4 py-3`,r>0&&`border-t border-[var(--line)]`,a&&`bg-[var(--accent-soft)]`),children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,W.jsx)(xe,{avatarUrl:t.author.avatarUrl,hue:t.author.avatarHue,name:t.author.displayName,profileId:t.author.id,size:`small`}),r<n.length-1?(0,W.jsx)(`span`,{className:`mt-2 w-px flex-1 bg-[var(--line)]`}):null]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`header`,{className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,W.jsx)(L,{profile:t.author,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:p,children:t.author.displayName}),(0,W.jsxs)(`span`,{className:b,children:[`@`,t.author.handle]})]})}),(0,W.jsx)(`span`,{className:`text-[var(--ink-soft)]`,children:`·`}),(0,W.jsx)(R,{className:i,value:t.createdAt}),a?(0,W.jsx)(`span`,{className:`ml-auto rounded-full bg-[var(--accent)] px-2 py-0.5 text-[11px] font-bold text-white`,children:`selected`}):null]}),(0,W.jsx)(H,{className:`mt-1 whitespace-pre-wrap break-words text-[14px] leading-[1.45] text-[var(--ink)] [overflow-wrap:anywhere]`,entities:t.entities,text:t.text}),(0,W.jsx)(K,{items:t.media}),t.entities.article?(0,W.jsx)(G,{article:t.entities.article}):null]})]},t.id)})})]})}function q({item:e,label:t}){return(0,W.jsxs)(`section`,{className:ne,children:[(0,W.jsx)(`p`,{className:x,children:t}),(0,W.jsxs)(`header`,{className:ie,children:[(0,W.jsx)(L,{profile:e.author,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:O,children:e.author.displayName}),(0,W.jsxs)(`span`,{className:te,children:[`@`,e.author.handle]})]})}),(0,W.jsx)(`span`,{className:`text-[var(--ink-soft)]`,children:`·`}),(0,W.jsx)(R,{className:i,value:e.createdAt})]}),(0,W.jsx)(H,{className:y,entities:e.entities,text:e.text}),(0,W.jsx)(K,{items:e.media}),e.entities.article?(0,W.jsx)(G,{article:e.entities.article}):null]})}var $e=2,J=0,Y=[];function et(e){let t=e.expandedUrl||``;return e.imageUrl&&e.siteName&&e.title&&it(t)?!1:!e.imageUrl||!e.title||!e.description||e.title===e.displayUrl||e.description===e.displayUrl}function tt(){for(;J<$e&&Y.length>0;)Y.shift()?.()}function nt(e){return new Promise((t,n)=>{Y.push(()=>{J+=1,e().then(t).catch(n).finally(()=>{J=Math.max(0,J-1),tt()})}),tt()})}function rt(e){let t=new URLSearchParams({url:e});return Ue({queryKey:[...P.linkPreviews,e],queryFn:()=>nt(()=>_e(`/api/link-preview?${t.toString()}`,void 0,he,`Link preview unavailable`).then(e=>e.preview)),staleTime:30*6e4})}function X(e,t){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return t}}function it(e){try{let t=new URL(e);return t.protocol===`https:`&&t.hostname===`pbs.twimg.com`&&(t.pathname.startsWith(`/media/`)||t.pathname.startsWith(`/amplify_video_thumb/`))}catch{return!1}}function at(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`https:`&&t.hostname===`pbs.twimg.com`&&(t.pathname.startsWith(`/media/`)||t.pathname.startsWith(`/amplify_video_thumb/`))?t.toString():null}catch{return null}}function ot({entry:e,index:t}){let r=I(e.expandedUrl||e.url),i=r??``,a=e.displayUrl||(r?X(r,r):``),o=r&&it(r)?r:null,s=(0,U.useMemo)(()=>({expandedUrl:i,displayUrl:a,title:e.title??(o?X(i,a):void 0),description:e.description??(o?a:void 0),imageUrl:e.imageUrl??o,siteName:e.siteName??(o?X(i,a):void 0)}),[o,a,e.description,e.imageUrl,e.siteName,e.title,i]),[c,l]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1),g=(0,U.useRef)(null),_=!!(r&&et(s)),v=z({...rt(r??``),enabled:_&&f&&m}),y=(0,U.useMemo)(()=>{let e=v.data;return e?{expandedUrl:I(e.url)??s.expandedUrl,displayUrl:s.displayUrl,title:e.title??s.title,description:e.description??s.description,imageUrl:e.imageUrl??s.imageUrl,siteName:e.siteName??s.siteName}:s},[s,v.data]);if((0,U.useEffect)(()=>{l(!1),p(!1),h(!1)},[s]),(0,U.useEffect)(()=>{if(!r||!_)return;let e=g.current;if(!e||typeof IntersectionObserver>`u`){p(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(p(!0),t.disconnect())},{rootMargin:`320px 0px`});return t.observe(e),()=>t.disconnect()},[_,r]),(0,U.useEffect)(()=>{if(!r||!f||!_)return;let e=window.setTimeout(()=>{h(!0)},100);return()=>window.clearTimeout(e)},[f,_,r]),!r)return null;let b=y.title||e.displayUrl,x=y.description&&y.description!==b?y.description:y.siteName||X(y.expandedUrl,e.displayUrl),S=y.siteName||X(y.expandedUrl,e.displayUrl),C=at(y.imageUrl),w=!!(C&&!c);return(0,W.jsxs)(`a`,{className:D,"data-perf":`link-preview-card`,href:I(y.expandedUrl)??r,ref:g,rel:`noreferrer`,target:`_blank`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:E,children:S}),(0,W.jsx)(B,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)] opacity-0 transition-opacity group-hover/link-preview:opacity-100`,strokeWidth:1.8})]}),(0,W.jsx)(`span`,{className:d,children:b}),(0,W.jsx)(`span`,{className:n,children:x}),(0,W.jsx)(`span`,{className:u(E,`text-[12px]`),children:e.displayUrl})]}),(0,W.jsx)(`div`,{className:`flex aspect-[1.45] w-40 shrink-0 items-center justify-center overflow-hidden border-l border-[var(--line)] bg-[var(--bg-soft)] max-[720px]:w-28`,children:w?(0,W.jsx)(`img`,{alt:b,className:`size-full object-cover transition-transform duration-200 group-hover/link-preview:scale-[1.03]`,loading:`lazy`,onError:()=>l(!0),src:C??``}):(0,W.jsx)(Be,{"aria-hidden":`true`,className:`size-8 text-[var(--ink-soft)]`,strokeWidth:1.7})})]},`${e.expandedUrl}-${String(t)}`)}function st(e){if(!e)return null;try{let t=new URL(e);return`${t.protocol}//${t.hostname}${t.pathname}`}catch{return e.split(`?`)[0]??e}}function ct(e){let t=new Set;for(let n of e)for(let e of[n.url,n.thumbnailUrl]){let n=st(e);n&&t.add(n)}return t}function lt(e,t,n){if(t.size>0&&ft(e.expandedUrl,n))return!0;for(let n of[e.url,e.expandedUrl,e.displayUrl]){let e=st(n);if(e&&t.has(e))return!0}return!1}function Z(e){if(!e)return!1;try{let t=e.includes(`://`)?e:`https://${e}`;return new URL(t).hostname.replace(/^www\./,``)===`t.co`}catch{return!1}}function Q(e){return Z(e.expandedUrl)?!0:e.expandedUrl?!1:Z(e.displayUrl)?!0:!e.displayUrl&&Z(e.url)}function ut(e,t){return(t.urls??[]).filter(Q).map(t=>Se(e,t))}function dt(e,t){let n=0,r=``;for(let i of[...t].sort((e,t)=>e.start-t.start))i.start<n||i.end<=i.start||i.end>e.length||(r+=e.slice(n,i.start),n=i.end);return r+=e.slice(n),r}function $(e,t,n){if(n.size===0)return!1;let r=ut(e,t);return r.length===0?!1:dt(e,r).trim().length===0}function ft(e,t){if(!e)return!1;try{let n=new URL(e),r=n.hostname.replace(/^www\./,``);if(r!==`x.com`&&r!==`twitter.com`)return!1;let i=n.pathname.split(`/`).filter(Boolean),a=i.indexOf(`status`);if(a<0||i[a+1]!==t)return!1;let o=i[a+2];return o===`photo`||o===`video`}catch{return!1}}function pt(e,t,n,r){let i=ct(t);if(i.size===0)return e;let a=$(r,e,i);return{...e,urls:(e.urls??[]).filter(e=>!lt(e,i,n)&&!(a&&Q(e)))}}function mt(e,t,n,r){let i=ct(t);if(i.size===0)return[];let a=$(r,e,i);return(e.urls??[]).filter(e=>lt(e,i,n)||a&&Q(e)).map(e=>Se(r,e))}function ht(e,t){return(e.urls??[]).filter(n=>Q(n)||e.article&&Ce(n,e.article)?!1:t?!n.expandedUrl.includes(t):!0)}function gt(e){return e instanceof Element&&!!e.closest(`a,button,input,textarea,select,[role='button']`)}function _t({tweet:e,hiddenUrlRanges:t,visibleUrlCards:n,replyToTweet:r,quotedTweet:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{className:a,entities:e.entities,hiddenUrlRanges:t,text:e.text}),(0,W.jsx)(K,{items:e.media}),e.entities.article?(0,W.jsx)(G,{article:e.entities.article}):null,r?(0,W.jsx)(`div`,{className:T,children:(0,W.jsx)(q,{item:r,label:`In reply to`})}):null,i?(0,W.jsx)(`div`,{className:T,children:(0,W.jsx)(q,{item:i,label:`Quoted tweet`})}):null,n.map((e,t)=>(0,W.jsx)(ot,{entry:e,index:t},`${e.expandedUrl}-${String(t)}`))]})}function vt({item:e,onReply:t,showReplyControls:n=!0}){let a=n&&e.kind!==`like`&&e.kind!==`bookmark`,o=e.retweetedTweet??e,s=o.id,c=e.retweetedTweet&&s===`${e.id}:retweeted`?e.id:s,l=o.author,d=Je(e.id,c),f=pt(o.entities,o.media,o.id,o.text),h=mt(o.entities,o.media,o.id,o.text),g=ht(f,e.retweetedTweet?null:e.quotedTweet?.id??null),v=e.retweetedTweet?o.mediaCount??o.media.length:e.mediaCount,y=o.isReplied??e.isReplied,x=o.likeCount??e.likeCount,w=o.bookmarked??e.bookmarked,T=o.liked??e.liked,E=T||x>0,D=v>0,O=!!(e.retweetedTweet?o.replyToId:e.replyToTweet||e.replyToId);return(0,W.jsxs)(`article`,{className:u(ae,`cursor-pointer [content-visibility:auto] [contain-intrinsic-size:auto_280px]`),"data-perf":`timeline-card`,onFocus:d.prefetch,onMouseEnter:d.prefetch,onClick:e=>{gt(e.target)||d.toggle()},children:[(0,W.jsx)(xe,{avatarUrl:l.avatarUrl,hue:l.avatarHue,name:l.displayName,profileId:l.id}),(0,W.jsxs)(`div`,{className:_,children:[e.retweetedTweet?(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,W.jsx)(le,{className:`size-4`,strokeWidth:1.8}),(0,W.jsx)(L,{profile:e.author,children:(0,W.jsxs)(`span`,{children:[e.author.displayName,` reposted`]})})]}):null,(0,W.jsxs)(`header`,{className:oe,children:[(0,W.jsx)(L,{profile:l,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:p,children:l.displayName}),(0,W.jsxs)(`span`,{className:b,children:[`@`,l.handle]})]})}),(0,W.jsx)(`span`,{className:se,children:`·`}),(0,W.jsx)(R,{className:i,value:o.createdAt}),a||O?(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1`,children:[O?(0,W.jsxs)(`span`,{"aria-label":`Part of a conversation`,className:u(j,r),title:`Part of a conversation`,children:[(0,W.jsx)(V,{className:`size-3.5`,strokeWidth:2}),`thread`]}):null,a?(0,W.jsxs)(`span`,{"aria-label":y?`We replied`:`Reply open`,className:u(j,y?r:m),title:y?`We replied`:`Reply open`,children:[y?(0,W.jsx)(ce,{className:`size-3.5`,strokeWidth:2}):(0,W.jsx)(Le,{className:`size-3`,strokeWidth:2.2}),y?`replied`:`open`]}):null]}):null]}),(0,W.jsx)(_t,{hiddenUrlRanges:h,quotedTweet:e.retweetedTweet?null:e.quotedTweet,replyToTweet:e.retweetedTweet?null:e.replyToTweet,tweet:o,visibleUrlCards:g}),(0,W.jsx)(`footer`,{className:C,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-[13px] text-[var(--ink-soft)]`,children:[(0,W.jsxs)(`button`,{"aria-expanded":d.isOpen,"aria-label":d.isOpen?`Hide conversation`:`Show conversation`,className:S,onClick:e=>{e.stopPropagation(),d.toggle()},type:`button`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(V,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:d.isOpen?`Hide thread`:`Thread`})]}),a?(0,W.jsxs)(`button`,{className:S,onClick:e=>{e.stopPropagation(),t(c)},type:`button`,"aria-label":`Reply`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(V,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:`Reply`})]}):null,(0,W.jsxs)(`a`,{"aria-label":`Analyse @${l.handle}`,className:S,href:`/profiles/${encodeURIComponent(l.handle)}`,onClick:e=>{e.stopPropagation()},title:`Analyse @${l.handle}`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(ke,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:`Analyse`})]}),E?(0,W.jsxs)(`span`,{"aria-label":`${F(x)} likes`,className:u(`inline-flex items-center gap-1 px-2 py-1 text-[13px]`,T&&`text-[var(--like)]`),title:`${F(x)} likes`,children:[(0,W.jsx)(Ne,{className:A,strokeWidth:1.7,fill:T?`currentColor`:`none`}),(0,W.jsx)(`span`,{children:F(x)})]}):null,w?(0,W.jsx)(`span`,{"aria-label":`Bookmarked`,className:`inline-flex items-center px-2 py-1`,title:`Bookmarked`,children:(0,W.jsx)(ze,{className:A,strokeWidth:1.7})}):null,D?(0,W.jsxs)(`span`,{"aria-label":`${String(v)} media attachments`,className:`inline-flex items-center gap-1 px-2 py-1 text-[13px]`,title:`${String(v)} media attachments`,children:[(0,W.jsx)(Be,{className:A,strokeWidth:1.7}),(0,W.jsx)(`span`,{children:v})]}):null]})}),d.isOpen?(0,W.jsx)(Qe,{anchorId:c,error:d.error,items:d.items,loading:d.loading}):null]})]})}function yt({title:e,subtitles:t,action:n,controls:r}){return(0,W.jsxs)(`header`,{className:h,children:[(0,W.jsxs)(`div`,{className:g,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,W.jsx)(`h1`,{className:c,children:e}),t]}),n]}),r]})}function bt({children:e}){return(0,W.jsx)(`p`,{className:s,children:e})}function xt({value:e,onChange:t,placeholder:n}){return(0,W.jsx)(`div`,{className:`px-4 pb-3`,children:(0,W.jsxs)(`label`,{className:re,children:[(0,W.jsx)(ue,{className:v,strokeWidth:2}),(0,W.jsx)(`input`,{className:ee,onChange:e=>t(e.target.value),placeholder:n,value:e})]})})}function St({header:e,notice:t,loading:n,loadingLabel:r,loadingDetail:i,error:a,errorTitle:o,onRetry:s,empty:c,emptyLabel:l,emptyDetail:u,children:d,hasMore:f,loadingMore:p,onLoadMore:m}){return(0,W.jsxs)(W.Fragment,{children:[e,t,(0,W.jsx)(qe,{children:(0,W.jsxs)(`section`,{className:w,children:[n?(0,W.jsx)(we,{detail:i,label:r,children:(0,W.jsx)(Te,{})}):a?(0,W.jsx)(je,{action:(0,W.jsx)(`button`,{className:`rounded-full bg-[var(--accent)] px-4 py-1.5 text-[14px] font-bold text-white`,onClick:s,type:`button`,children:`Retry`}),message:a,title:o}):c?(0,W.jsx)(Ee,{detail:u,label:l}):null,d,!n&&!a&&f?(0,W.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,W.jsx)(`button`,{className:`rounded-full bg-[var(--accent)] px-5 py-1.5 text-[14px] font-bold text-white disabled:opacity-60`,disabled:p,onClick:m,type:`button`,children:p?`Loading…`:`Load more`})}):null]})})]})}var Ct=50,wt=5*6e4;function Tt({resource:e,search:t,replyFilter:n,likedOnly:r,bookmarkedOnly:i,selectedAccountId:a,pageParam:o}){let s=new URLSearchParams({resource:e,limit:String(Ct)});a&&s.set(`account`,a),n&&s.set(`replyFilter`,n),r&&s.set(`liked`,`true`),i&&s.set(`bookmarked`,`true`),t.trim()&&s.set(`search`,t.trim()),o&&(s.set(`until`,o.until),s.set(`untilId`,o.untilId)),s.sort();let c=typeof window>`u`?`http://birdclaw.local`:window.location.origin;return new URL(`/api/query?${s.toString()}`,c).toString()}function Et({resource:e,search:t,errorFallback:n,replyFilter:r,likedOnly:i=!1,bookmarkedOnly:a=!1}){let o=N(),s=z({queryKey:P.status,queryFn:({signal:e})=>fe({signal:e})}).data??null,c=Pe(s?.accounts),l=Oe(t,180),u=[...P.timelines,{resource:e,search:l,replyFilter:r??`all`,likedOnly:i,bookmarkedOnly:a,selectedAccountId:c??null}],d=We({queryKey:u,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ge(Tt({resource:e,search:l,replyFilter:r,likedOnly:i,bookmarkedOnly:a,selectedAccountId:c,pageParam:t}),{signal:n}),getNextPageParam:e=>{if(e.resource===`dms`)return;let t=e.items,n=t.at(-1);return t.length>=Ct&&n?{until:n.createdAt,untilId:n.id}:void 0},staleTime:wt}),f=(0,U.useMemo)(()=>{let e=new Set,t=[];for(let n of d.data?.pages??[])if(n.resource!==`dms`)for(let r of n.items)e.has(r.id)||(e.add(r.id),t.push(r));return t},[d.data]),p=Fe({mutationFn:({tweetId:e,text:t})=>ve({kind:`replyTweet`,accountId:c??`acct_primary`,tweetId:e,text:t}),onSuccess:()=>o.invalidateQueries({queryKey:u})});function m(){d.refetch()}function h(){Promise.all([o.invalidateQueries({queryKey:P.timelines}),o.invalidateQueries({queryKey:P.status})])}async function g(e){let t=window.prompt(`Reply text`);t?.trim()&&await p.mutateAsync({tweetId:e,text:t.trim()}).catch(()=>{})}let _=d.error;return{meta:s,items:f,loading:d.isPending,error:_?_ instanceof Error?_.message:n:null,replyError:p.error?p.error instanceof Error?p.error.message:`Reply failed`:null,retry:m,refreshLocalView:h,replyToTweet:g,selectedAccountId:c,hasMore:d.hasNextPage,loadingMore:d.isFetchingNextPage,loadMore:()=>d.fetchNextPage().then(()=>void 0)}}export{xt as a,bt as i,yt as n,vt as o,St as r,Et as t};
1
+ import{r as e}from"./chunk-C0phanGV.js";import{t}from"./react-nBylq1U5.js";import{At as n,Ct as r,Dt as i,Et as a,Fn as o,Gt as s,Kt as c,Ln as l,M as u,Mt as d,Pn as f,St as p,Tt as m,Ut as h,Wt as g,_t as _,an as v,at as y,bt as b,ct as x,ft as S,gt as C,ht as w,it as T,jt as E,kt as D,lt as O,mt as k,on as ee,ot as te,pt as A,rt as ne,sn as re,st as ie,vt as ae,wt as j,xt as oe,yt as se}from"./schemas-I9r6F6ya.js";import{t as M}from"./createLucideIcon-JV8isFFR.js";import{t as ce}from"./circle-check-C_Vq3ElD.js";import{t as le}from"./repeat-2-xCwHM9hD.js";import{t as ue}from"./search-Dq5kYsxA.js";import{C as de,a as fe,b as N,i as pe,l as me,m as he,n as P,o as ge,r as _e,s as ve,v as ye,w as be}from"./query-client-fYu2rzRC.js";import{r as F,t as xe}from"./AvatarChip-DLoqM5xD.js";import{c as Se,i as I,s as Ce,t as L}from"./ProfilePreview-DQX6_xc3.js";import{t as R}from"./SmartTimestamp-BR0-9se2.js";import{A as we,M as Te,O as Ee,at as De,ct as z,d as Oe,dt as ke,gt as B,it as Ae,k as je,lt as Me,mt as Ne,ot as Pe,pt as V,s as H,st as Fe,ut as Ie,yt as Le}from"./index-DZVisyna.js";var Re=M(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),ze=M(`bookmark-check`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]),Be=M(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Ve=M(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),He=class extends Ie{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:de(t,n.data),hasPreviousPage:be(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Ue(e){return e}function We(e,t){return Me(e,He,t)}var U=e(t(),1),Ge=(0,U.createContext)(null);function Ke(e){return Ue({queryKey:[...P.conversations,e],queryFn:()=>me(pe(`/api/conversation?tweetId=${encodeURIComponent(e)}`,void 0,ye,`Conversation unavailable`)).then(e=>e.items),staleTime:1/0})}function qe({children:e}){let[t,n]=(0,U.useState)(null),r=(0,U.useMemo)(()=>({expandedSurfaceId:t,setExpandedSurfaceId:n}),[t]);return(0,U.createElement)(Ge.Provider,{value:r},e)}function Je(e,t=e){let n=(0,U.useContext)(Ge),[r,i]=(0,U.useState)(null),a=n?.expandedSurfaceId??r,o=n?.setExpandedSurfaceId??i,s=a===e,c=N(),l=z({...Ke(t),enabled:s}),u=(0,U.useCallback)(()=>{o(s?null:e)},[s,o,e]),d=(0,U.useCallback)(()=>{c.prefetchQuery(Ke(t))},[c,t]),f=l.isError?`error`:l.isFetching?`loading`:l.data?`ready`:`idle`;return{error:l.error instanceof Error?l.error.message:null,isOpen:s,items:l.data??[],loading:l.isFetching,prefetch:d,status:f,toggle:u}}var W=l();function Ye(e){let t=I(e);if(!t)return null;try{return new URL(t).hostname===`pbs.twimg.com`?t:null}catch{return null}}function G({article:e}){let t=I(e.url);if(!t)return null;let r=Ye(e.coverImageUrl);return(0,W.jsxs)(`a`,{"aria-label":`Read article: ${e.title}`,className:D,"data-perf":`tweet-article-card`,href:t,rel:`noreferrer`,target:`_blank`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(Re,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)]`,strokeWidth:1.8}),(0,W.jsx)(`span`,{className:E,children:`Article on X`}),(0,W.jsx)(B,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)] opacity-0 transition-opacity group-hover/link-preview:opacity-100`,strokeWidth:1.8})]}),(0,W.jsx)(`span`,{className:d,children:e.title}),e.previewText?(0,W.jsx)(`span`,{className:n,children:e.previewText}):null]}),r?(0,W.jsx)(`div`,{className:`flex aspect-[1.45] w-40 shrink-0 overflow-hidden border-l border-[var(--line)] bg-[var(--bg-soft)] max-[720px]:w-28`,children:(0,W.jsx)(`img`,{alt:``,className:`size-full object-cover transition-transform duration-200 group-hover/link-preview:scale-[1.03]`,loading:`lazy`,src:r})}):null]})}function K({items:e}){let[t,n]=(0,U.useState)(null);if(e.length===0)return null;let r=e.slice(0,4),i=t===null?null:r[t]??null,a=i?.type===`video`||i?.type===`gif`?i.variants?.[0]?.url??Ze(i.url):null,s=r.length===1&&r[0]?.type===`image`?r[0]:null;return(0,W.jsxs)(W.Fragment,{children:[s?(0,W.jsx)(`button`,{"aria-label":`Open tweet media 1`,className:u(`tweet-media-single mt-2 max-w-full overflow-hidden rounded-2xl border border-[var(--line)] bg-[var(--bg-active)] p-0 text-left`,s.width&&s.height?`block`:`inline-block align-top`),onClick:e=>{e.stopPropagation(),n(0)},style:Xe(s),type:`button`,children:(0,W.jsx)(`img`,{alt:s.altText??`Tweet media 1`,className:u(`tweet-media-image block max-h-[720px] max-w-full`,s.width&&s.height?`size-full object-cover`:`h-auto w-auto object-contain`),height:s.height,loading:`lazy`,src:s.thumbnailUrl??s.url,width:s.width})}):(0,W.jsx)(`div`,{className:f(Math.min(e.length,4)),children:r.map((t,i)=>(0,W.jsx)(`button`,{"aria-label":`Open tweet media ${String(i+1)}`,className:o(i,Math.min(e.length,4)),onClick:e=>{e.stopPropagation(),n(i)},style:r.length===1&&t.width&&t.height?{aspectRatio:`${String(t.width)} / ${String(t.height)}`}:void 0,type:`button`,children:t.type===`image`?(0,W.jsx)(`img`,{alt:t.altText??`Tweet media ${String(i+1)}`,className:`tweet-media-image block size-full object-contain`,loading:`lazy`,src:t.thumbnailUrl??t.url}):(0,W.jsx)(`span`,{className:`tweet-media-fallback grid min-h-40 place-items-center font-semibold text-[var(--ink-soft)]`,children:t.type===`video`?`Video`:t.type===`gif`?`GIF`:`Media`})},t.url+String(i)))}),i?(0,W.jsxs)(`div`,{"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/85 p-4`,onClick:e=>{e.stopPropagation(),n(null)},role:`dialog`,children:[(0,W.jsx)(`button`,{"aria-label":`Close media viewer`,className:`absolute right-4 top-4 grid size-10 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20`,onClick:e=>{e.stopPropagation(),n(null)},type:`button`,children:(0,W.jsx)(Ve,{className:`size-5`,strokeWidth:1.8})}),i.type===`image`?(0,W.jsx)(`img`,{alt:i.altText??`Tweet media`,className:`max-h-[92vh] max-w-[92vw] object-contain`,onClick:e=>e.stopPropagation(),src:i.url}):a?(0,W.jsx)(`video`,{autoPlay:i.type===`gif`,className:`max-h-[92vh] max-w-[92vw]`,controls:!0,loop:i.type===`gif`,muted:i.type===`gif`,onClick:e=>e.stopPropagation(),playsInline:!0,poster:i.thumbnailUrl,src:a}):(0,W.jsxs)(`div`,{className:`grid min-h-64 min-w-80 place-items-center gap-3 rounded-2xl border border-white/20 bg-black p-6 text-white`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{children:i.type===`video`?`Video`:i.type===`gif`?`GIF`:`Media`}),(0,W.jsx)(`a`,{className:`rounded-full bg-white/10 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-white/20`,href:i.url,rel:`noreferrer`,target:`_blank`,children:`Open media`})]})]}):null]})}function Xe(e){if(!e.width||!e.height)return;let t=Math.min(e.width,Math.round(e.width/e.height*720));return{aspectRatio:`${String(e.width)} / ${String(e.height)}`,width:`${String(t)}px`}}function Ze(e){try{let t=new URL(e);return t.hostname===`video.twimg.com`||/\.(?:mp4|m3u8)(?:$|[?#])/i.test(t.pathname)?e:void 0}catch{return/\.(?:mp4|m3u8)(?:$|[?#])/i.test(e)?e:void 0}}function Qe({anchorId:e,error:t,items:n,loading:r}){return r?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--line)] bg-[var(--bg-card)]`,children:(0,W.jsx)(De,{detail:`Finding archived replies around this post`,label:`Loading conversation`})}):t?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--alert)] bg-[var(--alert-soft)] px-4 py-3 text-[14px] text-[var(--alert)]`,children:t}):n.length<=1?(0,W.jsx)(`section`,{className:`mt-3 rounded-2xl border border-[var(--line)]`,children:(0,W.jsx)(Ae,{detail:`This post has no other archived replies locally.`,label:`No thread context yet`})}):(0,W.jsxs)(`section`,{"aria-label":`Conversation`,className:`mt-3 overflow-hidden rounded-2xl border border-[var(--line)] bg-[var(--bg-card)]`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--line)] px-4 py-2.5 text-[13px] font-bold text-[var(--ink)]`,children:[(0,W.jsx)(V,{className:A,strokeWidth:1.8}),(0,W.jsxs)(`span`,{children:[n.length,` tweets in conversation`]})]}),(0,W.jsx)(`div`,{className:`flex flex-col`,children:n.map((t,r)=>{let a=t.id===e;return(0,W.jsxs)(`div`,{className:u(`flex gap-3 px-4 py-3`,r>0&&`border-t border-[var(--line)]`,a&&`bg-[var(--accent-soft)]`),children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,W.jsx)(xe,{avatarUrl:t.author.avatarUrl,hue:t.author.avatarHue,name:t.author.displayName,profileId:t.author.id,size:`small`}),r<n.length-1?(0,W.jsx)(`span`,{className:`mt-2 w-px flex-1 bg-[var(--line)]`}):null]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`header`,{className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,W.jsx)(L,{profile:t.author,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:p,children:t.author.displayName}),(0,W.jsxs)(`span`,{className:b,children:[`@`,t.author.handle]})]})}),(0,W.jsx)(`span`,{className:`text-[var(--ink-soft)]`,children:`·`}),(0,W.jsx)(R,{className:i,value:t.createdAt}),a?(0,W.jsx)(`span`,{className:`ml-auto rounded-full bg-[var(--accent)] px-2 py-0.5 text-[11px] font-bold text-white`,children:`selected`}):null]}),(0,W.jsx)(H,{className:`mt-1 whitespace-pre-wrap break-words text-[14px] leading-[1.45] text-[var(--ink)] [overflow-wrap:anywhere]`,entities:t.entities,text:t.text}),(0,W.jsx)(K,{items:t.media}),t.entities.article?(0,W.jsx)(G,{article:t.entities.article}):null]})]},t.id)})})]})}function q({item:e,label:t}){return(0,W.jsxs)(`section`,{className:ne,children:[(0,W.jsx)(`p`,{className:x,children:t}),(0,W.jsxs)(`header`,{className:ie,children:[(0,W.jsx)(L,{profile:e.author,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:O,children:e.author.displayName}),(0,W.jsxs)(`span`,{className:te,children:[`@`,e.author.handle]})]})}),(0,W.jsx)(`span`,{className:`text-[var(--ink-soft)]`,children:`·`}),(0,W.jsx)(R,{className:i,value:e.createdAt})]}),(0,W.jsx)(H,{className:y,entities:e.entities,text:e.text}),(0,W.jsx)(K,{items:e.media}),e.entities.article?(0,W.jsx)(G,{article:e.entities.article}):null]})}var $e=2,J=0,Y=[];function et(e){let t=e.expandedUrl||``;return e.imageUrl&&e.siteName&&e.title&&it(t)?!1:!e.imageUrl||!e.title||!e.description||e.title===e.displayUrl||e.description===e.displayUrl}function tt(){for(;J<$e&&Y.length>0;)Y.shift()?.()}function nt(e){return new Promise((t,n)=>{Y.push(()=>{J+=1,e().then(t).catch(n).finally(()=>{J=Math.max(0,J-1),tt()})}),tt()})}function rt(e){let t=new URLSearchParams({url:e});return Ue({queryKey:[...P.linkPreviews,e],queryFn:()=>nt(()=>_e(`/api/link-preview?${t.toString()}`,void 0,he,`Link preview unavailable`).then(e=>e.preview)),staleTime:30*6e4})}function X(e,t){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return t}}function it(e){try{let t=new URL(e);return t.protocol===`https:`&&t.hostname===`pbs.twimg.com`&&(t.pathname.startsWith(`/media/`)||t.pathname.startsWith(`/amplify_video_thumb/`))}catch{return!1}}function at(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`https:`&&t.hostname===`pbs.twimg.com`&&(t.pathname.startsWith(`/media/`)||t.pathname.startsWith(`/amplify_video_thumb/`))?t.toString():null}catch{return null}}function ot({entry:e,index:t}){let r=I(e.expandedUrl||e.url),i=r??``,a=e.displayUrl||(r?X(r,r):``),o=r&&it(r)?r:null,s=(0,U.useMemo)(()=>({expandedUrl:i,displayUrl:a,title:e.title??(o?X(i,a):void 0),description:e.description??(o?a:void 0),imageUrl:e.imageUrl??o,siteName:e.siteName??(o?X(i,a):void 0)}),[o,a,e.description,e.imageUrl,e.siteName,e.title,i]),[c,l]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1),g=(0,U.useRef)(null),_=!!(r&&et(s)),v=z({...rt(r??``),enabled:_&&f&&m}),y=(0,U.useMemo)(()=>{let e=v.data;return e?{expandedUrl:I(e.url)??s.expandedUrl,displayUrl:s.displayUrl,title:e.title??s.title,description:e.description??s.description,imageUrl:e.imageUrl??s.imageUrl,siteName:e.siteName??s.siteName}:s},[s,v.data]);if((0,U.useEffect)(()=>{l(!1),p(!1),h(!1)},[s]),(0,U.useEffect)(()=>{if(!r||!_)return;let e=g.current;if(!e||typeof IntersectionObserver>`u`){p(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(p(!0),t.disconnect())},{rootMargin:`320px 0px`});return t.observe(e),()=>t.disconnect()},[_,r]),(0,U.useEffect)(()=>{if(!r||!f||!_)return;let e=window.setTimeout(()=>{h(!0)},100);return()=>window.clearTimeout(e)},[f,_,r]),!r)return null;let b=y.title||e.displayUrl,x=y.description&&y.description!==b?y.description:y.siteName||X(y.expandedUrl,e.displayUrl),S=y.siteName||X(y.expandedUrl,e.displayUrl),C=at(y.imageUrl),w=!!(C&&!c);return(0,W.jsxs)(`a`,{className:D,"data-perf":`link-preview-card`,href:I(y.expandedUrl)??r,ref:g,rel:`noreferrer`,target:`_blank`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:E,children:S}),(0,W.jsx)(B,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--ink-soft)] opacity-0 transition-opacity group-hover/link-preview:opacity-100`,strokeWidth:1.8})]}),(0,W.jsx)(`span`,{className:d,children:b}),(0,W.jsx)(`span`,{className:n,children:x}),(0,W.jsx)(`span`,{className:u(E,`text-[12px]`),children:e.displayUrl})]}),(0,W.jsx)(`div`,{className:`flex aspect-[1.45] w-40 shrink-0 items-center justify-center overflow-hidden border-l border-[var(--line)] bg-[var(--bg-soft)] max-[720px]:w-28`,children:w?(0,W.jsx)(`img`,{alt:b,className:`size-full object-cover transition-transform duration-200 group-hover/link-preview:scale-[1.03]`,loading:`lazy`,onError:()=>l(!0),src:C??``}):(0,W.jsx)(Be,{"aria-hidden":`true`,className:`size-8 text-[var(--ink-soft)]`,strokeWidth:1.7})})]},`${e.expandedUrl}-${String(t)}`)}function st(e){if(!e)return null;try{let t=new URL(e);return`${t.protocol}//${t.hostname}${t.pathname}`}catch{return e.split(`?`)[0]??e}}function ct(e){let t=new Set;for(let n of e)for(let e of[n.url,n.thumbnailUrl]){let n=st(e);n&&t.add(n)}return t}function lt(e,t,n){if(t.size>0&&ft(e.expandedUrl,n))return!0;for(let n of[e.url,e.expandedUrl,e.displayUrl]){let e=st(n);if(e&&t.has(e))return!0}return!1}function Z(e){if(!e)return!1;try{let t=e.includes(`://`)?e:`https://${e}`;return new URL(t).hostname.replace(/^www\./,``)===`t.co`}catch{return!1}}function Q(e){return Z(e.expandedUrl)?!0:e.expandedUrl?!1:Z(e.displayUrl)?!0:!e.displayUrl&&Z(e.url)}function ut(e,t){return(t.urls??[]).filter(Q).map(t=>Se(e,t))}function dt(e,t){let n=0,r=``;for(let i of[...t].sort((e,t)=>e.start-t.start))i.start<n||i.end<=i.start||i.end>e.length||(r+=e.slice(n,i.start),n=i.end);return r+=e.slice(n),r}function $(e,t,n){if(n.size===0)return!1;let r=ut(e,t);return r.length===0?!1:dt(e,r).trim().length===0}function ft(e,t){if(!e)return!1;try{let n=new URL(e),r=n.hostname.replace(/^www\./,``);if(r!==`x.com`&&r!==`twitter.com`)return!1;let i=n.pathname.split(`/`).filter(Boolean),a=i.indexOf(`status`);if(a<0||i[a+1]!==t)return!1;let o=i[a+2];return o===`photo`||o===`video`}catch{return!1}}function pt(e,t,n,r){let i=ct(t);if(i.size===0)return e;let a=$(r,e,i);return{...e,urls:(e.urls??[]).filter(e=>!lt(e,i,n)&&!(a&&Q(e)))}}function mt(e,t,n,r){let i=ct(t);if(i.size===0)return[];let a=$(r,e,i);return(e.urls??[]).filter(e=>lt(e,i,n)||a&&Q(e)).map(e=>Se(r,e))}function ht(e,t){return(e.urls??[]).filter(n=>Q(n)||e.article&&Ce(n,e.article)?!1:t?!n.expandedUrl.includes(t):!0)}function gt(e){return e instanceof Element&&!!e.closest(`a,button,input,textarea,select,[role='button']`)}function _t({tweet:e,hiddenUrlRanges:t,visibleUrlCards:n,replyToTweet:r,quotedTweet:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{className:a,entities:e.entities,hiddenUrlRanges:t,text:e.text}),(0,W.jsx)(K,{items:e.media}),e.entities.article?(0,W.jsx)(G,{article:e.entities.article}):null,r?(0,W.jsx)(`div`,{className:T,children:(0,W.jsx)(q,{item:r,label:`In reply to`})}):null,i?(0,W.jsx)(`div`,{className:T,children:(0,W.jsx)(q,{item:i,label:`Quoted tweet`})}):null,n.map((e,t)=>(0,W.jsx)(ot,{entry:e,index:t},`${e.expandedUrl}-${String(t)}`))]})}function vt({item:e,onReply:t,showReplyControls:n=!0}){let a=n&&e.kind!==`like`&&e.kind!==`bookmark`,o=e.retweetedTweet??e,s=o.id,c=e.retweetedTweet&&s===`${e.id}:retweeted`?e.id:s,l=o.author,d=Je(e.id,c),f=pt(o.entities,o.media,o.id,o.text),h=mt(o.entities,o.media,o.id,o.text),g=ht(f,e.retweetedTweet?null:e.quotedTweet?.id??null),v=e.retweetedTweet?o.mediaCount??o.media.length:e.mediaCount,y=o.isReplied??e.isReplied,x=o.likeCount??e.likeCount,w=o.bookmarked??e.bookmarked,T=o.liked??e.liked,E=T||x>0,D=v>0,O=!!(e.retweetedTweet?o.replyToId:e.replyToTweet||e.replyToId);return(0,W.jsxs)(`article`,{className:u(ae,`cursor-pointer [content-visibility:auto] [contain-intrinsic-size:auto_280px]`),"data-perf":`timeline-card`,onFocus:d.prefetch,onMouseEnter:d.prefetch,onClick:e=>{gt(e.target)||d.toggle()},children:[(0,W.jsx)(xe,{avatarUrl:l.avatarUrl,hue:l.avatarHue,name:l.displayName,profileId:l.id}),(0,W.jsxs)(`div`,{className:_,children:[e.retweetedTweet?(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-2 text-[13px] font-medium text-[var(--ink-soft)]`,children:[(0,W.jsx)(le,{className:`size-4`,strokeWidth:1.8}),(0,W.jsx)(L,{profile:e.author,children:(0,W.jsxs)(`span`,{children:[e.author.displayName,` reposted`]})})]}):null,(0,W.jsxs)(`header`,{className:oe,children:[(0,W.jsx)(L,{profile:l,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:p,children:l.displayName}),(0,W.jsxs)(`span`,{className:b,children:[`@`,l.handle]})]})}),(0,W.jsx)(`span`,{className:se,children:`·`}),(0,W.jsx)(R,{className:i,value:o.createdAt}),a||O?(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1`,children:[O?(0,W.jsxs)(`span`,{"aria-label":`Part of a conversation`,className:u(j,r),title:`Part of a conversation`,children:[(0,W.jsx)(V,{className:`size-3.5`,strokeWidth:2}),`thread`]}):null,a?(0,W.jsxs)(`span`,{"aria-label":y?`We replied`:`Reply open`,className:u(j,y?r:m),title:y?`We replied`:`Reply open`,children:[y?(0,W.jsx)(ce,{className:`size-3.5`,strokeWidth:2}):(0,W.jsx)(Le,{className:`size-3`,strokeWidth:2.2}),y?`replied`:`open`]}):null]}):null]}),(0,W.jsx)(_t,{hiddenUrlRanges:h,quotedTweet:e.retweetedTweet?null:e.quotedTweet,replyToTweet:e.retweetedTweet?null:e.replyToTweet,tweet:o,visibleUrlCards:g}),(0,W.jsx)(`footer`,{className:C,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-[13px] text-[var(--ink-soft)]`,children:[(0,W.jsxs)(`button`,{"aria-expanded":d.isOpen,"aria-label":d.isOpen?`Hide conversation`:`Show conversation`,className:S,onClick:e=>{e.stopPropagation(),d.toggle()},type:`button`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(V,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:d.isOpen?`Hide thread`:`Thread`})]}),a?(0,W.jsxs)(`button`,{className:S,onClick:e=>{e.stopPropagation(),t(c)},type:`button`,"aria-label":`Reply`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(V,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:`Reply`})]}):null,(0,W.jsxs)(`a`,{"aria-label":`Analyse @${l.handle}`,className:S,href:`/profiles/${encodeURIComponent(l.handle)}`,onClick:e=>{e.stopPropagation()},title:`Analyse @${l.handle}`,children:[(0,W.jsx)(`span`,{className:k,children:(0,W.jsx)(ke,{className:A,strokeWidth:1.7})}),(0,W.jsx)(`span`,{className:`text-[13px]`,children:`Analyse`})]}),E?(0,W.jsxs)(`span`,{"aria-label":`${F(x)} likes`,className:u(`inline-flex items-center gap-1 px-2 py-1 text-[13px]`,T&&`text-[var(--like)]`),title:`${F(x)} likes`,children:[(0,W.jsx)(Ne,{className:A,strokeWidth:1.7,fill:T?`currentColor`:`none`}),(0,W.jsx)(`span`,{children:F(x)})]}):null,w?(0,W.jsx)(`span`,{"aria-label":`Bookmarked`,className:`inline-flex items-center px-2 py-1`,title:`Bookmarked`,children:(0,W.jsx)(ze,{className:A,strokeWidth:1.7})}):null,D?(0,W.jsxs)(`span`,{"aria-label":`${String(v)} media attachments`,className:`inline-flex items-center gap-1 px-2 py-1 text-[13px]`,title:`${String(v)} media attachments`,children:[(0,W.jsx)(Be,{className:A,strokeWidth:1.7}),(0,W.jsx)(`span`,{children:v})]}):null]})}),d.isOpen?(0,W.jsx)(Qe,{anchorId:c,error:d.error,items:d.items,loading:d.loading}):null]})]})}function yt({title:e,subtitles:t,action:n,controls:r}){return(0,W.jsxs)(`header`,{className:h,children:[(0,W.jsxs)(`div`,{className:g,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,W.jsx)(`h1`,{className:c,children:e}),t]}),n]}),r]})}function bt({children:e}){return(0,W.jsx)(`p`,{className:s,children:e})}function xt({value:e,onChange:t,placeholder:n}){return(0,W.jsx)(`div`,{className:`px-4 pb-3`,children:(0,W.jsxs)(`label`,{className:re,children:[(0,W.jsx)(ue,{className:v,strokeWidth:2}),(0,W.jsx)(`input`,{className:ee,onChange:e=>t(e.target.value),placeholder:n,value:e})]})})}function St({header:e,notice:t,loading:n,loadingLabel:r,loadingDetail:i,error:a,errorTitle:o,onRetry:s,empty:c,emptyLabel:l,emptyDetail:u,children:d,hasMore:f,loadingMore:p,onLoadMore:m}){return(0,W.jsxs)(W.Fragment,{children:[e,t,(0,W.jsx)(qe,{children:(0,W.jsxs)(`section`,{className:w,children:[n?(0,W.jsx)(we,{detail:i,label:r,children:(0,W.jsx)(Te,{})}):a?(0,W.jsx)(je,{action:(0,W.jsx)(`button`,{className:`rounded-full bg-[var(--accent)] px-4 py-1.5 text-[14px] font-bold text-white`,onClick:s,type:`button`,children:`Retry`}),message:a,title:o}):c?(0,W.jsx)(Ee,{detail:u,label:l}):null,d,!n&&!a&&f?(0,W.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,W.jsx)(`button`,{className:`rounded-full bg-[var(--accent)] px-5 py-1.5 text-[14px] font-bold text-white disabled:opacity-60`,disabled:p,onClick:m,type:`button`,children:p?`Loading…`:`Load more`})}):null]})})]})}var Ct=50,wt=5*6e4;function Tt({resource:e,search:t,replyFilter:n,likedOnly:r,bookmarkedOnly:i,selectedAccountId:a,pageParam:o}){let s=new URLSearchParams({resource:e,limit:String(Ct)});a&&s.set(`account`,a),n&&s.set(`replyFilter`,n),r&&s.set(`liked`,`true`),i&&s.set(`bookmarked`,`true`),t.trim()&&s.set(`search`,t.trim()),o&&(s.set(`until`,o.until),s.set(`untilId`,o.untilId)),s.sort();let c=typeof window>`u`?`http://birdclaw.local`:window.location.origin;return new URL(`/api/query?${s.toString()}`,c).toString()}function Et({resource:e,search:t,errorFallback:n,replyFilter:r,likedOnly:i=!1,bookmarkedOnly:a=!1}){let o=N(),s=z({queryKey:P.status,queryFn:({signal:e})=>fe({signal:e})}).data??null,c=Pe(s?.accounts),l=Oe(t,180),u=[...P.timelines,{resource:e,search:l,replyFilter:r??`all`,likedOnly:i,bookmarkedOnly:a,selectedAccountId:c??null}],d=We({queryKey:u,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ge(Tt({resource:e,search:l,replyFilter:r,likedOnly:i,bookmarkedOnly:a,selectedAccountId:c,pageParam:t}),{signal:n}),getNextPageParam:e=>{if(e.resource===`dms`)return;let t=e.items,n=t.at(-1);return t.length>=Ct&&n?{until:n.createdAt,untilId:n.id}:void 0},staleTime:wt}),f=(0,U.useMemo)(()=>{let e=new Set,t=[];for(let n of d.data?.pages??[])if(n.resource!==`dms`)for(let r of n.items)e.has(r.id)||(e.add(r.id),t.push(r));return t},[d.data]),p=Fe({mutationFn:({tweetId:e,text:t})=>ve({kind:`replyTweet`,accountId:c??`acct_primary`,tweetId:e,text:t}),onSuccess:()=>o.invalidateQueries({queryKey:u})});function m(){d.refetch()}function h(){Promise.all([o.invalidateQueries({queryKey:P.timelines}),o.invalidateQueries({queryKey:P.status})])}async function g(e){let t=window.prompt(`Reply text`);t?.trim()&&await p.mutateAsync({tweetId:e,text:t.trim()}).catch(()=>{})}let _=d.error;return{meta:s,items:f,loading:d.isPending,error:_?_ instanceof Error?_.message:n:null,replyError:p.error?p.error instanceof Error?p.error.message:`Reply failed`:null,retry:m,refreshLocalView:h,replyToTweet:g,selectedAccountId:c,hasMore:d.hasNextPage,loadingMore:d.isFetchingNextPage,loadMore:()=>d.fetchNextPage().then(()=>void 0)}}export{xt as a,bt as i,yt as n,vt as o,St as r,Et as t};
@@ -1,5 +1,5 @@
1
1
  import { q as errorCopyClass } from "./ui-qbmcMSSX.js";
2
- import { a as useNdjsonRun, o as MarkdownViewer, r as profileAnalysisStreamEventSchema, t as isTerminalStreamEvent } from "./client-stream-contracts-C2xbWVjm.js";
2
+ import { a as useNdjsonRun, o as MarkdownViewer, r as profileAnalysisStreamEventSchema, t as isTerminalStreamEvent } from "./client-stream-contracts-Bq6kMmhh.js";
3
3
  import { n as normalizeProfileHydrationHandle, t as hydrateProfileHandles } from "./profile-hydration-client-GJ4kwJS8.js";
4
4
  import { useCallback, useState } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -132,16 +132,15 @@ function normalizeTweetUrlEntityRangeForText(text, entry) {
132
132
  function enrichFallbackUrlEntities(text, entities, resolveExpansion) {
133
133
  const enrichedExistingUrls = (entities.urls ?? []).map((entry) => {
134
134
  const expansion = resolveExpansion?.(entry.url);
135
- if (!expansion) return entry;
136
- const expandedUrl = expansion.expandedUrl || entry.expandedUrl;
135
+ const expandedUrl = expansion?.expandedUrl || entry.expandedUrl || entry.url;
137
136
  return {
138
137
  ...entry,
139
138
  expandedUrl,
140
- displayUrl: expansion.displayUrl || displayUrlForLink(expandedUrl),
141
- ...expansion.title ? { title: expansion.title } : {},
139
+ displayUrl: expansion?.displayUrl || entry.displayUrl || displayUrlForLink(expandedUrl),
140
+ ...expansion?.title ? { title: expansion.title } : {},
142
141
  ...expansion && "description" in expansion ? { description: expansion.description ?? null } : {},
143
- ...expansion.imageUrl ? { imageUrl: expansion.imageUrl } : {},
144
- ...expansion.siteName ? { siteName: expansion.siteName } : {}
142
+ ...expansion?.imageUrl ? { imageUrl: expansion.imageUrl } : {},
143
+ ...expansion?.siteName ? { siteName: expansion.siteName } : {}
145
144
  };
146
145
  });
147
146
  const fallbackUrls = [];
@@ -1,5 +1,5 @@
1
1
  import { t as SyncNowButton } from "./SyncNowButton-BOn_IBXS.js";
2
- import { a as TimelineSearchField, i as TimelineHeaderSubtitle, n as TimelineFeedHeader, o as TimelineCard, r as TimelineFeedShell, t as useTimelineRouteData } from "./useTimelineRouteData-27cxynxa.js";
2
+ import { a as TimelineSearchField, i as TimelineHeaderSubtitle, n as TimelineFeedHeader, o as TimelineCard, r as TimelineFeedShell, t as useTimelineRouteData } from "./useTimelineRouteData-BLXvMGb2.js";
3
3
  import { useMemo, useState } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/components/SavedTimelineView.tsx
@@ -1,6 +1,6 @@
1
1
  import { cn as tabButtonClass, ln as tabButtonIndicatorClass, m as cx, pn as timestampClass, un as tabStripClass } from "./ui-qbmcMSSX.js";
2
2
  import { t as SyncNowButton } from "./SyncNowButton-BOn_IBXS.js";
3
- import { a as TimelineSearchField, i as TimelineHeaderSubtitle, n as TimelineFeedHeader, o as TimelineCard, r as TimelineFeedShell, t as useTimelineRouteData } from "./useTimelineRouteData-27cxynxa.js";
3
+ import { a as TimelineSearchField, i as TimelineHeaderSubtitle, n as TimelineFeedHeader, o as TimelineCard, r as TimelineFeedShell, t as useTimelineRouteData } from "./useTimelineRouteData-BLXvMGb2.js";
4
4
  import { useMemo, useState } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/TimelineRouteFrame.tsx
@@ -1,5 +1,5 @@
1
1
  import { hn as tweetLinkClass, mn as tweetHashtagClass, s as bodyCopyClass, vn as tweetMentionClass } from "./ui-qbmcMSSX.js";
2
- import { c as collectTweetSegmentsForText, d as isTweetArticleUrlEntity, f as normalizeTweetUrlEntityRangeForText, s as safeHttpUrl, t as ProfilePreview, u as enrichFallbackUrlEntities } from "./ProfilePreview-C6gAor_j.js";
2
+ import { c as collectTweetSegmentsForText, d as isTweetArticleUrlEntity, f as normalizeTweetUrlEntityRangeForText, s as safeHttpUrl, t as ProfilePreview, u as enrichFallbackUrlEntities } from "./ProfilePreview-Cg-AOHBE.js";
3
3
  import { Fragment } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/components/TweetRichText.tsx
@@ -38,72 +38,72 @@ var tsrStartManifest = () => ({ routes: {
38
38
  ],
39
39
  css: ["/assets/index-bpFrQ5yG.css"],
40
40
  preloads: [
41
- "/assets/index-CEIG7S6s.js",
41
+ "/assets/index-DZVisyna.js",
42
42
  "/assets/chunk-C0phanGV.js",
43
43
  "/assets/query-client-fYu2rzRC.js",
44
44
  "/assets/createLucideIcon-JV8isFFR.js",
45
45
  "/assets/circle-check-C_Vq3ElD.js",
46
- "/assets/client-stream-contracts-ys3XhWG4.js",
46
+ "/assets/client-stream-contracts-sR4xMQxY.js",
47
47
  "/assets/sparkles-CQVlvHsZ.js",
48
48
  "/assets/react-dom-DHl6Ug7F.js",
49
49
  "/assets/schemas-I9r6F6ya.js",
50
50
  "/assets/react-nBylq1U5.js",
51
51
  "/assets/AvatarChip-DLoqM5xD.js",
52
- "/assets/ProfilePreview-BejAuYsJ.js",
52
+ "/assets/ProfilePreview-DQX6_xc3.js",
53
53
  "/assets/SmartTimestamp-BR0-9se2.js",
54
54
  "/assets/profile-hydration-client-YEtJsNTv.js"
55
55
  ],
56
56
  scripts: [{ attrs: {
57
57
  type: "module",
58
58
  async: !0,
59
- src: "/assets/index-CEIG7S6s.js"
59
+ src: "/assets/index-DZVisyna.js"
60
60
  } }]
61
61
  },
62
62
  "/": {
63
63
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/index.tsx",
64
64
  children: void 0,
65
- preloads: ["/assets/routes-q7ZaW4En.js", "/assets/TimelineRouteFrame-CyGPj0eM.js"]
65
+ preloads: ["/assets/routes-CiLuYpZr.js", "/assets/TimelineRouteFrame-9NDLnXzH.js"]
66
66
  },
67
67
  "/blocks": {
68
68
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/blocks.tsx",
69
69
  children: void 0,
70
- preloads: ["/assets/blocks-7UDKQp8H.js"]
70
+ preloads: ["/assets/blocks-CFp_njvG.js"]
71
71
  },
72
72
  "/bookmarks": {
73
73
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/bookmarks.tsx",
74
74
  children: void 0,
75
- preloads: ["/assets/bookmarks-CbBkMvXk.js", "/assets/SavedTimelineView-BIS7HKpp.js"]
75
+ preloads: ["/assets/bookmarks-LbYOsoKf.js", "/assets/SavedTimelineView-BhSiVyR1.js"]
76
76
  },
77
77
  "/data-sources": {
78
78
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/data-sources.tsx",
79
79
  children: void 0,
80
- preloads: ["/assets/data-sources-Cm2bpNvg.js", "/assets/triangle-alert-CBL7s2pf.js"]
80
+ preloads: ["/assets/data-sources-euTr6T_L.js", "/assets/triangle-alert-CBL7s2pf.js"]
81
81
  },
82
82
  "/discuss": {
83
83
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/discuss.tsx",
84
84
  children: void 0,
85
- preloads: ["/assets/discuss-DTjaOugw.js", "/assets/search-Dq5kYsxA.js"]
85
+ preloads: ["/assets/discuss-BWKu_p7B.js", "/assets/search-Dq5kYsxA.js"]
86
86
  },
87
87
  "/dms": {
88
88
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/dms.tsx",
89
89
  children: void 0,
90
- preloads: ["/assets/dms-CGd6Eogq.js", "/assets/search-Dq5kYsxA.js"]
90
+ preloads: ["/assets/dms-SLXMtC4v.js", "/assets/search-Dq5kYsxA.js"]
91
91
  },
92
92
  "/inbox": {
93
93
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/inbox.tsx",
94
94
  children: void 0,
95
- preloads: ["/assets/inbox-BHlGuOy2.js"]
95
+ preloads: ["/assets/inbox-BybSI5Vf.js"]
96
96
  },
97
97
  "/likes": {
98
98
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/likes.tsx",
99
99
  children: void 0,
100
- preloads: ["/assets/likes-cLrcAQem.js", "/assets/SavedTimelineView-BIS7HKpp.js"]
100
+ preloads: ["/assets/likes-dyh9p8y_.js", "/assets/SavedTimelineView-BhSiVyR1.js"]
101
101
  },
102
102
  "/links": {
103
103
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/links.tsx",
104
104
  children: void 0,
105
105
  preloads: [
106
- "/assets/links-CM9QO1LC.js",
106
+ "/assets/links-CIwqK_dX.js",
107
107
  "/assets/repeat-2-xCwHM9hD.js",
108
108
  "/assets/search-Dq5kYsxA.js",
109
109
  "/assets/users-CHbKlqUr.js"
@@ -112,13 +112,13 @@ var tsrStartManifest = () => ({ routes: {
112
112
  "/mentions": {
113
113
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/mentions.tsx",
114
114
  children: void 0,
115
- preloads: ["/assets/mentions-CxKCgzIf.js", "/assets/TimelineRouteFrame-CyGPj0eM.js"]
115
+ preloads: ["/assets/mentions-BoVVAIT7.js", "/assets/TimelineRouteFrame-9NDLnXzH.js"]
116
116
  },
117
117
  "/network-map": {
118
118
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/network-map.tsx",
119
119
  children: void 0,
120
120
  preloads: [
121
- "/assets/network-map-B5a3whqj.js",
121
+ "/assets/network-map-zRysIY_b.js",
122
122
  "/assets/search-Dq5kYsxA.js",
123
123
  "/assets/users-CHbKlqUr.js"
124
124
  ]
@@ -126,22 +126,22 @@ var tsrStartManifest = () => ({ routes: {
126
126
  "/profile-analyze": {
127
127
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/profile-analyze.tsx",
128
128
  children: void 0,
129
- preloads: ["/assets/profile-analyze-CRtNEwlb.js", "/assets/search-Dq5kYsxA.js"]
129
+ preloads: ["/assets/profile-analyze-C_yDeX6-.js", "/assets/search-Dq5kYsxA.js"]
130
130
  },
131
131
  "/rate-limits": {
132
132
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/rate-limits.tsx",
133
133
  children: void 0,
134
- preloads: ["/assets/rate-limits-ScaEwdVK.js", "/assets/triangle-alert-CBL7s2pf.js"]
134
+ preloads: ["/assets/rate-limits-BWPmPOSh.js", "/assets/triangle-alert-CBL7s2pf.js"]
135
135
  },
136
136
  "/today": {
137
137
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/today.tsx",
138
138
  children: void 0,
139
- preloads: ["/assets/today-CeG1O7Py.js"]
139
+ preloads: ["/assets/today-BoO64YoY.js"]
140
140
  },
141
141
  "/profiles/$handle": {
142
142
  filePath: "/Users/steipete/Projects/birdclaw/src/routes/profiles.$handle.tsx",
143
143
  children: void 0,
144
- preloads: ["/assets/profiles._handle-C82_HoKX.js"]
144
+ preloads: ["/assets/profiles._handle-DdIVPqU-.js"]
145
145
  }
146
146
  } });
147
147
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as SavedTimelineView } from "./SavedTimelineView-BG1jnBp1.js";
1
+ import { t as SavedTimelineView } from "./SavedTimelineView-BtCq1dHk.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  //#region src/routes/bookmarks.tsx?tsr-split=component
4
4
  function BookmarksRoute() {
@@ -1,6 +1,6 @@
1
1
  import { hn as tweetLinkClass, m as cx, vn as tweetMentionClass } from "./ui-qbmcMSSX.js";
2
2
  import { r as formatCompactNumber, t as AvatarChip } from "./AvatarChip-zUDAEmjL.js";
3
- import { m as renderTweetPlainText, n as useFloatingPreview, r as useAvatarPreload, s as safeHttpUrl, t as ProfilePreview } from "./ProfilePreview-C6gAor_j.js";
3
+ import { m as renderTweetPlainText, n as useFloatingPreview, r as useAvatarPreload, s as safeHttpUrl, t as ProfilePreview } from "./ProfilePreview-Cg-AOHBE.js";
4
4
  import { t as SmartTimestamp } from "./SmartTimestamp-DfwE1NGf.js";
5
5
  import { Fragment, useCallback, useEffect, useRef, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
1
  import { Dt as pageSubtitleClass, Et as pageHeaderRowClass, Ht as searchFieldInputClass, Jt as selectFieldClass, Mt as primaryButtonClass, Ot as pageTitleClass, Tt as pageHeaderClass, Ut as searchFieldShellClass, Vt as searchFieldIconClass, Wt as secondaryButtonClass, dn as textFieldClass, m as cx, q as errorCopyClass, wt as pageHeaderActionsClass } from "./ui-qbmcMSSX.js";
2
- import { a as useNdjsonRun, i as searchDiscussionStreamEventSchema, o as MarkdownViewer, t as isTerminalStreamEvent } from "./client-stream-contracts-C2xbWVjm.js";
2
+ import { a as useNdjsonRun, i as searchDiscussionStreamEventSchema, o as MarkdownViewer, t as isTerminalStreamEvent } from "./client-stream-contracts-Bq6kMmhh.js";
3
3
  import { n as validateDiscussSearch } from "./route-search-BUlQ5lGM.js";
4
- import { t as Route$1 } from "./discuss-CJ1dau1j.js";
4
+ import { t as Route$1 } from "./discuss-DAq6ehL9.js";
5
5
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { CheckCircle2, ChevronDown, Loader2, RefreshCw, Search, Sparkles } from "lucide-react";
@@ -1,12 +1,12 @@
1
1
  import "./ui-qbmcMSSX.js";
2
- import "./client-stream-contracts-C2xbWVjm.js";
2
+ import "./client-stream-contracts-Bq6kMmhh.js";
3
3
  import { n as validateDiscussSearch } from "./route-search-BUlQ5lGM.js";
4
4
  import "react";
5
5
  import { createFileRoute, lazyRouteComponent } from "@tanstack/react-router";
6
6
  import "react/jsx-runtime";
7
7
  import "lucide-react";
8
8
  //#region src/routes/discuss.tsx
9
- var $$splitComponentImporter = () => import("./discuss-QTo08NCN.js");
9
+ var $$splitComponentImporter = () => import("./discuss-C1QMBBSk.js");
10
10
  var Route$1 = createFileRoute("/discuss")({
11
11
  component: lazyRouteComponent($$splitComponentImporter, "component"),
12
12
  validateSearch: validateDiscussSearch
@@ -1,4 +1,4 @@
1
- import { t as SavedTimelineView } from "./SavedTimelineView-BG1jnBp1.js";
1
+ import { t as SavedTimelineView } from "./SavedTimelineView-BtCq1dHk.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  //#region src/routes/likes.tsx?tsr-split=component
4
4
  function LikesRoute() {
@@ -1,10 +1,10 @@
1
1
  import { Dt as pageSubtitleClass, Et as pageHeaderRowClass, Ht as searchFieldInputClass, Kt as segmentClass, Ot as pageTitleClass, Tt as pageHeaderClass, Ut as searchFieldShellClass, Vt as searchFieldIconClass, Wt as secondaryButtonClass, m as cx, qt as segmentedClass } from "./ui-qbmcMSSX.js";
2
2
  import { r as formatCompactNumber, t as AvatarChip } from "./AvatarChip-zUDAEmjL.js";
3
3
  import { i as LinkSkeletonRows, n as FeedError, r as FeedLoading, t as FeedEmpty } from "./FeedState-ntW0Q2GB.js";
4
- import { t as ProfilePreview } from "./ProfilePreview-C6gAor_j.js";
4
+ import { t as ProfilePreview } from "./ProfilePreview-Cg-AOHBE.js";
5
5
  import { t as SmartTimestamp } from "./SmartTimestamp-DfwE1NGf.js";
6
6
  import { a as validateLinksSearch } from "./route-search-BUlQ5lGM.js";
7
- import { a as itemSubtitle, c as mentionCopy, d as ranges, f as youtubeThumbnailUrl, i as isSameProfile, l as mentionHref, n as useLinksController, o as itemTitle, r as commentCount, s as mediaImage, t as Route$1, u as pureShareCount } from "./links-DAhSjynu.js";
7
+ import { a as itemSubtitle, c as mentionCopy, d as ranges, f as youtubeThumbnailUrl, i as isSameProfile, l as mentionHref, n as useLinksController, o as itemTitle, r as commentCount, s as mediaImage, t as Route$1, u as pureShareCount } from "./links-dqXb35YM.js";
8
8
  import { useState } from "react";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { ChevronDown, ChevronUp, ExternalLink, MessageCircle, Play, Repeat2, Search, Users } from "lucide-react";