1import{f as ae,r as k,R as w,j as t}from"./vendor-wagmi-CRHMQcRy.js";import{$ as oe,fg as le,b8 as we,fI as B,gi as ie,Z as F,fK as z,f as A,as as G,gj as ke,gk as ce,eR as ue,e4 as Ee,au as Ne,av as Te,z as de,gl as Le,ak as H,B as pe,H as fe,fm as Se,gm as Ie,gn as Ae,go as Fe,gp as Pe,gq as Me,gr as Ue,gs as He,gt as We,dd as De,fX as Ge,gu as Oe,gv as qe,gw as Ve,gx as q,gy as ze,gz as _e,fU as Be,fT as Ke,fV as Qe,fO as Xe,gA as Z,gB as Y,gC as W,gD as ee,gE as V,gF as $e,gG as te,gH as Je,gI as Ze,gJ as Ye,gK as et,ba as tt,aw as st}from"./index-CjDX1y09.js";import{b as nt,a as rt}from"./buildStarterPackUsersKey-DAwWEQU2.js";import{E as se}from"./VideoAttachment-BbkmyXvM.js";import{I as at}from"./ImageLightboxModal-DA8GdrFc.js";const ot=({apiClient:e,id:n})=>async()=>(await e.getStarterPack({id:n})).data.result,lt=()=>{const e=ae(),{apiClient:n}=oe(),s=le();return k.useCallback(({id:l})=>{const u=nt({id:l});if(!s({queryKey:u}))return e.prefetchQuery({queryKey:u,queryFn:ot({apiClient:n,id:l})})},[s,e,n])},it=({id:e,apiClient:n})=>we(async({pageParam:s})=>(await n.getStarterPackUsers({cursor:s,id:e,limit:15})).data),ct=()=>{const e=ae(),{apiClient:n}=oe(),s=le();return k.useCallback(({id:l})=>{const u=rt({id:l});if(!s({queryKey:u}))return e.prefetchInfiniteQuery({initialPageParam:void 0,queryKey:u,queryFn:it({apiClient:n,id:l})})},[s,e,n])},he=w.memo(({medias:e,height:n,width:s,maxWidth:l,ignoreAspectRatio:u,carouselIndex:h,noShrink:a,snapContext:o=!1})=>{const d=B(),{open:c}=bt(),j=w.useMemo(()=>ie({medias:e,pixelDensity:3,blockAnimated:!1,increasedWidth:!0}),[e]),g=o&&a&&u;return t.jsx(t.Fragment,{children:j.map((i,m)=>o?t.jsx(F,{className:A("relative max-w-full rounded-[12px] border object-cover bg-elevated border-default",g||a?"shrink-0 object-center":"min-w-0 object-left"),style:{maxHeight:n,height:n,width:s,maxWidth:g?s:l,aspectRatio:g?void 0:i.aspectRatio},src:i.thumbnail,draggable:!1,alt:"Cast image embed",loading:"lazy",onClick:p=>{d({type:z.Image}),p.stopPropagation(),c?.({initialIndex:h||0})},onMouseOver:()=>{const p=new Image;p.src=i.original}},m):t.jsx(F,{className:"relative max-w-full rounded-[12px] border object-cover object-left bg-elevated border-default",style:{maxHeight:n,height:u?n:void 0,width:s,maxWidth:l,aspectRatio:i.aspectRatio},src:i.thumbnail,draggable:!1,alt:"Cast image embed",loading:"lazy",onClick:p=>{d({type:z.Image}),p.stopPropagation(),c?.({initialIndex:h||0})},onMouseOver:()=>{const p=new Image;p.src=i.original}},m))})});he.displayName="ImageAttachmentGroup";const _=({images:e,height:n,width:s,maxWidth:l,ignoreAspectRatio:u,carouselIndex:h,noShrink:a,snapContext:o=!1})=>{const d=w.useMemo(()=>{if(e.length===0)return t.jsx(t.Fragment,{});const c=e.map(j=>typeof j.media<"u"?j.media:{version:"2",staticRaster:j.url,height:1e3,width:1e3});return t.jsx(he,{medias:c,height:n,width:s,maxWidth:l,ignoreAspectRatio:u,carouselIndex:h,noShrink:a,snapContext:o})},[h,n,u,e,l,a,o,s]);return t.jsx(t.Fragment,{children:d})};_.displayName="ImageAttachments";const ut=({og:e})=>t.jsxs("div",{className:"relative flex w-full flex-row items-center rounded-lg",children:[t.jsx(F,{alt:"App image",className:"h-24 w-[88px] min-w-[88px] rounded-l-lg border border-faint",src:e.image||G}),t.jsxs("div",{className:"flex h-24 flex-1 flex-col justify-center rounded-lg rounded-l-none border border-l-0 p-2 border-faint",children:[t.jsx("div",{className:"flex flex-row space-x-1",children:t.jsx("span",{className:"text-sm font-semibold text-default",children:e.title})}),t.jsx("span",{className:"text-sm text-faint",children:e.description})]})]}),dt=({og:e,disabled:n,variant:s})=>{const l=ke(),u=w.useCallback(()=>{},[]),h=w.useMemo(()=>{const o=ce(ue.channel.path,new URL(e.url).pathname);if(!(!o||!o.params.channelKey))return o.params},[e.url]),a=w.useCallback(()=>{typeof h>"u"||l({feedKey:h.channelKey,feedType:"default",updateState:!1,onNullFeedItemsResponse:u})},[h,l,u]);return t.jsxs("div",{className:"relative flex w-full flex-row items-center rounded-lg",onMouseOver:a,children:[typeof h<"u"&&!n&&t.jsx(Ee,{className:"absolute inset-0",channelKe
1y:h.channelKey,title:e.title}),t.jsx(F,{alt:"Channel image",className:"h-24 w-[88px] min-w-[88px] rounded-l-lg border border-faint",src:e.image||G}),t.jsxs("div",{className:"flex h-24 flex-1 flex-col justify-center rounded-lg rounded-l-none border border-l-0 p-2 border-faint",children:[t.jsxs("div",{className:"flex flex-row space-x-1",children:[t.jsxs("span",{className:A("line-clamp-1 text-sm font-semibold break-gracefully text-default"),children:[e.title,typeof e.channel<"u"&&t.jsxs("span",{className:A("ml-1 text-sm font-normal",s==="direct-cast"?"text-direct-casts-link":"text-faint"),children:["· /",e.channel.key]})]}),t.jsxs("div",{className:A("flex flex-row items-center text-xs leading-[20px] text-faint"),children:[t.jsx(Ne,{size:10}),t.jsx("span",{className:"ml-0.5",children:Te(e.channel?.followerCount||0)})]})]}),t.jsx("span",{className:A("line-clamp-3 text-sm break-gracefully",s==="direct-cast"?"text-default":"text-faint"),children:e.description})]})]})},me=k.memo(({...e})=>t.jsx(de,{to:"channels",params:{},searchParams:{},...e}));me.displayName="LinkToChannels";const xe=({og:e})=>t.jsxs("div",{className:"flex w-full flex-col rounded-lg border p-3 pt-2 border-faint",children:[t.jsx(me,{className:"absolute inset-0",title:e.title}),t.jsxs("div",{className:"flex flex-row items-center",children:[t.jsx(F,{alt:"og",className:"mr-1 size-5 rounded-md",src:Le({assetName:"Farcaster",assetExtension:"webp"})}),t.jsx("div",{className:"max-w-sm truncate text-sm",children:e.title})]}),t.jsx("div",{className:"mt-1 text-sm break-gracefully text-faint",children:e.description})]});xe.displayName="ExploreChannelsAttachment";const pt=({og:e,disabled:n})=>t.jsxs("div",{className:"relative flex w-full flex-col items-center rounded-lg border border-default",children:[!n&&t.jsx(H,{className:"absolute inset-0 subtle-hover-z",href:e.url,title:e.url}),t.jsx(F,{alt:"Starter pack",className:"max-h-[300px] w-full rounded-t-lg object-cover object-left-top",src:e.image||G,style:{aspectRatio:1.91}}),t.jsxs("div",{className:"flex w-full flex-col rounded-b-lg border-t p-2 text-sm bg-app border-default text-default",children:[t.jsx("div",{className:"font-semibold",children:e.title}),t.jsx("div",{className:"text-faint",children:e.description})]})]}),ge=k.memo(e=>{const n=lt(),s=ct(),l=k.useCallback(()=>{n({id:e.params.id}),s({id:e.params.id})},[n,s,e.params.id]);return t.jsx(de,{to:"starterPackWithUsername",onMouseOver:l,...e})});ge.displayName="LinkToStarterPack";const ft=({og:e,disabled:n})=>{const{trackEvent:s}=pe(),l=w.useMemo(()=>{const u=ce(ue.starterPackWithUsername.path,new URL(e.url).pathname);if(!(!u||!u.params.id||!u.params.username))return u.params},[e.url]);return t.jsxs("div",{className:"relative flex w-full flex-col items-center rounded-lg border border-default",children:[!n&&(typeof l<"u"?t.jsx(ge,{className:"absolute inset-0 subtle-hover-z",title:`Starter Pack / ${e.title}`,params:l,searchParams:{}}):t.jsx(H,{className:"absolute inset-0 subtle-hover-z",href:e.url,title:e.url,onClick:()=>{s(fe.PressStarterPackOnFeed,{starterPackName:e.title||""})}})),t.jsx(F,{alt:"Starter pack",className:"max-h-[300px] w-full rounded-t-lg object-cover object-left-top",src:e.image||G,style:{aspectRatio:1.91}}),t.jsxs("div",{className:"flex w-full flex-col rounded-b-lg border-t p-2 text-sm bg-app border-default text-default",children:[t.jsx("div",{className:"font-semibold",children:e.title}),t.jsx("div",{className:"text-faint",children:e.description})]})]})},ht=({og:e,disabled:n})=>t.jsxs("div",{className:"relative flex w-full flex-row items-center rounded-lg border border-faint",children:[!n&&t.jsx(H,{className:"absolute inset-0 subtle-hover-z",href:e.url,title:e.url}),t.jsx("div",{className:"dark:bg-dark-app-background flex size-[48px] items-center justify-center rounded-l-lg border-r bg-[#efefef] object-cover border-faint",children:t.jsx(Se,{size:32})}),t.jsx("div",{className:"ml-4 flex flex-1 flex-col justify-center rounded-lg rounded-l-none",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm font-semibold text-default",children:e.description}),e.description!=="Manage your account preferences"&&t.jsx("span",{className:"font-regular text-span text-sm",children:"Update your Farcaster settings"})]})})]}),mt=({embed:e,attachment:n,imageProps:s,setDidImageFailToLoad:l,title:u,type:h,disabled:a,skipWrapperStyles:o=!1,variant:d="default"})=>k.useMemo(()=>{switch(h){case"explore-channels":return t.jsx(xe,{og:n});case"news":return t.jsx(Fe,{og:n,disabled:a});case"channel-attachment":return t.jsx(dt,{og:n,disabled:a,variant:d});case"app-attachment":return t.jsx(ut,{og:n,disabled:a});case"warpcast-settings":return t.jsx(ht,{og:n,disabled:a});case"starter-pack":return t.jsx(ft,{og:n,disabled:a});case"rich-warpcast-attachment":return t.jsx(pt,{og:n,disabled:a});case"quote-tweet":return t.jsx(Ae,{embed:e,url:n.url,title:n.title||"",tweet:n.description||"",skipWrapperStyles:o});case"contract-address":return null;case"token":return typeof e.tokenV2>"u"?null:t.jsx(Ie,{token:e.tokenV2,disabled:a,location:"feed"});case"url":default:return t.jsxs(t.Fragment,{children:[s.src&&t.jsx(F,{alt:n.title||"OpenGra
1ph image",className:A("bg-[#efefef] object-cover dark:bg-[#101010]","aspect-opengraph w-full rounded-t-[12px]"),...s,onError:()=>l(!0)}),t.jsxs("div",{className:A("flex w-full flex-col justify-center overflow-hidden rounded-b-[12px] border-t p-2 border-default"),children:[t.jsx("div",{className:"text-xs text-muted",children:n.domain}),t.jsx("div",{className:"line-clamp-2 font-semibold",children:u})]})]})}},[n,a,e,s,l,o,u,h,d]),ye=({cast:e,embed:n,attachment:s,disabled:l=!1,skipWrapperStyles:u=!1,variant:h="default"})=>{const[a,o]=w.useState(!1),d=Pe({urlEmbed:n}),c=Me({attachment:s}),j=B(),{imageProps:g}=Ue({attachment:s,didImageFailToLoad:a}),i=mt({embed:n,attachment:s,imageProps:g,setDidImageFailToLoad:o,title:c,type:d,disabled:l,skipWrapperStyles:u,variant:h}),m=w.useMemo(()=>He({attachment:s}),[s]);return w.useLayoutEffect(()=>{if(o(!1),!m)return;const p=new Image;let y=!0;return p.onerror=()=>{y&&o(!0)},p.src=m,()=>{y=!1,p.onerror=null}},[m]),l?t.jsx("div",{className:A("relative mt-2 flex cursor-default rounded-lg text-sm text-inherit bg-app",a?d==="url"?"w-full flex-row border p-2 border-default":"w-full flex-row":"w-full flex-col"),children:i}):d==="channel-attachment"||d==="explore-channels"||d==="app-attachment"||d==="warpcast-settings"||d==="starter-pack"||d==="contract-address"||d==="rich-warpcast-attachment"||d==="quote-tweet"||d==="token"||d==="news"?t.jsxs("div",{className:"relative",children:[!l&&d!=="token"&&d!=="news"&&t.jsx(H,{className:"absolute inset-0 subtle-hover-z",href:s.url,title:s.url,onClick:()=>{j({type:z.ExtLink})}}),i]}):typeof s.frame<"u"&&typeof s.domain<"u"&&typeof s.frameEmbedNext>"u"?t.jsx(We,{}):null};ye.displayName="RichOpenGraphCastAttachment";const be=w.memo(({source:e})=>{const{trackEvent:n}=pe(),s=w.useCallback(()=>{n(fe.VisitingExternalURL,{source:e})},[e,n]);return t.jsxs("div",{className:"flex flex-row items-center justify-between space-x-2 rounded-lg border p-2 text-sm text-muted border-default",children:[t.jsx("div",{className:"flex flex-row items-center",children:t.jsx("div",{className:"text-sm",children:"No preview found for shared link"})}),t.jsxs(H,{className:"flex cursor-pointer flex-row items-center text-sm text-link hover:underline",href:e,title:"View source",onClick:s,children:[t.jsx(De,{size:10,className:"mr-1"}),"View source"]})]})});be.displayName="UnsupportedEmbed";const D=({hasReplies:e,isFocused:n,isReplyingToFocusedCast:s,isReplyingToDisconnectedCast:l,isReplyingToContinuousCast:u,isReplyingToEmbed:h})=>n?u&&!h?"end_continuous":"start_and_end":s?e?"start":"start_and_end":u?e?h?"start":"middle_continuous":"end_continuous":l?"end_disconnected":e?"start":"start_and_end",kt=(e,{focusedCastHash:n,forceThreadPosition:s,showPinnedAsAnnouncement:l,showChannelTag:u=!0,isHighlighted:h=!1}={})=>{const a=[],o=e.filter(c=>!Ge(c.cast));o.forEach(({cast:c,replies:j,meta:g,timestamp:i,pinned:m},p)=>{const y=p===0,x=n?c.hash.includes(n):!1,b=a[a.length-1],R=p<o.length-1?o[p+1].cast:void 0,C=j||c.replies.casts||[],f=C.length?C[C.length-1]:void 0,N=!!(f||R?.parentHash===c.hash),T=!!(f&&f.parentHash!==c.hash)?{cast:c}:void 0,E=!!(c.parentHash&&b&&b.cast.hash===c.parentHash&&!b.context.showMore),P=!1,I=!!b?.context.isFocused,M=c.replies.count!==0||c.recasts.count!==0||c.reactions.count!==0||typeof c.quoteCount<"u"&&c.quoteCount!==0||(c.warpsTipped??0)!==0,r=typeof c.recasts.recasters<"u"&&c.recasts.recasters.length!==0,v=c.parentSource?.type==="url",U=typeof u=="boolean"?u:typeof u=="function"?u(c):!0;if(a.push({cast:c,context:{index:p,hasVisibleReplies:N,isFirstInList:y,isLastInList:!1,isFocused:x,isReplyingToDisconnectedCast:P,isReplyingToContinuousCast:E,isReplyingToFocusedCast:I,forceShowReplyingTo:!1,truncateCastText:!0,showMore:T,threadPosition:s||D({hasReplies:N,isFocused:x,isReplyingToFocusedCast:I,isReplyingToDisconnectedCast:P,isReplyingToContinuousCast:E,isReplyingToEmbed:v}),includeDetails:M,shouldShowRecastLabel:r,isReplyingToEmbed:v,shouldShowChannelTag:U,includeReason:g?.includeReason,labelReason:g?.labelReason,itemTimestamp:i,isPinned:m,showPinnedAsAnnouncement:l,isHighlighted:h,score:g?.score,topHat:g?.to
1pHat}}),f){const K=f.hash===n,O=!!T,Q=f.parentHash===c.hash&&!O,X=x,$=!1,Re=!1,J=f.parentSource?.type==="url";a.push({cast:f,context:{index:p,hasVisibleReplies:$,isFirstInList:Re,isLastInList:!1,isFocused:K,isReplyingToDisconnectedCast:O,isReplyingToContinuousCast:Q,isReplyingToFocusedCast:X,forceShowReplyingTo:!1,showMore:void 0,truncateCastText:!0,threadPosition:s||D({hasReplies:$,isFocused:K,isReplyingToFocusedCast:X,isReplyingToDisconnectedCast:O,isReplyingToContinuousCast:Q,isReplyingToEmbed:J}),includeDetails:M,shouldShowRecastLabel:!1,isReplyingToEmbed:J,shouldShowChannelTag:!1,includeReason:g?.includeReason,itemTimestamp:i,score:g?.score}})}});const d=a[a.length-1];return d&&(d.context.isLastInList=!0),a},Et=({focusedCastHash:e,casts:n,onShowMorePress:s,castHashesWithNoMoreReplies:l,hasHiddenReplies:u,hiddenRepliesVisible:h,numMainCasts:a,channelDisallowed:o})=>{const d=[],c=n.findIndex(i=>e&&i.hash.includes(e)),j=c!==-1?c:void 0,g=Be(n);if(n.forEach((i,m)=>{const p=m===0||h&&m===a,y=e?i.hash.includes(e):!1,x=d[d.length-1],b=m<n.length-1?n[m+1]:void 0,R=i.replies.casts||[],C=Ke({cast:i,directReplyHashesByParentHash:g}),f=Qe({cast:i,loadedDirectReplyHashes:C}),L=!!((R.length?R[R.length-1]:void 0)||b?.parentHash===i.hash),S=!!(x&&i.parentHash&&x.cast.hash===i.parentHash&&!x.context.isFocused||i.parentSource?.type==="url"&&i.channel),E=f>0&&l?.includes(i.hash)!==!0?{cast:i,onPress:s?()=>s({parentCastHash:i.hash,excludeReplyHashes:C}):void 0}:void 0,P=!1,I=j!==void 0&&m>=j,M=i.recasts.count!==0||i.reactions.count!==0||typeof i.quoteCount<"u"&&i.quoteCount!==0||(i.warpsTipped??0)!==0,r=!1,v=i.parentSource?.type==="url";d.push({cast:i,context:{hasVisibleReplies:L,isFirstInList:p,isLastInList:!1,isFocused:y,isReplyingToDisconnectedCast:P,isReplyingToContinuousCast:S,isReplyingToFocusedCast:I,forceShowReplyingTo:!1,truncateCastText:!1,showMore:E,threadPosition:D({hasReplies:L,isFocused:y,isReplyingToFocusedCast:I,isReplyingToDisconnectedCast:P,isReplyingToContinuousCast:S,isReplyingToEmbed:v}),includeDetails:M,shouldShowRecastLabel:r,isReplyingToEmbed:v,shouldShowChannelTag:!1,channelDisallowed:o,showMemberBadge:!0}}),d.push(...ve({cast:i,castHashesWithNoMoreReplies:l,onShowMorePress:s,convReplyLevel:0,parentIsLast:!0}))}),!u||h&&n.length>a){const i=d[d.length-1];i&&(i.context.isLastInList=!0)}return d};function ve({cast:e,castHashesWithNoMoreReplies:n,onShowMorePress:s,convReplyLevel:l,parentIsLast:u}){const h=[],a=e.replies.casts||[];return a.forEach((o,d)=>{const c=a.length-1===d,j=!c,g=a.find(f=>f.hash!==o.hash&&f.parentHash===o.hash),i=o.replies.casts?.length??0,m=l===0&&!g&&o.replies.count>i&&n?.includes(o.hash)!==!0,p=o.replies.casts,y=m,x=m?{cast:o,onPress:s?()=>s({parentCastHash:o.hash,excludeReplyHashes:p?.map(f=>f.hash)}):void 0}:void 0,b=o.parentSource?.type==="url";let R=[];(o.replies.casts?.length??!1)&&(R=ve({cast:o,castHashesWithNoMoreReplies:n,onShowMorePress:s,convReplyLevel:l+1,parentIsLast:u&&c}));const C=R.length>0;h.push({cast:o,context:{hasVisibleReplies:j,isFirstInList:!1,isLastInList:!1,isFocused:!1,isReplyingToDisconnectedCast:!1,isReplyingToContinuousCast:!0,isReplyingToFocusedCast:!1,forceShowReplyingTo:!1,truncateCastText:!1,showMore:x,threadPosition:D({hasReplies:!u||C||j||y,isFocused:!1,isReplyingToFocusedCast:!1,isReplyingToDisconnectedCast:!1,isReplyingToContinuousCast:!0,isReplyingToEmbed:b}),includeDetails:!1,shouldShowRecastLabel:!1,isReplyingToEmbed:b,shouldShowChannelTag:!1,showMemberBadge:!0}}),h.push(...R)}),h}function xt(e){if(!e.domain||!e.url||typeof e.frame<"u"&&typeof e.domain<"u"&&typeof e.frameEmbedNext>"u")return!1;if(q(e.domain,"twitter.com")||ze(e.domain,"x.com"))return!!e.description;if(!(q(e.domain,"warpcast.com")||q(e.domain,"farcaster.xyz")))return!1;try{return _e({urlEmbed:e})!=="url"}catch{return!1}}function gt({embeds:e,castText:n}){if(!e)return[];const s=[],l=Oe({quotes:e.casts??[]});for(const a of e.videos??[])s.push({type:"video",data:a});for(const a of e.images??[])s.push({type:"image",data:a});for(const a of e.casts??[])s.push({type:"quote",data:a});for(const a of e.groupInvites??[])s.push({type:"groupInvite",data:a});const u=e.urls.filter(a=>!qe({url:a.openGraph.url,sourceUrl:a.openGraph.sourceUrl,quoteCastUrls:l}));for(const a of u){const o=a.openGraph;xt(o)?s.push({type:"non-carousel-bunched-og",data:a}):s.push({type:"og",data:a})}const h=new Set((e.urls??[]).map(a=>a.openGraph?.snap?.url).filter(a=>
1typeof a=="string"));for(const a of e.snap??[])!a.url||h.has(a.url)||s.push({type:"og",data:Ve(a)});for(const a of e.unknowns??[]){const o=a.source;!n.includes(o)&&!(o.startsWith("https://")&&n.includes(o.slice(8)))&&!(o.startsWith("http://")&&n.includes(o.slice(7)))&&s.push({type:"unsupported",source:o})}return s}function Nt(){const e=k.useRef(null),n=k.useRef(!1),s=k.useRef(!1);return k.useEffect(()=>{const l=e.current;if(!l)return;const u=()=>{const i=l.scrollWidth>l.clientWidth;l.classList[i?"add":"remove"]("cursor-grab"),i?l.style.cursor="grab":l.style.cursor="pointer"};u();const h=new ResizeObserver(u);h.observe(l);let a=0,o=0;const d=5,c=i=>{i.button===0&&(n.current=!0,s.current=!1,l.classList.add("cursor-[grabbing]"),l.style.cursor="grabbing",a=i.clientX,o=l.scrollLeft,document.addEventListener("pointermove",j),document.addEventListener("pointerup",g))},j=i=>{if(!n.current)return;Math.abs(i.clientX-a)>d&&(s.current=!0,i.preventDefault(),l.scrollLeft=o-(i.clientX-a))},g=()=>{if(!n.current)return;n.current=!1,l.classList.remove("cursor-[grabbing]");const i=l.scrollWidth>l.clientWidth;if(l.style.cursor=i?"grab":"pointer",document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",g),s.current){const m=p=>{p.preventDefault(),p.stopImmediatePropagation(),document.removeEventListener("click",m,!0)};document.addEventListener("click",m,!0),setTimeout(()=>{document.removeEventListener("click",m,!0)},10)}s.current=!1};return l.addEventListener("pointerdown",c),()=>{l.removeEventListener("pointerdown",c),document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",g),h.disconnect()}},[]),{ref:e,draggingRef:n,draggedRef:s}}const yt=10,ne=({text:e,spaceUrl:n})=>{const s=e.trimEnd();return s.endsWith(n)?s.slice(0,-n.length).trimEnd():s},Ce=({cast:e,text:n,embeds:s,isFocusedCast:l,draggingRef:u,onMiniAppLaunch:h})=>{const a=Xe(),o=gt({castText:n,embeds:s}),d=w.useMemo(()=>o.filter(p=>p.type==="image"||p.type==="video"||p.type==="og"),[o]),c=w.useMemo(()=>s?d.length>1:!1,[d.length,s]),j=w.useMemo(()=>s?d.length>0:!1,[d.length,s]),g=w.useMemo(()=>s?o.filter(y=>y.type==="quote"||y.type==="non-carousel-bunched-og"||y.type==="groupInvite"||y.type==="unsupported").length>0:!1,[s,o]),i=k.useCallback(({embed:p,cast:y,width:x,height:b,spaceWidth:R})=>{const C=p.openGraph;return C&&C.frameEmbedNext&&C.frameEmbedNext.frameEmbed?t.jsx(Z,{cast:y,frameEmbed:C.frameEmbedNext,onLaunchMiniApp:h,height:b,width:x},C.url):Y(C.url)?t.jsx(W,{url:C.url,width:R??x},C.url):t.jsx(ee,{embed:p,attachment:C,height:b,width:x,snapContext:!1},C.url)},[h]),m=k.useCallback(({embed:p,cast:y,width:x,height:b,snapWidth:R,spaceWidth:C})=>{const f=p.openGraph;return f&&f.frameEmbedNext&&f.frameEmbedNext.frameEmbed?t.jsx(Z,{cast:y,frameEmbed:f.frameEmbedNext,onLaunchMiniApp:h,height:b,width:x},f.url):Y(f.url)?t.jsx(W,{url:f.url,width:C??x},f.url):V(p)?t.jsx($e,{embed:p,cast:y,width:R??x,height:b,onMiniAppLaunch:h,enableLiftOnInteraction:!0},f.url):t.jsx(ee,{embed:p,attachment:f,height:b,width:x,snapContext:!0},f.url)},[h]);return k.useMemo(()=>{let p=n.trimEnd(),y=null,x=null,b=!1;if(typeof s>"u"){const r=te(n);return typeof r<"u"&&(p=ne({text:n,spaceUrl:r}),y=t.jsx(W,{url:r}),b=!0),{bodyTextOverride:p,hasAttachments:b||j,hasNonCarouselAttachments:g,castAttachment:y,nonCarouselAttachments:x,needsCarousel:!1,carouselMaxHeight:void 0}}const R=d.findIndex(r=>r.type==="og")!==-1,C=Je({embeds:s,platform:"web",isFocused:l,renderingCarousel:c,carouselHasNonMedia:R}),{width:f,height:N,effectiveAR:L,carouselMaxHeight:S,mediaTileHeight:T}=C;if(o.filter(r=>r.type==="image").length!==0&&n.endsWith(o.filter(r=>r.type==="image")[0].data.sourceUrl)&&(p=n.replace(o.filter(r=>r.type==="image")[0].data.sourceUrl,"").trimEnd()),typeof s<"u"&&s.urls.length!==0&&(typeof s.processedCastText<"u"&&n===e.text?p=s.processedCastText:n.endsWith(s.urls[s.urls.length-1].openGraph.url)&&(p=n.replace(s.urls[s.urls.length-1].openGraph.url,"").trimEnd())),d.length===0){const r=te(n);typeof r<"u"&&(p=ne({text:p,spaceUrl:r}),y=t.jsx(W,{url:r}),b=!0)}const E=o.filter(r=>r.type==="image").map(({data:r})=>typeof r.media<"u"?r.media:{version:"2",staticRaster:r.url,height:1e3,width:1e3}),P=Date.now(),I=ie({medias:E,pixelDensity:3,blockAnimated:!1,useLowQualityImages:!1}),M=Date.now();return a.maybeAddFrameDroppingAction("farcaster-web.useCastBody.processMediasForRendering",M-P),b||(y=C.mode==="non-snap"?t.jsxs(t.Fragment,{children:[o.filter(r=>r.type==="video").map(({data:r},v)=>t.jsx(se,{url:r.url,videoWidth:r.width,videoHeight:r.height,thumbnailUrl:r.thumbnailUrl,mode:"cast",autoPlay:!0,maxHeight:N,maxWidth:f,renderWidth:v
1===0&&!c&&L!=="vertical-media"?f:void 0,renderHeight:N},v)),t.jsx(re,{draggingRef:u,imagesToRender:I,children:o.filter(r=>r.type==="image").map(({data:r},v)=>t.jsx(_,{images:[r],height:v===0&&!c&&L!=="vertical-media"?void 0:T??N,width:void 0,maxWidth:v===0&&o.filter(U=>U.type==="video").length===0?f:void 0,ignoreAspectRatio:R,carouselIndex:v,snapContext:!1},v))}),o.filter(r=>r.type==="og").map(({data:r})=>i({embed:r,height:c?N:void 0,width:c?void 0:f,spaceWidth:f,cast:e}))]}):t.jsxs(t.Fragment,{children:[o.filter(r=>r.type==="og").filter(r=>V(r.data)).map(({data:r})=>m({embed:r,height:c?N:void 0,width:c?void 0:f,snapWidth:f,spaceWidth:f,cast:e})),o.filter(r=>r.type==="video").map(({data:r},v)=>t.jsx(se,{url:r.url,videoWidth:r.width,videoHeight:r.height,thumbnailUrl:r.thumbnailUrl,mode:"cast",autoPlay:!0,maxHeight:N,maxWidth:f,renderWidth:v===0&&!c&&L!=="vertical-media"?f:void 0,renderHeight:N},v)),t.jsx(re,{draggingRef:u,imagesToRender:I,children:o.filter(r=>r.type==="image").map(({data:r},v)=>t.jsx(_,{images:[r],height:v===0&&!c&&L!=="vertical-media"?void 0:T??N,width:R?f:void 0,maxWidth:R||v===0&&o.filter(U=>U.type==="video").length===0?f:void 0,ignoreAspectRatio:R,carouselIndex:v,noShrink:c,snapContext:!0},v))}),o.filter(r=>r.type==="og").filter(r=>!V(r.data)).map(({data:r})=>m({embed:r,height:c?N:void 0,width:c?void 0:f,snapWidth:f,spaceWidth:f,cast:e}))]})),g&&(x=t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[o.filter(r=>r.type==="quote").map(({data:r},v)=>t.jsx("div",{className:"w-full",children:t.jsx(Ze,{cast:r})},v)),o.filter(r=>r.type==="non-carousel-bunched-og").map(({data:r},v)=>t.jsx(ye,{cast:e,attachment:r.openGraph,embed:r,disabled:!1},v)),o.filter(r=>r.type==="unsupported").map(({source:r},v)=>t.jsx(be,{source:r},v)),o.filter(r=>r.type==="groupInvite").map(({data:r})=>t.jsx("div",{children:t.jsx(Ye,{groupInvite:r})}))]})),{bodyTextOverride:p,hasAttachments:b||j,hasNonCarouselAttachments:g,castAttachment:y,nonCarouselAttachments:x,needsCarousel:c,carouselMaxHeight:S}},[d,e,u,s,j,g,l,c,i,m,o,n,a])},Tt=Ce,Lt=({cast:e,castText:n=e.text,isFocusedCast:s,truncateCastText:l,draggingRef:u,onMiniAppLaunch:h})=>{const a=et();B();const o=a({fid:e.author.fid,hash:e.hash}),d=e.embeds||o?.embeds,{bodyTextOverride:c,castAttachment:j,nonCarouselAttachments:g,hasNonCarouselAttachments:i,hasAttachments:m,needsCarousel:p,carouselMaxHeight:y}=Ce({cast:e,text:n,embeds:d,isFocusedCast:s,draggingRef:u,onMiniAppLaunch:h}),x=c,{regularCastByteLimit:b}=tt(),R=k.useMemo(()=>l&&!s&&x.length>b+yt,[x,s,b,l]),C=k.useMemo(()=>R?`${x.slice(0,b)}...`:x,[x,b,R]),f=k.useMemo(()=>{if(typeof e.embeds<"u"&&e.embeds.urls.length!==0){const S=e.embeds.urls.map(({token:E})=>E),T=[];for(const E of S)typeof E<"u"&&T.push(E.ca);return T}return[]},[e.embeds]),N=k.useMemo(()=>{if(typeof e.embeds<"u"&&e.embeds.urls.length!==0){const S=e.embeds.urls.map(({tokenV2:E})=>E),T=[];for(const E of S)typeof E<"u"&&T.push(E);return T}return[]},[e.embeds]),L=t.jsx(st,{content:C,mentions:e.mentions,channelMentions:e.channelMentions,tokenMentions:f,tokenMentionsV2:N,castAuthorFid:e.author.fid},"cast-text");return{nonLinkfiedText:c,text:L,isTruncatedCastText:R,castAttachment:j,nonCarouselAttachments:g,hasNonCarouselAttachments:i,hasAttachments:m,needsCarousel:p,carouselMaxHeight:y}},je=w.createContext({});function re({draggingRef:e,imagesToRender:n,children:s}){const[l,u]=w.useState(void 0),h=w.useCallback(({initialIndex:a})=>{e.current!==!0&&u(a)},[e]);return t.jsxs(je,{value:{open:h},children:[s,typeof l<"u"&&t.jsx(at,{title:"Image embeds on cast",imageUrls:n.map(({original:a})=>a),initialIndex:l,onClose:()=>{u(void 0)}})]})}const bt=()=>w.useContext(je);export{ot as a,kt as b,it as c,Et as d,Nt as e,Lt as f,Tt as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.