hive-react-kit 0.2.3 → 0.2.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.
package/dist/index.cjs.js CHANGED
@@ -1093,7 +1093,7 @@ and ensure you are accounting for this risk.
1093
1093
  text-sm sm:text-base px-3 py-2 sm:px-4 sm:py-3 shadow
1094
1094
  ${n===0||c?"bg-blue-300 text-white cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white"}`,children:c?t.jsxs(t.Fragment,{children:[t.jsx(z.Loader2,{className:"w-4 h-4 sm:w-5 sm:h-5 mr-1 animate-spin"}),"Voting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(z.ThumbsUp,{className:"w-4 h-4 sm:w-5 sm:h-5 mr-1"}),"Vote"]})}),t.jsxs("button",{onClick:r,disabled:c,className:`flex-1 flex items-center justify-center rounded-full font-semibold text-sm sm:text-base px-3 py-2 sm:px-4 sm:py-3 shadow
1095
1095
  bg-gray-300 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-white
1096
- disabled:opacity-50 disabled:cursor-not-allowed`,children:[t.jsx(z.X,{className:"w-4 h-4 sm:w-5 sm:h-5 mr-1"}),"Cancel"]})]})]})})}const bd=({comment:e,allComments:a,onReply:i,currentUser:s,token:r,searchQuery:n,depth:u=0,onVotedRefresh:c,onClickCommentUpvote:d,onClickCommentReply:f,onClickUpvoteButton:o})=>{const[h,l]=P.useState(!1),[p,x]=P.useState(!0),[w,b]=P.useState(!1),g=P.useMemo(()=>{const K=e.active_votes||[];if(!s)return!1;const te=s.toLowerCase();return K.some(pe=>(pe.voter||"").toLowerCase()===te)},[e.active_votes,s]),[v,_]=P.useState(!1),[N,y]=P.useState(""),[m,k]=P.useState(!1),j=K=>{y(K),_(!0),setTimeout(()=>_(!1),2500)},A=e.depth||0;let C=a.filter(K=>K.parent_author===e.author&&K.parent_permlink===e.permlink&&(typeof K.depth!="number"||K.depth===A+1));if((!C||C.length===0)&&Array.isArray(e.replies)&&e.replies.length>0){const K=new Set(e.replies);C=a.filter(te=>K.has(`${te.author}/${te.permlink}`))}const O=C.length>0,L=u>=4,H=(K,te)=>{if(!te)return K;const pe=new RegExp(`(${te})`,"gi");return K.replace(pe,'<mark class="bg-yellow-200 dark:bg-yellow-800">$1</mark>')},F=()=>{b(!0)},B=async K=>{if(d){try{await Promise.resolve(d(e.author,e.permlink,K)),l(!0),b(!1),setTimeout(()=>{c?.(),j("Vote submitted successfully!")},3e3)}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";alert(pe)}return}if(!r){j("Please login or provide an upvote handler to vote");return}try{const te=Math.round(K*100);await Re.handleUpvote({author:e.author,permlink:e.permlink,weight:te,authToken:r}),l(!0),b(!1),k(!0),setTimeout(()=>{c?.(),k(!1),j("Vote submitted successfully ✅")},3e3)}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";alert(pe)}},$=()=>{s?i(e.author,e.permlink):j("Please login to upvote")},G=e.json_metadata_parsed||(()=>{try{return e.json_metadata?JSON.parse(e.json_metadata):void 0}catch{return}})(),X=e.body||"",R=(K=>{const te=/^(\s*(?:#[\p{L}\p{N}_-]+\s*(?:,\s*)?)+\s*)$/gimu;return K.replace(te,"").trim()})(X),se=n?H(R,n):R,I=/!\[[^\]]*\]\([^)]+\)/.test(R)||/<img\s/i.test(R),V=Array.isArray(G?.image)?G.image:[],J=new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:K=>K,usertagUrlFn:K=>`/@${K}`,hashtagUrlFn:K=>`/trending/${K}`,isLinkSafeFn:K=>!0,addExternalCssClassToMatchingLinksFn:K=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"}),oe=e.stats?.total_votes||e.net_votes||0;return t.jsxs("div",{className:`${u>0?"ml-4 md:ml-8 border-l-2 border-gray-200 dark:border-gray-700 pl-4 md:pl-6":""}`,children:[t.jsx("div",{className:"group hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors duration-200 p-4 md:p-6",children:t.jsxs("div",{className:"flex items-start space-x-3 md:space-x-4",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("img",{src:`https://images.hive.blog/u/${e.author}/avatar`,alt:e.author,className:"w-8 h-8 md:w-10 md:h-10 rounded-full object-cover ring-2 ring-gray-200 dark:ring-gray-700",onError:K=>{K.target.src=`https://ui-avatars.com/api/?name=${e.author}&background=random`}})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center flex-wrap gap-2 mb-2",children:[t.jsxs("button",{className:"font-semibold text-gray-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 text-sm md:text-base",onClick:()=>{},children:["@",e.author]}),t.jsxs("div",{className:"flex items-center text-xs md:text-sm text-gray-500 dark:text-gray-400 space-x-1",children:[t.jsx(z.Clock,{className:"w-3 h-3 md:w-4 md:h-4"}),t.jsx("span",{children:ns.formatDistanceToNow(new Date(e.created+"Z"),{addSuffix:!0})})]}),e.author===s&&t.jsx("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded-full",children:"You"})]}),t.jsx("div",{className:"prose prose-sm md:prose-base dark:prose-invert max-w-none mb-3 comment-content text-left text-gray-900 dark:text-gray-100 prose-a:text-blue-600 dark:prose-a:text-blue-400 [&>*]:text-left",children:n?t.jsx("div",{className:"text-left",dangerouslySetInnerHTML:{__html:se}}):t.jsx("div",{className:"text-left",dangerouslySetInnerHTML:{__html:J.render(R)}})}),!I&&V.length>0&&t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-3",children:V.map((K,te)=>t.jsx("img",{src:K,alt:`image-${te}`,className:"max-w-full h-auto rounded-lg shadow-sm cursor-pointer hover:shadow-md transition-shadow duration-200",onClick:()=>window.open(K,"_blank")},K+te))}),t.jsxs("div",{className:"flex items-center space-x-4 md:space-x-6",children:[t.jsxs("button",{onClick:()=>{if(d){if(!s){j("Please login to upvote");return}if(g||h){j("You have already upvoted this comment");return}F()}else if(o){if(!s){j("Please login to upvote");return}if(g||h){j("You have already upvoted this comment");return}F()}else{if(!s){j("Please login to upvote");return}r?g?j("You have already upvoted this comment"):F():(c?.(),j("Vote submitted successfully ✅"))}},className:`flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium transition-colors duration-200 ${h?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"}`,children:[t.jsx(z.ThumbsUp,{className:`w-4 h-4 ${g||h?"fill-current text-blue-600 dark:text-blue-400":""}`}),t.jsx("span",{children:oe})]}),t.jsxs("button",{onClick:()=>{f?f(e):$()},className:"flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200",children:[t.jsx(z.MessageSquare,{className:"w-4 h-4"}),t.jsx("span",{children:"Reply"})]}),O&&t.jsx("button",{onClick:()=>x(!p),className:"flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200",children:t.jsxs("span",{children:[p?"Hide":"Show"," ",C.length," ",C.length===1?"reply":"replies"]})}),t.jsx("button",{onClick:()=>f?.(e),className:"opacity-0 group-hover:opacity-100 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-all duration-200",children:t.jsx(z.MoreHorizontal,{className:"w-4 h-4 text-gray-400"})})]}),w&&!g&&t.jsx("div",{className:"mt-3",children:t.jsx(ro,{author:e.author,permlink:e.permlink,onUpvote:B,onCancel:()=>b(!1)})}),m&&t.jsxs("div",{className:"mt-3 inline-flex items-center text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin mr-2"}),"Updating votes..."]}),v&&t.jsx("div",{className:"fixed bottom-4 right-4 w-[280px] z-50",children:t.jsx("div",{className:"bg-gray-800 text-white rounded px-3 py-2 shadow-lg text-sm",children:N})})]})]})}),O&&p&&!L&&t.jsx("div",{className:"space-y-0",children:C.map(K=>t.jsx(bd,{comment:K,allComments:a,onReply:i,currentUser:s,searchQuery:n,depth:u+1,onVotedRefresh:c,onClickCommentUpvote:d,onClickCommentReply:f,onClickUpvoteButton:o},K.permlink))}),O&&L&&t.jsx("div",{className:"ml-4 md:ml-8 p-3 text-sm text-gray-500 dark:text-gray-400 border-l-2 border-gray-200 dark:border-gray-700 pl-4",children:t.jsxs("button",{onClick:()=>{console.log("Show more replies for:",e.author,e.permlink)},className:"text-blue-600 dark:text-blue-400 hover:underline",children:["View ",C.length," more ",C.length===1?"reply":"replies"]})})]})},xd=({onSubmit:e,onCancel:a,currentUser:i,placeholder:s="Write your comment...",parentAuthor:r,parentPermlink:n})=>{const[u,c]=P.useState(""),[d,f]=P.useState(!1),o=P.useRef(null);P.useEffect(()=>{o.current&&o.current.focus()},[]);const h=async()=>{if(!(!u.trim()||d)){f(!0);try{await e(u.trim()),c("")}catch(p){console.error("Failed to submit comment:",p)}finally{f(!1)}}},l=p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),h()),p.key==="Escape"&&a()};return t.jsxs("div",{className:"p-4 md:p-6 space-y-4 bg-white dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-start space-x-3 text-left",children:[t.jsx("div",{className:"flex-shrink-0",children:i?t.jsx("img",{src:`https://images.hive.blog/u/${i}/avatar`,alt:i,className:"w-10 h-10 rounded-full object-cover border-2 border-gray-200 dark:border-gray-600",onError:p=>{p.target.src=`https://ui-avatars.com/api/?name=${i}&background=random`}}):t.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:t.jsx(z.User,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white font-medium",children:i?`@${i}`:"Anonymous"}),r&&t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Replying to @",r]})]})]}),t.jsx("div",{className:"relative",children:t.jsx("textarea",{ref:o,value:u,onChange:p=>c(p.target.value),onKeyDown:l,placeholder:s,disabled:d,className:"w-full min-h-[100px] max-h-[300px] p-4 border border-gray-200 dark:border-gray-600 rounded-lg resize-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors duration-200 disabled:opacity-50",style:{height:"auto"},onInput:p=>{const x=p.target;x.style.height="auto",x.style.height=x.scrollHeight+"px"}})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Press Cmd+Enter to post"}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("button",{onClick:a,disabled:d,className:"px-4 py-2 text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors duration-200 disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:h,disabled:d||!u.trim(),className:"px-6 py-2 bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 dark:disabled:bg-gray-600 text-white rounded-lg font-medium transition-all duration-200 transform hover:scale-[1.02] disabled:transform-none disabled:opacity-50 flex items-center space-x-2",children:d?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),t.jsx("span",{children:"Posting..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(z.Send,{className:"w-4 h-4"}),t.jsx("span",{children:"Post"})]})})]})]})]})},op=({parentAuthor:e,parentPermlink:a,onClose:i,onCommentSubmitted:s,currentUser:r})=>{const[n,u]=P.useState(!1),c=async d=>{if(!(!d.trim()||n)){u(!0);try{await s(e,a,d),i()}catch(f){console.error("Failed to submit reply:",f)}finally{u(!1)}}};return P.useEffect(()=>{const d=f=>{f.key==="Escape"&&i()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[i]),t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900 rounded-lg",children:t.jsx(z.Send,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Reply to Comment"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["@",e]})]})]}),t.jsx("button",{onClick:i,disabled:n,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 disabled:opacity-50",children:t.jsx(z.X,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(xd,{onSubmit:c,onCancel:i,currentUser:r,parentAuthor:e,parentPermlink:a,placeholder:`Reply to @${e}...`})}),t.jsx("div",{className:"p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:t.jsxs("div",{className:"flex items-center justify-between text-xs md:text-sm text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("span",{children:"• Markdown supported"}),t.jsx("span",{children:"• Be respectful"})]}),t.jsx("div",{className:"hidden md:block",children:"Press Esc to close"})]})})]})})},up=({isVisible:e,searchQuery:a,onSearchChange:i,onClose:s})=>{const r=P.useRef(null);P.useEffect(()=>{e&&r.current&&r.current.focus()},[e]);const n=()=>{i(""),s()};return t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${e?"max-h-20 opacity-100":"max-h-0 opacity-0"}`,children:t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400"}),t.jsx("input",{ref:r,type:"text",value:a,onChange:u=>i(u.target.value),placeholder:"Search comments and authors...",className:"w-full pl-10 pr-10 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors duration-200"}),a&&t.jsx("button",{onClick:()=>i(""),className:"absolute right-8 top-1/2 transform -translate-y-1/2 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-4 h-4 text-gray-400"})}),t.jsx("button",{onClick:n,className:"absolute right-3 top-1/2 transform -translate-y-1/2 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-4 h-4 text-gray-400"})})]})})})},ao=({author:e,permlink:a,onClose:i,currentUser:s,token:r,onClickCommentUpvote:n,onClickCommentReply:u,onClickUpvoteButton:c,onSubmitComment:d})=>{const[f,o]=P.useState([]),[h,l]=P.useState([]),[p,x]=P.useState(!0),[w,b]=P.useState(null),[g,v]=P.useState(null),[_,N]=P.useState(!1),[y,m]=P.useState(""),[k,j]=P.useState(!1),[A,D]=P.useState(!1),C=P.useCallback(async($=!1)=>{$?D(!0):x(!0),b(null);try{const G=await Re.getCommentsList(e,a);o(G),l(G)}catch(G){b(G instanceof Error?G.message:"Failed to load comments")}finally{x(!1),D(!1)}},[e,a]);P.useEffect(()=>{C()},[C]),P.useEffect(()=>{if(!y.trim())l(f);else{const $=f.filter(G=>G.body?.toLowerCase().includes(y.toLowerCase())||G.author.toLowerCase().includes(y.toLowerCase()));l($)}},[y,f]);const O=($,G)=>{v({author:$,permlink:G})},L=$=>{$.target===$.currentTarget&&i()},H=async($,G,X)=>{if(d){try{await Promise.resolve(d($,G,X)),j(!1),D(!0),setTimeout(async()=>{await C(!0),D(!1)},3e3)}catch(ee){const R=ee instanceof Error?ee.message:"Failed to post comment";alert(R)}return}if(!r){alert("Please login to comment");return}try{await Re.handleComment({author:$,permlink:G,body:X,authToken:r}),j(!1),D(!0),setTimeout(async()=>{await C(!0),D(!1)},3e3)}catch(ee){const R=ee instanceof Error?ee.message:"Failed to post comment";alert(R)}},F=P.useMemo(()=>{if(!s?.trim())return h;const $=s.toLowerCase();return[...h].sort((G,X)=>{const ee=G.author?.toLowerCase()===$,R=X.author?.toLowerCase()===$;return ee&&!R?-1:!ee&&R?1:0})},[h,s]),B=F.filter($=>$.parent_author===e&&$.parent_permlink===a);return p?t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4 h-screen",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl h-[90vh] flex flex-col",children:t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center",children:[t.jsx(z.Loader2,{className:"w-12 h-12 animate-spin text-blue-500 mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Loading comments..."})]})})})}):w?t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-40 p-4 h-screen",onClick:L,children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl h-[90vh] flex flex-col overflow-hidden",children:t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center p-6",children:[t.jsx(z.AlertCircle,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load comments"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6",children:w}),t.jsx("button",{onClick:()=>C(),className:"px-6 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors duration-200",children:"Try Again"})]})})})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-40 p-4 h-screen",onClick:L,children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex justify-between items-center p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("h2",{className:"text-lg md:text-xl font-bold text-gray-900 dark:text-white",children:["Comments (",f.length,")"]}),A&&t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin text-blue-500"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>C(!0),disabled:A,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 disabled:opacity-50",title:"Refresh comments",children:t.jsx(z.RefreshCw,{className:`w-5 h-5 text-gray-500 dark:text-gray-400 ${A?"animate-spin":""}`})}),t.jsx("button",{onClick:()=>N(!_),className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",title:"Search comments",children:t.jsx(z.Search,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})}),t.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})]})]}),t.jsx(up,{isVisible:_,searchQuery:y,onSearchChange:m,onClose:()=>N(!1)}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[k&&t.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:t.jsx(xd,{onSubmit:$=>H(e,a,$),onCancel:()=>j(!1),currentUser:s,placeholder:"Add a comment..."})}),B.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-8 text-center",children:[t.jsx(z.MessageCirclePlus,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mb-4"}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:y?"No comments found":"No comments yet"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-6",children:y?"Try adjusting your search terms":"Be the first to share your thoughts!"}),!y&&s&&t.jsx("button",{onClick:()=>j(!0),className:"px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition-colors duration-200",children:"Add Comment"})]}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:B.map($=>t.jsx(bd,{comment:$,allComments:F,onReply:O,currentUser:s,token:r,searchQuery:y,depth:0,onVotedRefresh:()=>C(!0),onClickCommentUpvote:n,onClickCommentReply:u,onClickUpvoteButton:c},$.permlink))})]}),!k&&s&&B.length>0&&t.jsx("div",{className:"p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:t.jsxs("button",{onClick:()=>j(!0),className:"w-full md:w-auto px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition-all duration-200 transform hover:scale-[1.02] flex items-center justify-center space-x-2",children:[t.jsx(z.MessageCirclePlus,{className:"w-5 h-5"}),t.jsx("span",{children:"Add Comment"})]})})]})}),g&&t.jsx(op,{parentAuthor:g.author,parentPermlink:g.permlink,onClose:()=>v(null),onCommentSubmitted:H,currentUser:s})]})};function lp(e){const a=typeof e=="string"?new Date(e):e,i=Math.floor((Date.now()-a.getTime())/1e3),s={year:31536e3,month:2628e3,day:86400,hour:3600,minute:60};for(const[r,n]of Object.entries(s)){const u=Math.floor(i/n);if(u>1)return`${u} ${r}s ago`;if(u===1)return`${u} ${r} ago`}return"just now"}const yd=({author:e,permlink:a,onClose:i,currentUser:s,token:r,onClickUpvoteButton:n})=>{const[u,c]=P.useState([]),[d,f]=P.useState(!0),[o,h]=P.useState(!1),l=!!s&&u.some(k=>k.voter===s),[p,x]=P.useState(!1),[w,b]=P.useState(""),[g,v]=P.useState(!1),_=k=>{b(k),x(!0),setTimeout(()=>x(!1),2500)},N=async()=>{f(!0);const k=await Re.getActiveVotes(e,a);k.sort((j,A)=>!j.time||!A.time?0:new Date(A.time).getTime()-new Date(j.time).getTime()),c(k),f(!1)};P.useEffect(()=>{N()},[e,a]);const y=k=>{k.target===k.currentTarget&&i()},m=async k=>{if(!r||!s){alert("Please login to upvote");return}try{const j=Math.round(k*100);await Re.handleUpvote({author:e,permlink:a,weight:j,authToken:r}),h(!1),v(!0),setTimeout(async()=>{await N(),v(!1),_("Vote submitted successfully ✅"),i()},3e3)}catch(j){const A=j instanceof Error?j.message:"Failed to upvote";alert(A)}};return t.jsxs("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 px-4 h-screen",onClick:y,children:[t.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-md max-h-[80vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50 flex items-center justify-between",children:[t.jsxs("h2",{className:"text-lg font-bold text-gray-900 dark:text-white flex items-center space-x-2",children:[t.jsxs("span",{children:["Voters (",u.length,")"]}),g&&t.jsx("span",{className:"inline-flex items-center ml-2",children:t.jsx("span",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})})]}),!o&&t.jsx("button",{onClick:()=>{if(n){n(s,r);return}if(!s||!r){_("Please login to upvote");return}l?_("You have already upvoted this post"):h(!0)},"aria-label":"Open Vote Slider",className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",type:"button",children:t.jsx(z.ThumbsUp,{className:`w-5 h-5 ${l?"text-blue-600 dark:text-blue-400 fill-current":"text-gray-600 dark:text-gray-300"}`})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?t.jsx("div",{className:"flex justify-center items-center h-full p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"})}):o&&!l?t.jsx(ro,{author:e,permlink:a,onUpvote:m,onCancel:()=>h(!1)}):t.jsx("ul",{children:u.map(k=>t.jsxs("li",{className:"flex items-center p-4 border-b dark:border-gray-700",children:[t.jsx("img",{src:`https://images.hive.blog/u/${k.voter}/avatar`,alt:k.voter,className:"w-10 h-10 rounded-full mr-4",onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${k.voter}&background=random`}}),t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold text-gray-900 dark:text-white",children:k.voter}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[((k.percent||0)/100).toFixed(0),"%",k.time&&` · ${lp(k.time+"Z")}`]})]})]},k.voter))})})]}),p&&t.jsx("div",{className:"fixed bottom-4 right-4 w-[280px] z-50",children:t.jsx("div",{className:"bg-gray-800 text-white rounded px-3 py-2 shadow-lg text-sm",children:w})})]})},vd=({isOpen:e,onClose:a,title:i,children:s,maxWidth:r="max-w-2xl"})=>e?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),t.jsxs("div",{className:`relative bg-card border border-border rounded-xl shadow-xl w-full mx-4 ${r} max-h-[90vh] overflow-hidden animate-scale-in`,children:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[t.jsx("h2",{className:"text-xl font-bold text-card-foreground",children:i}),t.jsx("button",{onClick:a,className:"p-2 rounded-lg hover:bg-muted transition-colors",children:t.jsx(z.X,{className:"w-5 h-5 text-muted-foreground"})})]}),t.jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-80px)] custom-scrollbar",children:s})]})]}):null,cp=({author:e,permlink:a,content:i,onClose:s})=>t.jsx(vd,{isOpen:!0,onClose:s,title:"Video Description",maxWidth:"max-w-2xl",children:t.jsxs("div",{className:"p-6",children:[i?t.jsx("div",{className:"prose prose-sm max-w-none",children:t.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:t.jsx("pre",{className:"whitespace-pre-wrap text-sm text-card-foreground font-sans leading-relaxed",children:i})})}):t.jsxs("div",{className:"text-center py-8",children:[t.jsx(z.FileText,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),t.jsx("p",{className:"text-muted-foreground",children:"No description available"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video doesn't have a description yet."})]}),t.jsx("div",{className:"mt-6 pt-4 border-t border-border",children:t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsxs("span",{children:["By @",e]}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:["/",a]})]})})]})}),dp=({username:e,permlink:a,onAuthorClick:i,onVideoClick:s,onTagClick:r,onBack:n,onCommentsModal:u,onUpvotesModal:c,onDescriptionModal:d,onVideoInfo:f,onShare:o,onBookmark:h}={})=>{const l=e,p=a,[x,w]=P.useState(null),[b,g]=P.useState(!0),[v,_]=P.useState(null),[N,y]=P.useState(!1),[m,k]=P.useState(null),[j,A]=P.useState(!1),[D,C]=P.useState(!1),[O,L]=P.useState(!1),[H,F]=P.useState(!1),B=P.useRef(null),$=P.useRef(null),G=P.useRef(null);P.useEffect(()=>{(async()=>{if(!(!l||!p))try{g(!0),_(null);const J=await Re.getVideoDetails(l,p);w(J),y(!1),k(null)}catch(J){_(J instanceof Error?J.message:"Failed to load video")}finally{g(!1)}})()},[l,p]);const X=V=>V?V.startsWith("ipfs://")?`https://ipfs-3speak.b-cdn.net/ipfs/${V.replace("ipfs://","").split("/")[0]}/manifest.m3u8`:V:"";P.useEffect(()=>((async()=>{const J=x?.video_v2;if(!N||!J||!B.current)return;const oe=B.current,K=X(J);$.current&&($.current.destroy(),$.current=null),oe.src="",oe.load();try{let te=!1;const pe=()=>{te||(te=!0,oe.play().then(()=>k(null)).catch(xe=>k(`Playback failed: ${xe.message}`)))};if(Qr.isSupported()){const xe=new Qr({debug:!1,enableWorker:!1,lowLatencyMode:!1,backBufferLength:90,maxLoadingDelay:4,maxBufferLength:30,maxMaxBufferLength:600,startLevel:-1});$.current=xe,xe.on(Qr.Events.MANIFEST_PARSED,()=>{}),xe.on(Qr.Events.ERROR,(ge,ke)=>{if(ke.fatal)switch(ke.type){case Qr.ErrorTypes.NETWORK_ERROR:k("Network error, retrying..."),setTimeout(()=>xe.startLoad(),1e3);break;case Qr.ErrorTypes.MEDIA_ERROR:k("Media error, retrying..."),setTimeout(()=>xe.recoverMediaError(),1e3);break;default:k(`Fatal error: ${ke.details}`),xe.destroy(),$.current=null;break}}),xe.attachMedia(oe),xe.loadSource(K)}else if(oe.canPlayType("application/vnd.apple.mpegurl"))oe.src=K;else{const xe=K.replace("/manifest.m3u8","/480p/index.m3u8");oe.src=xe}const Ee=()=>A(!0),Z=()=>{A(!1),pe()},ae=xe=>{const ge=xe.target;k(`Video error: ${ge.error?.message||"Unknown error"}`),A(!1)},re=()=>A(!1);oe.addEventListener("loadstart",Ee),oe.addEventListener("canplay",Z),oe.addEventListener("error",ae),oe.addEventListener("loadeddata",re);const ce=async()=>{const xe=!!document.fullscreenElement;try{xe?"orientation"in screen&&await(screen.orientation?.lock?.("landscape")??Promise.resolve()):"orientation"in screen&&screen.orientation?.unlock?.()}catch{}};return document.addEventListener("fullscreenchange",ce),G.current=()=>{document.removeEventListener("fullscreenchange",ce)},()=>{oe.removeEventListener("loadstart",Ee),oe.removeEventListener("canplay",Z),oe.removeEventListener("error",ae),oe.removeEventListener("loadeddata",re),G.current&&G.current()}}catch(te){k(`Setup error: ${te instanceof Error?te.message:"Unknown"}`)}})(),()=>{$.current&&($.current.destroy(),$.current=null)}),[N,x?.video_v2]);const ee=()=>{if(!x?.video_v2){k("No video source available");return}y(!0),k(null),A(!0)},R=V=>{s&&s(V)},se=V=>{i&&i(V)},I=V=>{if(!V)return"00:00";const J=Math.floor(V),oe=Math.floor(J/3600),K=Math.floor(J%3600/60),te=J%60,pe=Ee=>Ee.toString().padStart(2,"0");return J<60?`00:${pe(te)}`:oe===0?`${pe(K)}:${pe(te)}`:`${pe(oe)}:${pe(K)}:${pe(te)}`};return b?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("div",{className:"sticky top-0 z-50 w-full bg-background border-b border-border",children:t.jsx("div",{className:"container mx-auto px-4 py-3",children:t.jsx("div",{className:"h-8 w-24 bg-muted rounded-full animate-pulse"})})}),t.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:t.jsxs("div",{className:"animate-pulse space-y-6",children:[t.jsx("div",{className:"aspect-video bg-muted rounded-xl"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})]})})]}):v||!x?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsxs("div",{className:"text-center max-w-md mx-auto px-4",children:[t.jsx("h2",{className:"text-xl font-semibold text-card-foreground mb-2",children:"Failed to Load Video"}),t.jsx("p",{className:"text-muted-foreground mb-4",children:v||"Video not found"}),t.jsxs("button",{onClick:()=>{n&&n()},className:"inline-flex items-center gap-2 px-4 py-2 bg-card border border-border text-card-foreground rounded-lg hover:bg-card-hover transition-colors",children:[t.jsx(z.ArrowLeft,{className:"w-4 h-4"}),"Go Back"]})]})}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("div",{className:"sticky top-0 z-50 w-full bg-background/95 backdrop-blur-sm border-b border-border",children:t.jsx("div",{className:"container mx-auto px-4 py-3",children:t.jsxs("button",{onClick:()=>{n&&n()},className:"inline-flex items-center gap-2 text-muted-foreground hover:text-card-foreground transition-colors",children:[t.jsx(z.ArrowLeft,{className:"w-4 h-4"}),"Back"]})})}),t.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsx("div",{className:"w-full aspect-video bg-black rounded-xl overflow-hidden relative shadow-card",children:N?t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("video",{ref:B,controls:!0,poster:Br(x.thumbnail),className:"w-full h-full object-contain bg-black",onDoubleClick:async V=>{const J=V.currentTarget;try{document.fullscreenElement?await document.exitFullscreen():await J.requestFullscreen()}catch{}}}),j&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),m&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80",children:t.jsxs("div",{className:"text-center text-white",children:[t.jsx("p",{className:"mb-4",children:m}),t.jsx("button",{onClick:()=>{y(!1),k(null)},className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover transition-colors",children:"Try Again"})]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("img",{src:Br(x.thumbnail)||`https://images.hive.blog/u/${x.owner}/avatar`,alt:x.title,className:"w-full h-full object-cover",onError:V=>{V.target.src=`https://images.hive.blog/u/${x.owner}/avatar`}}),t.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-30"}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("button",{onClick:ee,className:"bg-primary hover:bg-primary-hover rounded-full p-6 transform hover:scale-110 transition-all duration-300 shadow-lg",children:t.jsx(z.Play,{className:"w-8 h-8 text-primary-foreground ml-1",fill:"currentColor"})})}),x.duration&&t.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/80 text-white text-sm px-3 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[t.jsx(z.Clock,{className:"w-3 h-3"}),I(x.duration)]}),x.views&&t.jsxs("div",{className:"absolute bottom-4 left-4 bg-black/80 text-white text-sm px-3 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[t.jsx(z.Eye,{className:"w-3 h-3"}),x.views.toLocaleString()," views"]})]})}),t.jsx(Ec,{title:x.title||"",author:x.owner||"",permlink:x.permlink||"",createdAt:x.created,description:x.description||"",video:{title:x.title||"",author:x.owner||"",permlink:x.permlink||"",created:x.created||new Date,category:x.category||"",numOfUpvotes:void 0,numOfComments:void 0,hiveValue:void 0,duration:x.duration,thumbnail:x.thumbnail,views:x.views},onTapComment:()=>{u?u(l,p):C(!0)},onTapUpvote:()=>{c?c(l,p):L(!0)},onTapInfo:()=>{d?d(l,p,x.description||""):F(!0)},onTapAuthor:()=>{i&&i(x.owner)},onTapShare:()=>{o&&o(l,p)},onTapBookmark:()=>{h&&h(l,p)}}),x.tags&&t.jsx("div",{className:"flex flex-wrap gap-2",children:x.tags.split(",").map((V,J)=>t.jsxs("span",{className:"bg-primary/10 text-primary px-3 py-1 rounded-full text-sm font-medium hover:bg-primary/20 transition-colors cursor-pointer",onClick:()=>{r&&r(V.trim())},children:["#",V.trim()]},J))})]}),t.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 sticky top-24",children:[t.jsx("h3",{className:"font-semibold text-card-foreground mb-4 text-lg",children:"Related Videos"}),t.jsx("div",{className:"space-y-4",children:t.jsx(ss,{feedType:Ge.RELATED,username:x.owner,onVideoClick:R,onAuthorClick:se})})]})]})}),D&&l&&p&&t.jsx(ao,{author:l,permlink:p,onClose:()=>C(!1)}),O&&l&&p&&t.jsx(yd,{author:l,permlink:p,onClose:()=>L(!1)}),H&&l&&p&&t.jsx(cp,{author:l,permlink:p,content:x.description||"",onClose:()=>F(!1)})]})};var wd={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},hc=P.createContext&&P.createContext(wd),fp=["attr","size","title"];function hp(e,a){if(e==null)return{};var i=pp(e,a),s,r;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)s=n[r],!(a.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(i[s]=e[s])}return i}function pp(e,a){if(e==null)return{};var i={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(a.indexOf(s)>=0)continue;i[s]=e[s]}return i}function rs(){return rs=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},rs.apply(this,arguments)}function pc(e,a){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function as(e){for(var a=1;a<arguments.length;a++){var i=arguments[a]!=null?arguments[a]:{};a%2?pc(Object(i),!0).forEach(function(s){mp(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):pc(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function mp(e,a,i){return a=gp(a),a in e?Object.defineProperty(e,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[a]=i,e}function gp(e){var a=bp(e,"string");return typeof a=="symbol"?a:a+""}function bp(e,a){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function _d(e){return e&&e.map((a,i)=>P.createElement(a.tag,as({key:i},a.attr),_d(a.child)))}function la(e){return a=>P.createElement(xp,rs({attr:as({},e.attr)},a),_d(e.child))}function xp(e){var a=i=>{var{attr:s,size:r,title:n}=e,u=hp(e,fp),c=r||i.size||"1em",d;return i.className&&(d=i.className),e.className&&(d=(d?d+" ":"")+e.className),P.createElement("svg",rs({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,s,u,{className:d,style:as(as({color:e.color||i.color},i.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),n&&P.createElement("title",null,n),e.children)};return hc!==void 0?P.createElement(hc.Consumer,null,i=>a(i)):a(wd)}function yp(e){return la({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M296 160H180.6l42.6-129.8C227.2 15 215.7 0 200 0H56C44 0 33.8 8.9 32.2 20.8l-32 240C-1.7 275.2 9.5 288 24 288h118.7L96.6 482.5c-3.6 15.2 8 29.5 23.3 29.5 8.4 0 16.4-4.4 20.8-12l176-304c9.3-15.9-2.2-36-20.7-36z"},child:[]}]})(e)}function vp(e){return la({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 405.3V448c0 35.3 86 64 192 64s192-28.7 192-64v-42.7C342.7 434.4 267.2 448 192 448S41.3 434.4 0 405.3zM320 128c106 0 192-28.7 192-64S426 0 320 0 128 28.7 128 64s86 64 192 64zM0 300.4V352c0 35.3 86 64 192 64s192-28.7 192-64v-51.6c-41.3 34-116.9 51.6-192 51.6S41.3 334.4 0 300.4zm416 11c57.3-11.1 96-31.7 96-55.4v-42.7c-23.2 16.4-57.3 27.6-96 34.5v63.6zM192 160C86 160 0 195.8 0 240s86 80 192 80 192-35.8 192-80-86-80-192-80zm219.3 56.3c60-10.8 100.7-32 100.7-56.3v-42.7c-35.5 25.1-96.5 38.6-160.7 41.8 29.5 14.3 51.2 33.5 60 57.2z"},child:[]}]})(e)}function wp(e){return la({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(e)}function _p(e){return la({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M608 64H32C14.33 64 0 78.33 0 96v320c0 17.67 14.33 32 32 32h576c17.67 0 32-14.33 32-32V96c0-17.67-14.33-32-32-32zM48 400v-64c35.35 0 64 28.65 64 64H48zm0-224v-64h64c0 35.35-28.65 64-64 64zm272 176c-44.19 0-80-42.99-80-96 0-53.02 35.82-96 80-96s80 42.98 80 96c0 53.03-35.83 96-80 96zm272 48h-64c0-35.35 28.65-64 64-64v64zm0-224c-35.35 0-64-28.65-64-64h64v64z"},child:[]}]})(e)}function kp(e){return la({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M560 224h-29.5c-8.8-20-21.6-37.7-37.4-52.5L512 96h-32c-29.4 0-55.4 13.5-73 34.3-7.6-1.1-15.1-2.3-23-2.3H256c-77.4 0-141.9 55-156.8 128H56c-14.8 0-26.5-13.5-23.5-28.8C34.7 215.8 45.4 208 57 208h1c3.3 0 6-2.7 6-6v-20c0-3.3-2.7-6-6-6-28.5 0-53.9 20.4-57.5 48.6C-3.9 258.8 22.7 288 56 288h40c0 52.2 25.4 98.1 64 127.3V496c0 8.8 7.2 16 16 16h64c8.8 0 16-7.2 16-16v-48h128v48c0 8.8 7.2 16 16 16h64c8.8 0 16-7.2 16-16v-80.7c11.8-8.9 22.3-19.4 31.3-31.3H560c8.8 0 16-7.2 16-16V240c0-8.8-7.2-16-16-16zm-128 64c-8.8 0-16-7.2-16-16s7.2-16 16-16 16 7.2 16 16-7.2 16-16 16zM256 96h128c5.4 0 10.7.4 15.9.8 0-.3.1-.5.1-.8 0-53-43-96-96-96s-96 43-96 96c0 2.1.5 4.1.6 6.2 15.2-3.9 31-6.2 47.4-6.2z"},child:[]}]})(e)}function Np(e){return la({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M461.2 128H80c-8.84 0-16-7.16-16-16s7.16-16 16-16h384c8.84 0 16-7.16 16-16 0-26.51-21.49-48-48-48H64C28.65 32 0 60.65 0 96v320c0 35.35 28.65 64 64 64h397.2c28.02 0 50.8-21.53 50.8-48V176c0-26.47-22.78-48-50.8-48zM416 336c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z"},child:[]}]})(e)}const no=new Id.Client(["https://api.hive.blog"]),jp=async e=>{try{const a=await no.database.getAccounts([e]);if(!a||a.length===0)throw new Error("Account not found");return a[0]}catch(a){return console.error("Error in getWalletDataDetail:",a),{error:a instanceof Error?a.message:"Unknown error"}}},Ep=async e=>{try{const a=await no.database.getDynamicGlobalProperties(),i=parseFloat(e.split(" ")[0]),s=parseFloat(String(a.total_vesting_shares).split(" ")[0]),r=parseFloat(String(a.total_vesting_fund_hive).split(" ")[0]);return(i*r/s).toFixed(3)}catch(a){return console.error("Error in convertVestingSharesToHiveData:",a),"0"}},Ap=async e=>{try{const i=(await no.database.call("get_feed_history",[])).current_median_history,s=parseFloat(i.base.split(" ")[0]),r=typeof e=="string"?parseFloat(e):e;return(s*r).toFixed(2)}catch(a){return console.error("Error in convertHivetoUSDData:",a),"0"}},kd=_c.create(e=>({walletData:null,isLoading:!1,error:null,setWalletData:a=>e({walletData:a}),clearWalletData:()=>e({walletData:null,error:null}),fetchWalletData:async a=>{e({isLoading:!0,error:null});try{const i=await jp(a),s=w=>"error"in w;if(!i||s(i))throw new Error(s(i)?i.error:"Account not found");const r=typeof i.vesting_shares=="string"?i.vesting_shares:"0.000000 VESTS",n=typeof i.balance=="string"?i.balance:i.balance.toString(),u=typeof i.hbd_balance=="string"?i.hbd_balance:i.hbd_balance.toString(),c=typeof i.savings_balance=="string"?i.savings_balance:i.savings_balance.toString(),d=typeof i.savings_hbd_balance=="string"?i.savings_hbd_balance:i.savings_hbd_balance.toString(),f=await Ep(r),o=parseFloat(n.split(" ")[0]||"0"),h=parseFloat(f),l=(o+h).toFixed(3),p=await Ap(l),x={balance:n,hbd_balance:u,savings_balance:c,savings_hbd_balance:d,hive_power:`${f} HP`,estimated_value:`$${p}`};return e({walletData:x}),x}catch(i){const s=i instanceof Error?i.message:"Failed to fetch wallet data";console.error("Wallet fetch error:",s);const r={balance:"0.000 HIVE",hbd_balance:"0.000 HBD",savings_balance:"0.000 HIVE",savings_hbd_balance:"0.000 HBD",hive_power:"0 HP",estimated_value:"$0.00",error:s};return e({walletData:r,error:s}),r}finally{e({isLoading:!1})}}})),Sp=({username:e,className:a=""})=>{const{walletData:i,fetchWalletData:s,isLoading:r,error:n}=kd();P.useEffect(()=>{e&&s(e)},[e,s]);const u=({label:c,value:d,icon:f,colorClass:o="bg-primary/10"})=>t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-card border border-border shadow-sm mb-3 transition-all duration-200 hover:shadow-md",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[f&&t.jsx("div",{className:`p-2 rounded-full flex items-center justify-center ${o} text-primary`,children:f}),t.jsx("span",{className:"font-semibold text-card-foreground",children:c})]}),t.jsx("span",{className:"font-medium text-muted-foreground",children:d??"-"})]});return t.jsx("div",{className:`min-h-screen bg-gradient-elegant p-4 transition-all duration-300 ${a}`,children:t.jsxs("div",{className:"max-w-md mx-auto",children:[t.jsxs("div",{className:"flex flex-col items-center p-6 mb-6 rounded-xl bg-card border border-border shadow-elegant",children:[e&&t.jsx("img",{src:`https://images.hive.blog/u/${e}/avatar`,alt:`${e} avatar`,className:"w-20 h-20 rounded-full border-4 border-primary/20 mb-3 transition-transform hover:scale-105",onError:c=>{c.target.src=`https://ui-avatars.com/api/?name=${e}&background=random`}}),t.jsx("div",{className:"text-lg font-bold text-card-foreground",children:e}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Hive Wallet Overview"})]}),t.jsxs("div",{className:"text-center rounded-xl bg-gradient-primary shadow-glow p-6 mb-6 transition-all duration-300 hover:shadow-elegant",children:[t.jsx("div",{className:"text-sm font-semibold text-primary-foreground/80",children:"Estimated Value"}),t.jsx("div",{className:"text-3xl font-bold mt-2 text-primary-foreground",children:r?t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"}),"Loading..."]}):i?.estimated_value??"-"})]}),n&&t.jsxs("div",{className:"flex items-center p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive mb-4",children:[t.jsx(wp,{className:"mr-2"}),t.jsx("span",{children:n})]}),t.jsx(u,{label:"Balance",value:i?.balance,icon:t.jsx(Np,{}),colorClass:"bg-blue-500/10"}),t.jsx(u,{label:"HBD Balance",value:i?.hbd_balance,icon:t.jsx(_p,{}),colorClass:"bg-green-500/10"}),t.jsx(u,{label:"Savings Balance",value:i?.savings_balance,icon:t.jsx(kp,{}),colorClass:"bg-yellow-500/10"}),t.jsx(u,{label:"Savings HBD Balance",value:i?.savings_hbd_balance,icon:t.jsx(vp,{}),colorClass:"bg-purple-500/10"}),t.jsx(u,{label:"Hive Power",value:i?.hive_power,icon:t.jsx(yp,{}),colorClass:"bg-orange-500/10"})]})})};function Nd({sort:e="trending",tag:a="",observer:i="hive.blog",limit:s=20,showSortDropdown:r=!0,theme:n="dark",onAuthorClick:u,onPostClick:c,onCommunityClick:d,onPayoutClick:f,onUpvoteClick:o,onCommentClick:h,onReblogClick:l}){const[p,x]=P.useState([]),[w,b]=P.useState(!0),[g,v]=P.useState(null),[_,N]=P.useState(e),[y,m]=P.useState(!0),[k,j]=P.useState(!1),A=P.useRef(null);new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:B=>B,usertagUrlFn:B=>`/@${B}`,hashtagUrlFn:B=>`/trending/${B}`,isLinkSafeFn:B=>!0,addExternalCssClassToMatchingLinksFn:B=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"});const D=P.useCallback(async(B,$=!1)=>{$?j(!0):(b(!0),m(!0)),v(null);try{const G=$&&p.length>0?p[p.length-1]:null,X=await Re.getRankedPosts(B,a,i,s,G?.author,G?.permlink);$?(x(ee=>{const R=new Set(ee.map(I=>I.post_id)),se=X.filter(I=>!R.has(I.post_id));return[...ee,...se]}),m(X.length===s)):(x(X),m(X.length===s))}catch(G){v(G instanceof Error?G.message:"Failed to load posts"),m(!1)}finally{b(!1),j(!1)}},[a,i,s,p]),C=P.useCallback(()=>{!k&&y&&!w&&D(_,!0)},[k,y,w,_,D]);P.useEffect(()=>{D(_)},[_,a,i,s]),P.useEffect(()=>{const B=new IntersectionObserver($=>{$[0].isIntersecting&&C()},{threshold:1});return A.current&&B.observe(A.current),()=>{A.current&&B.unobserve(A.current)}},[C]);const O=B=>{N(B),x([]),m(!0)},L=B=>B>=1e6?`${(B/1e6).toFixed(1)}M`:B>=1e3?`${(B/1e3).toFixed(1)}K`:B.toString(),H=B=>{const $=B.payout*.5,G=B.payout*.5,ee=(B.beneficiaries.find(R=>R.account==="commentrewarder")?.weight||0)/1e4*100;return{pending:`$${B.payout.toFixed(2)}`,breakdown:`${$.toFixed(2)} HBD, ${G.toFixed(2)} HP`,commentRewarder:`${ee.toFixed(2)}%`,payoutInDays:Math.ceil((new Date(B.payout_at).getTime()-Date.now())/(1e3*60*60*24))}},F=B=>{const G=(B.body||"").replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#+\s*/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/<[^>]*>/g,"").replace(/\n+/g," ").trim();return G.length>200?G.substring(0,200)+"...":G};return w?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(z.Loader2,{className:"w-8 h-8 animate-spin"})}):g?t.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-card-foreground",children:"Failed to load posts"}),t.jsx("p",{className:"text-muted-foreground",children:g}),t.jsx("button",{onClick:()=>D(_),className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90",children:"Retry"})]}):t.jsx("div",{className:n==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[r&&t.jsx("div",{className:"flex justify-center",children:t.jsxs("select",{value:_,onChange:B=>O(B.target.value),className:`px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary ${n==="dark"?"bg-slate-950 text-white":"bg-card text-card-foreground"}`,children:[t.jsx("option",{value:"trending",children:"Trending"}),t.jsx("option",{value:"hot",children:"Hot"}),t.jsx("option",{value:"created",children:"New"})]})}),t.jsxs("div",{className:"space-y-4",children:[p.map(B=>{const $=B.json_metadata?.image?.[0],G=H(B);return t.jsxs("div",{className:`border border-border rounded-xl p-4 shadow-card hover:shadow-card-hover transition-shadow ${n==="dark"?"bg-slate-900 text-white":"bg-slate-50 text-black"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("img",{src:`https://images.hive.blog/u/${B.author}/avatar`,alt:B.author,className:"w-8 h-8 rounded-full cursor-pointer flex-shrink-0",onClick:()=>u?.(B.author,`https://images.hive.blog/u/${B.author}/avatar`),onError:X=>{X.target.src=`https://ui-avatars.com/api/?name=${B.author}&background=random`}}),t.jsx("span",{className:"font-medium cursor-pointer hover:text-primary",onClick:()=>u?.(B.author,`https://images.hive.blog/u/${B.author}/avatar`),children:B.author}),t.jsxs("span",{className:n==="dark"?"text-gray-400":"text-muted-foreground",children:["(",B.author_reputation.toFixed(2),")"]}),t.jsx("span",{className:`cursor-pointer hover:text-primary ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>d?.(B.community_title),children:B.community_title}),t.jsx("span",{className:`hidden sm:inline ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"•"}),t.jsx("span",{className:`text-sm ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:ns.formatDistanceToNow(new Date(B.created+"Z"),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex gap-3 sm:gap-4",children:[t.jsx("div",{className:"flex-shrink-0",children:$?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:$.startsWith("http")?$:`https://images.hive.blog/u/320x0/${$}`,alt:B.title,className:"w-20 h-20 sm:w-32 sm:h-32 object-cover rounded-lg cursor-pointer",onClick:()=>c?.(B),onError:X=>{X.target.src!==`https://images.hive.blog/u/${B.author}/avatar`?X.target.src=`https://images.hive.blog/u/${B.author}/avatar`:X.target.src="https://images.hive.blog/u/null/avatar"}}),(()=>{const X=B.body?.match(/!\[[^\]]*\]\(([^)]+)\)/g)?.map(ee=>{const R=ee.match(/\(([^)]+)\)/);return R?R[1]:null}).filter(Boolean)||[];return X.length>0?t.jsx("div",{className:"absolute -bottom-1 -right-1 sm:-bottom-2 sm:-right-2 flex space-x-1",children:X.slice(0,3).map((ee,R)=>t.jsx("img",{src:ee,alt:`body-image-${R}`,className:"w-6 h-6 sm:w-8 sm:h-8 object-cover rounded border-2 border-white shadow-sm cursor-pointer",onClick:se=>{se.stopPropagation();const I=se.currentTarget.parentElement?.parentElement?.querySelector("img:not(.w-6):not(.w-8)");I&&(I.src=ee)}},R))}):null})()]}):t.jsx("img",{src:`https://images.hive.blog/u/${B.author}/avatar`,alt:B.author,className:"w-20 h-20 sm:w-32 sm:h-32 rounded-lg cursor-pointer",onClick:()=>c?.(B)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-1 sm:mb-2 cursor-pointer hover:text-primary line-clamp-2",onClick:()=>c?.(B),children:B.title}),t.jsx("p",{className:`mb-2 sm:mb-3 line-clamp-2 sm:line-clamp-3 cursor-pointer hover:text-primary text-sm sm:text-base ${n==="dark"?"text-gray-300":"text-gray-600"}`,onClick:()=>c?.(B),children:B.json_metadata?.description||F(B)||"No description available"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"relative group",children:[t.jsxs("span",{className:"font-semibold text-green-600 cursor-pointer hover:text-green-700 text-sm sm:text-base",onClick:()=>f?.(B.payout),children:["$",B.payout.toFixed(2)]}),t.jsxs("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block bg-black text-white text-xs p-2 rounded shadow-lg whitespace-nowrap z-10",children:[t.jsxs("div",{children:["Pending payout amount: ",G.pending]}),t.jsxs("div",{children:["Breakdown: ",G.breakdown]}),t.jsxs("div",{children:["commentrewarder: ",G.commentRewarder]}),t.jsxs("div",{children:["Payout in ",G.payoutInDays," days"]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[t.jsxs("div",{className:`flex items-center gap-1 hover:text-primary transition-colors cursor-pointer ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>o?.(B),children:[t.jsx(z.ThumbsUp,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.stats.total_votes)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-blue-400 transition-colors cursor-pointer ${n==="dark"?"text-blue-400":"text-blue-600"}`,onClick:()=>h?.(B),children:[t.jsx(z.MessageCircle,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.children)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-gray-400 transition-colors cursor-pointer ${n==="dark"?"text-gray-400":"text-gray-600"}`,onClick:()=>l?.(B),children:[t.jsx(z.Repeat2,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.reblogs)})]})]})]})]})]})]},B.post_id)}),k&&t.jsxs("div",{className:"flex justify-center items-center py-4",children:[t.jsx(z.Loader2,{className:"w-6 h-6 animate-spin"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"Loading more posts..."})]}),y&&!k&&t.jsx("div",{ref:A,className:"h-10"})]})]})})}class sa{static instance;static getInstance(){return sa.instance||(sa.instance=new sa),sa.instance}async getProposals(a){return a==="expired"?this.getExpiredProposals():this.getActiveProposals()}async getActiveProposals(){try{const s=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:72,jsonrpc:"2.0",method:"database_api.list_proposals",params:{start:[-1],limit:500,order:"by_total_votes",order_direction:"descending",status:"votable"}})})).json()).result.proposals,n=await(await fetch("https://stats.hivehub.dev/dhf_proposals")).json(),u={};n.forEach(h=>{u[h.proposal_id]=h});const f=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:73,jsonrpc:"2.0",method:"database_api.list_proposal_votes",params:{start:["shaktimaaan"],limit:1e3,order:"by_voter_proposal",order_direction:"ascending",status:"votable"}})})).json()).result.proposal_votes||[],o={};return f.forEach(h=>{o[h.proposal.proposal_id]||(o[h.proposal.proposal_id]=[]),o[h.proposal.proposal_id].push(h)}),s.map(h=>{const l=h.id,p=u[l],x=o[l]||[],w=x.reduce((b,g)=>b+parseFloat(g.total_hbd||"0"),0);return{proposal_id:l,subject:h.subject,permlink:h.permlink,creator:h.creator,receiver:h.receiver,start_date:h.start_date,end_date:h.end_date,total_hbd_received:p?p.total_hbd_received:"0",max_hbd_remaining:p?p.max_hbd_remaining:"0",all_votes_num:h.total_votes||"0",all_votes_hp:p?p.all_votes_hp:w.toString(),votes:p?p.votes:x,status:h.status,daily_pay:h.daily_pay,total_votes:h.total_votes,daily_pay_hbd:h.daily_pay?Number(h.daily_pay.amount)/Math.pow(10,h.daily_pay.precision):0,remaining_days:Math.max(0,Math.ceil((new Date(h.end_date).getTime()-new Date().getTime())/(1e3*60*60*24))),vote_value_total:p?parseFloat(p.all_votes_hp):w}})}catch(a){return console.error("Error fetching active proposals:",a),[]}}async getExpiredProposals(){try{const s=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:65,jsonrpc:"2.0",method:"database_api.list_proposals",params:{start:[-1],limit:500,order:"by_total_votes",order_direction:"descending",status:"expired"}})})).json()).result.proposals,n=await(await fetch("https://stats.hivehub.dev/dhf_proposals")).json(),u={};n.forEach(h=>{u[h.proposal_id]=h});const f=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:76,jsonrpc:"2.0",method:"database_api.list_proposal_votes",params:{start:["shaktimaaan"],limit:1e3,order:"by_voter_proposal",order_direction:"ascending",status:"expired"}})})).json()).result.proposal_votes||[],o={};return f.forEach(h=>{o[h.proposal_id]||(o[h.proposal_id]=[]),o[h.proposal_id].push(h)}),s.map(h=>{const l=h.id,p=u[l],x=o[l]||[],w=x.reduce((b,g)=>b+parseFloat(g.total_hbd||"0"),0);return{proposal_id:l,subject:h.subject,permlink:h.permlink,creator:h.creator,receiver:h.receiver,start_date:h.start_date,end_date:h.end_date,total_hbd_received:p?p.total_hbd_received:"0",max_hbd_remaining:p?p.max_hbd_remaining:"0",all_votes_num:h.total_votes||"0",all_votes_hp:p?p.all_votes_hp:w.toString(),votes:p?p.votes:x,status:h.status,daily_pay:h.daily_pay,total_votes:h.total_votes,daily_pay_hbd:h.daily_pay?Number(h.daily_pay.amount)/Math.pow(10,h.daily_pay.precision):0,remaining_days:0,vote_value_total:p?parseFloat(p.all_votes_hp):w}})}catch(a){return console.error("Error fetching expired proposals:",a),[]}}}const mc=sa.getInstance(),Cp=["All","Active","Upcoming","Expired","By Peak Projects"],jd=["Votes","Start Date","End Date","Creator"],gc=e=>e==="By Peak Projects"?["Creator"]:jd,it=e=>{const a=typeof e=="string"?parseFloat(e):e;return isNaN(a)?e.toString():a.toLocaleString()},Si=e=>{const a=new Date(e.start_date),i=new Date(e.end_date);return`(${Math.ceil((i.getTime()-a.getTime())/(1e3*60*60*24))} days)`},Dp=({onClickSupport:e,onClickVoteValue:a,onClickSelect:i,onClickUser:s,onClickAvatar:r,theme:n="dark"})=>{const[u,c]=P.useState([]),[d,f]=P.useState("All"),[o,h]=P.useState("Votes");P.useEffect(()=>{d==="By Peak Projects"&&!gc(d).includes(o)?h("Creator"):d!=="By Peak Projects"&&o==="Creator"&&!jd.includes(o)&&h("Votes")},[d,o]);const[l,p]=P.useState(!0);P.useEffect(()=>{(async()=>{p(!0);try{const[g,v]=await Promise.all([mc.getProposals("active"),mc.getProposals("expired")]);c([...g,...v])}catch(g){console.error("Error fetching proposals:",g),c([])}p(!1)})()},[]);const x=u.filter(b=>d==="All"?b.status==="active"||new Date(b.start_date+"Z")>new Date:d==="Active"?b.status==="active":d==="Upcoming"?new Date(b.start_date+"Z")>new Date:d==="Expired"?new Date(b.end_date+"Z")<new Date:d==="By Peak Projects"?b.creator==="peakd":!0).sort((b,g)=>d==="By Peak Projects"?g.creator.localeCompare(b.creator):0),w=d==="All"?(()=>{const b=x.filter(_=>_.status==="active"),g=x.filter(_=>new Date(_.start_date+"Z")>new Date),v=(_,N)=>o==="Votes"?Number(N.all_votes_num)-Number(_.all_votes_num):o==="Start Date"?new Date(N.start_date+"Z").getTime()-new Date(_.start_date+"Z").getTime():o==="End Date"?new Date(_.end_date+"Z").getTime()-new Date(N.end_date+"Z").getTime():o==="Creator"?_.creator.localeCompare(N.creator):0;return[...b.sort(v),...g.sort(v)]})():x.sort((b,g)=>o==="Votes"?Number(g.all_votes_num)-Number(b.all_votes_num):o==="Start Date"?new Date(g.start_date+"Z").getTime()-new Date(b.start_date+"Z").getTime():o==="End Date"?new Date(b.end_date+"Z").getTime()-new Date(g.end_date+"Z").getTime():o==="Creator"?b.creator.localeCompare(g.creator):0);return l?t.jsx("div",{className:"flex justify-center items-center py-8",children:t.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading proposals..."})}):t.jsx("div",{className:n==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:Cp.map(b=>t.jsx("button",{className:`px-3 py-1 rounded text-sm ${d===b?"bg-blue-500 text-white":`${n==="dark"?"bg-slate-900 text-gray-300":"bg-gray-200 text-gray-700"}`}`,onClick:()=>f(b),children:b},b))}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:`${n==="dark"?"text-gray-300":"text-gray-700"} mr-2`,children:"Sort by:"}),t.jsx("select",{value:o,onChange:b=>h(b.target.value),className:`px-3 py-1 border rounded ${n==="dark"?"border-gray-600 bg-slate-900 text-gray-100":"border-gray-300 bg-white text-gray-900"}`,children:gc(d).map(b=>t.jsx("option",{value:b,children:b},b))})]}),t.jsxs("div",{children:[d==="All"&&(()=>{const b=w.filter(v=>v.status==="active"),g=w.filter(v=>new Date(v.start_date+"Z")>new Date);return t.jsxs(t.Fragment,{children:[b.map(v=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-900":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(v),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${v.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${v.creator} avatar`})}),t.jsxs("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(v),children:["by ",v.creator]}),v.receiver&&t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:v.receiver})]})]}),t.jsxs("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(v),children:[v.subject," ",t.jsxs("span",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-500":"text-gray-600"}`,children:["#",v.proposal_id]})]}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(v.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(v.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":v.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(v.start_date+"Z")>new Date?"upcoming":new Date(v.end_date+"Z")<new Date?"expired":v.status})," - "+new Date(v.start_date+"Z").toLocaleDateString()+" - "+new Date(v.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(v)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/${v.creator}/${v.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${v.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(v),children:["Vote value: ",v.vote_value_total?it(v.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Daily Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[v.daily_pay_hbd?it(v.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Remaining:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.remaining_days||0)," Days"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Paid:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"To Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(v),children:"Support"})})]})]})},v.proposal_id)),g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"my-6 text-center",children:[t.jsx("h3",{className:`text-xl font-bold mb-2 ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:"Upcoming proposals"}),t.jsx("p",{className:`${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"The proposals listed below will start in the future. You can already support them."})]}),g.map(v=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-950":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(v),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${v.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${v.creator} avatar`})}),t.jsx("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(v),children:v.creator}),t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:v.receiver})]})]}),t.jsx("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(v),children:v.subject}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(v.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(v.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":v.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(v.start_date+"Z")>new Date?"upcoming":new Date(v.end_date+"Z")<new Date?"expired":v.status})," - "+new Date(v.start_date+"Z").toLocaleDateString()+" - "+new Date(v.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(v)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/${v.creator}/${v.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${v.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(v),children:["Vote value: ",v.vote_value_total?it(v.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Daily Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[v.daily_pay_hbd?it(v.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Remaining:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.remaining_days||0)," Days"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Paid:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"To Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(v),children:"Support"})})]})]})},v.proposal_id))]})]})})(),d!=="All"&&w.map(b=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-950":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(b),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${b.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${b.creator} avatar`})}),t.jsx("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(b),children:b.creator}),t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:b.receiver})]})]}),t.jsxs("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(b),children:[b.subject," #",b.proposal_id]}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(b.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(b.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":b.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(b.start_date+"Z")>new Date?"upcoming":new Date(b.end_date+"Z")<new Date?"expired":b.status})," - "+new Date(b.start_date+"Z").toLocaleDateString()+" - "+new Date(b.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(b)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/@${b.creator}/${b.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${b.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(b),children:["Vote value: ",b.vote_value_total?it(b.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Daily Pay:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[b.daily_pay_hbd?it(b.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Remaining:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.remaining_days||0)," Days"]})]}),d!=="Expired"&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Paid:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"To Pay:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(b),children:"Support"})})]})]})},b.proposal_id))]})]})})};class Tp{HIVE_API_URL="https://api.hive.blog";async getProfile(a){const i={jsonrpc:"2.0",method:"bridge.get_profile",params:{account:a},id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getFollowers(a){const i={jsonrpc:"2.0",method:"condenser_api.get_followers",params:[a,null,"blog"],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getFollowing(a){const i={jsonrpc:"2.0",method:"condenser_api.get_following",params:[a,null,"blog"],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getAccounts(a){const i={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[a],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getDynamicGlobalProperties(){const a={jsonrpc:"2.0",method:"condenser_api.get_dynamic_global_properties",params:[],id:1},i=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return(await i.json()).result}async convertVestingSharesToHive(a){try{const i=await this.getDynamicGlobalProperties(),s=parseFloat(a.split(" ")[0]),r=parseFloat(i.total_vesting_shares.split(" ")[0]),n=parseFloat(i.total_vesting_fund_hive.split(" ")[0]);return(s*n/r).toFixed(3)}catch(i){return console.error("Error converting vesting shares:",i),"0"}}async getFeedHistory(){const a={jsonrpc:"2.0",method:"condenser_api.get_feed_history",params:[],id:1},i=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return(await i.json()).result}async getVoteValue(a,i=1e4){try{const s=await this.getAccounts([a]);if(s.length===0)throw new Error("Account not found!");const r=s[0],n=await this.getDynamicGlobalProperties(),u=await this.getFeedHistory(),c=parseFloat(r.vesting_shares)+parseFloat(r.received_vesting_shares)-parseFloat(r.delegated_vesting_shares)-parseFloat(r.vesting_withdraw_rate),d=Math.floor(Date.now()/1e3)-r.voting_manabar.last_update_time,f=c*1e6/4;let o=parseFloat(r.voting_manabar.current_mana.toString())+d*f/(300*60*24);o>f&&(o=f);const h=o*100/f,l=r.vesting_shares||"0 VESTS",p=parseFloat(l.toString().split(" ")[0]),x=n.total_vesting_shares||"0 VESTS",w=parseFloat(x.toString().split(" ")[0]),b=i/1e4,g=h*b/100,v=n.vote_power_reserve_rate*(300*60*24)/(3600*24),_=g*f/100,N=parseFloat(n.recent_claims||"0"),y=n.reward_balance||"0 HIVE",m=parseFloat(y.toString().split(" ")[0]),k=n.current_supply||"0 HIVE",j=parseFloat(k.toString().split(" ")[0]),A=n.current_sbd_supply||"0 HBD",D=parseFloat(A.toString().split(" ")[0]),C=m/N*(p/w)*(_/f)*j,O=u?.current_median_history;if(!O||!O.base)return"0.00";const L=parseFloat(O.base.toString().split(" ")[0]);return(C*L).toFixed(2)}catch(s){return console.error("Error calculating vote value:",s),"0.00"}}userAvatar(a){return`https://images.hive.blog/u/${a}/avatar`}}const be=new Tp,bc=({vestingShares:e})=>{const[a,i]=P.useState("...");return P.useEffect(()=>{(async()=>{try{const r=await be.convertVestingSharesToHive(e);i(r)}catch(r){console.error("Error calculating HP:",r);const n=parseFloat(e.split(" ")[0]);i((n/1e6).toFixed(3))}})()},[e]),t.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a," HP"]})},Op=({username:e,onClickAuthor:a,onClickAddRemoveFromLists:i,onClickFollow:s})=>{const[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState({}),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=P.useRef(null),g=async()=>{try{h(!0),p(null);const N=await be.getFollowers(e);if(n(N),N.length>0){const y=N.map(A=>A.follower),m=await be.getAccounts(y);c(m);const k={},j={};for(const A of N)try{const D=await be.getVoteValue(A.follower);j[A.follower]=D}catch(D){console.warn(`Failed to get voting data for ${A.follower}:`,D),k[A.follower]={upvotepower:"0",downvote:"0"},j[A.follower]="0.00"}f(j)}}catch(N){p(N instanceof Error?N.message:"Failed to load followers data")}finally{h(!1)}};P.useEffect(()=>{g()},[e]),P.useEffect(()=>{const N=y=>{b.current&&!b.current.contains(y.target)&&w(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]);const v=N=>{const y=u.find(m=>m.name===N);if(!y)return null;try{return JSON.parse(y.posting_json_metadata)?.profile||{}}catch{return{}}},_=N=>{const y=new Date,m=new Date(N),k=y.getTime()-m.getTime(),j=Math.floor(k/(1e3*60*60*24));if(Math.floor(j/30)>=1)return m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});const D=Math.floor(k/1e3),C=Math.floor(D/60),O=Math.floor(C/60),L=Math.floor(j/7),H=Math.floor(j/365);return H>0?`${H} year${H>1?"s":""} ago`:L>0?`${L} week${L>1?"s":""} ago`:j>0?`${j} day${j>1?"s":""} ago`:O>0?`${O} hour${O>1?"s":""} ago`:C>0?`${C} minute${C>1?"s":""} ago`:"Just now"};return o?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading followers..."]})}):l?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load followers"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),t.jsxs("button",{onClick:g,className:"m-2 inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):r.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user has no followers."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"hidden md:block overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Avatar"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Username"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Last Post"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"HP"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Vote Value"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Manage"})]})}),t.jsx("tbody",{children:r.map((N,y)=>{const m=u.find(j=>j.name===N.follower),k=v(N.follower);return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[t.jsx("td",{className:"py-4 px-4",children:t.jsx("img",{src:k?.profile_image||be.userAvatar(N.follower),alt:N.follower,className:"w-12 h-12 rounded-full object-cover cursor-pointer",onClick:()=>a&&a(N.follower),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.follower}&background=random`}})}),t.jsxs("td",{className:"py-4 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>a&&a(N.follower),children:["@",N.follower]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),k?.about&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1 truncate max-w-xs",children:k.about})]}),t.jsx("td",{className:"py-4 px-4",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:_(m.last_root_post)}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"Never"})}),t.jsx("td",{className:"py-4 px-4",children:m?t.jsx(bc,{vestingShares:m.vesting_shares}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:d[N.follower]?t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["$",d[N.follower]]}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:t.jsxs("div",{className:"relative",ref:x===N.follower?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.follower?null:N.follower),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),x===N.follower&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.follower),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-4 h-4"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.follower),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-4 h-4"}),"Follow"]})]})]})})]},`${N.follower}-${y}`)})})]})}),t.jsx("div",{className:"md:hidden space-y-4",children:r.map((N,y)=>{const m=u.find(j=>j.name===N.follower),k=v(N.follower);return t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:k?.profile_image||be.userAvatar(N.follower),alt:N.follower,className:"w-10 h-10 rounded-full object-cover cursor-pointer flex-shrink-0",onClick:()=>a&&a(N.follower),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.follower}&background=random`}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 text-sm",onClick:()=>a&&a(N.follower),children:["@",N.follower]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?_(m.last_root_post):t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Never"})})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsx("div",{className:"flex items-center gap-4",children:m&&t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:t.jsx(bc,{vestingShares:m.vesting_shares})})}),t.jsxs("div",{className:"relative",ref:x===N.follower?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.follower?null:N.follower),className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),x===N.follower&&t.jsxs("div",{className:"absolute right-0 mt-1 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.follower),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-3 h-3"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.follower),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-3 h-3"}),"Follow"]})]})]})]})]})]})},`${N.follower}-${y}`)})})]})},xc=({vestingShares:e})=>{const[a,i]=P.useState("...");return P.useEffect(()=>{(async()=>{try{const r=await be.convertVestingSharesToHive(e);i(r)}catch(r){console.error("Error calculating HP:",r);const n=parseFloat(e.split(" ")[0]);i((n/1e6).toFixed(3))}})()},[e]),t.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a," HP"]})},Pp=({username:e,onClickAuthor:a,onClickAddRemoveFromLists:i,onClickUnfollow:s})=>{const[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState({}),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=P.useRef(null),g=async()=>{try{h(!0),p(null);const N=await be.getFollowing(e);if(n(N),N.length>0){const y=N.map(j=>j.following),m=await be.getAccounts(y);c(m);const k={};for(const j of N)try{const A=await be.getVoteValue(j.following);k[j.following]=A}catch(A){console.warn(`Failed to get voting data for ${j.following}:`,A),k[j.following]="0.00"}f(k)}}catch(N){p(N instanceof Error?N.message:"Failed to load following data")}finally{h(!1)}};P.useEffect(()=>{g()},[e]),P.useEffect(()=>{const N=y=>{b.current&&!b.current.contains(y.target)&&w(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]);const v=N=>{const y=u.find(m=>m.name===N);if(!y)return null;try{return JSON.parse(y.posting_json_metadata)?.profile||{}}catch{return{}}},_=N=>{const y=new Date,m=new Date(N),k=y.getTime()-m.getTime(),j=Math.floor(k/(1e3*60*60*24));if(Math.floor(j/30)>=1)return m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});const D=Math.floor(k/1e3),C=Math.floor(D/60),O=Math.floor(C/60),L=Math.floor(j/7),H=Math.floor(j/365);return H>0?`${H} year${H>1?"s":""} ago`:L>0?`${L} week${L>1?"s":""} ago`:j>0?`${j} day${j>1?"s":""} ago`:O>0?`${O} hour${O>1?"s":""} ago`:C>0?`${C} minute${C>1?"s":""} ago`:"Just now"};return o?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading following..."]})}):l?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load following"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),t.jsxs("button",{onClick:g,className:"m-2 inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):r.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user is not following anyone."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"hidden md:block overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Avatar"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Username"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Last Post"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"HP"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Vote Value"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Manage"})]})}),t.jsx("tbody",{children:r.map((N,y)=>{const m=u.find(j=>j.name===N.following),k=v(N.following);return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[t.jsx("td",{className:"py-4 px-4",children:t.jsx("img",{src:k?.profile_image||be.userAvatar(N.following),alt:N.following,className:"w-12 h-12 rounded-full object-cover cursor-pointer",onClick:()=>a&&a(N.following),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.following}&background=random`}})}),t.jsxs("td",{className:"py-4 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>a&&a(N.following),children:["@",N.following]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),k?.about&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1 truncate max-w-xs",children:k.about})]}),t.jsx("td",{className:"py-4 px-4",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:_(m.last_root_post)}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"Never"})}),t.jsx("td",{className:"py-4 px-4",children:m?t.jsx(xc,{vestingShares:m.vesting_shares}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:d[N.following]?t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["$",d[N.following]]}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:t.jsxs("div",{className:"relative",ref:x===N.following?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.following?null:N.following),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),x===N.following&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.following),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-4 h-4"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.following),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-4 h-4"}),"Unfollow"]})]})]})})]},`${N.following}-${y}`)})})]})}),t.jsx("div",{className:"md:hidden space-y-4",children:r.map((N,y)=>{const m=u.find(j=>j.name===N.following),k=v(N.following);return t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:k?.profile_image||be.userAvatar(N.following),alt:N.following,className:"w-10 h-10 rounded-full object-cover cursor-pointer flex-shrink-0",onClick:()=>a&&a(N.following),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.following}&background=random`}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 text-sm",onClick:()=>a&&a(N.following),children:["@",N.following]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?_(m.last_root_post):t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Never"})})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsx("div",{className:"flex items-center gap-4",children:m&&t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:t.jsx(xc,{vestingShares:m.vesting_shares})})}),t.jsxs("div",{className:"relative",ref:x===N.following?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.following?null:N.following),className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),x===N.following&&t.jsxs("div",{className:"absolute right-0 mt-1 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.following),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-3 h-3"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.following),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-3 h-3"}),"Unfollow"]})]})]})]})]})]})},`${N.following}-${y}`)})})]})},yc=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class $p{async getAccountHistory(a,i=-1,s=1e3,r,n){try{const u=[a,i,s];return r!==void 0&&n!==void 0&&u.push(r,n),(await yc.call("condenser_api","get_account_history",u)).map(([d,f])=>({index:d,block:f.block,op:{type:f.op[0],value:f.op[1]},op_in_trx:f.op_in_trx,timestamp:f.timestamp,trx_id:f.trx_id,trx_in_block:f.trx_in_block,virtual_op:f.virtual_op}))}catch(u){return console.error("Error fetching account history:",u),[]}}async getNextAccountHistoryPage(a,i,s=1e3){try{const r=i-1;return(await yc.call("condenser_api","get_account_history",[a,r,s])).map(([c,d])=>({index:c,block:d.block,op:{type:d.op[0],value:d.op[1]},op_in_trx:d.op_in_trx,timestamp:d.timestamp,trx_id:d.trx_id,trx_in_block:d.trx_in_block,virtual_op:d.virtual_op})).filter(c=>c.index<i)}catch(r){return console.error("Error fetching next page of account history:",r),[]}}convertToActivityListItems(a,i){return a.filter(s=>{const r=s.op.type;return r!=="effective_comment_vote"&&r!=="witness_set_properties"&&r!=="producer_reward"&&r!=="comment_reward"&&r!=="comment_payout_update"&&r!=="claim_reward_balance"&&r!=="transfer"&&r!=="claim_account"&&r!=="transfer_to_vesting"&&r!=="transfer_to_vesting_completed"}).map(s=>{const r=this.parseOperation(s,i);return{id:`${s.index}-${s.trx_id}`,type:r.type,direction:r.direction,timestamp:s.timestamp,block:s.block,description:r.description,details:s.op.value,index:s.index,...r.extraFields}}).filter(s=>s!==null)}parseOperation(a,i){const{op:s}=a,r=s.type,n=s.value;switch(r){case"vote":return this.parseVoteOperation(n,i);case"comment":return this.parseCommentOperation(n,i);case"custom_json":return this.parseCustomJsonOperation(n,i);case"comment_options":return this.parseCommentOptionsOperation(n,i);case"effective_comment_vote":return this.parseEffectiveCommentVoteOperation(n,i);case"curation_reward":return this.parseCurationRewardOperation(n,i);case"author_reward":return this.parseAuthorRewardOperation(n,i);case"comment_benefactor_reward":return this.parseCommentBenefactorRewardOperation(n,i);default:return{type:"other",direction:"out",description:`${r} operation`,extraFields:{}}}}parseVoteOperation(a,i){const{voter:s,author:r,permlink:n,weight:u}=a,c=r===i,d=c?"in":"out",f=(u/100).toFixed(0);let o="";return c?o=`${s} voted ${r}/${n} with ${f}%`:o=`Voted ${r}/${n} with ${f}%`,{type:"vote",direction:d,description:o,extraFields:{voter:s,author:r,permlink:n,weight:parseInt(f)}}}parseCommentOperation(a,i){const{author:s,parent_author:r,parent_permlink:n,permlink:u}=a,d=r===i?"in":"out",o=`Commented on ${n} by ${r||s}.`;return{type:"comment",direction:d,description:o,extraFields:{author:s,permlink:u,parent_author:r,parent_permlink:n}}}parseCustomJsonOperation(a,i){const{id:s,json:r,required_auths:n,required_posting_auths:u}=a;let c={};try{c=JSON.parse(r)}catch{}let d="Custom Json";if(s==="follow"){const[f,o]=c;f==="follow"&&(d="Custom Json")}return{type:"custom_json",direction:"out",description:d,extraFields:{}}}parseCommentOptionsOperation(a,i){const{author:s,permlink:r,max_accepted_payout:n}=a;return{type:"comment_options",direction:"out",description:"Comment Payout Update",extraFields:{author:s,permlink:r,payout:n}}}parseEffectiveCommentVoteOperation(a,i){const{voter:s,author:r,permlink:n,pending_payout:u}=a,c=r===i,d=c?"in":"out",f=c?`${s} voted on ${r}/${n} (effective vote)`:`Effective vote on ${r}/${n}`;return{type:"effective_comment_vote",direction:d,description:f,extraFields:{voter:s,author:r,permlink:n,payout:u}}}parseCurationRewardOperation(a,i){const{author:s,curator:r,permlink:n,reward:u}=a,d=r===i?"in":"out",h=`${(parseFloat(u.split(" ")[0])*1e-6).toFixed(3)} HP`,l=`Curation reward for ${r}/${n} by ${s}`;return{type:"curation_reward",direction:d,description:l,extraFields:{author:s,curator:r,permlink:n,reward:h}}}parseAuthorRewardOperation(a,i){const{author:s,permlink:r,hbd_payout:n,hive_payout:u,vesting_payout:c}=a,f=s===i?"in":"out",h=(parseFloat(c.split(" ")[0])*1e-6).toFixed(3),l=n.split(" ")[0],p=u.split(" ")[0],x=`Author reward: ${l} HBD, ${p} HIVE, ${h} HP for ${r}`;return{type:"author_reward",direction:f,description:x,extraFields:{author:s,permlink:r,hbd_payout:n,hive_payout:u,vesting_payout:c}}}parseCommentBenefactorRewardOperation(a,i){const{author:s,benefactor:r,permlink:n,hbd_payout:u,hive_payout:c,vesting_payout:d}=a,o=r===i?"in":"out",l=(parseFloat(d.split(" ")[0])*1e-6).toFixed(3),p=u.split(" ")[0],x=c.split(" ")[0],w=`Benefactor reward on ${n} by ${s}: ${p} HBD, ${x} HIVE, ${l} HP`;return{type:"comment_benefactor_reward",direction:o,description:w,extraFields:{author:s,benefactor:r,permlink:n,hbd_payout:u,hive_payout:c,vesting_payout:d}}}filterByDirection(a,i){return i==="all"?a:a.filter(s=>s.direction===i)}filterByGeneralType(a,i){if(i==="all")return a;switch(i){case"votes":return a.filter(s=>s.type==="vote"||s.type==="effective_comment_vote");case"comments":return a.filter(s=>s.type==="comment");case"replies":return a.filter(s=>s.type==="comment"&&s.direction==="in");case"others":return a.filter(s=>s.type==="custom_json"||s.type==="comment_options"||s.type==="other");default:return a}}filterByRewardType(a,i){if(i==="all")return a;switch(i){case"author":return a.filter(s=>s.type==="effective_comment_vote"&&s.direction==="in");case"curation":return a.filter(s=>s.type==="effective_comment_vote"&&s.direction==="out");case"benefactor":return a.filter(s=>s.type==="comment_options"&&s.details?.beneficiaries);default:return a}}searchActivities(a,i){if(!i.trim())return a;const s=i.toLowerCase();return a.filter(r=>r.description.toLowerCase().includes(s)||r.author?.toLowerCase().includes(s)||r.permlink?.toLowerCase().includes(s)||r.voter?.toLowerCase().includes(s))}getRelativeTime(a){try{const i=new Date(a),r=new Date().getTime()-i.getTime(),n=Math.floor(r/1e3),u=Math.floor(n/60),c=Math.floor(u/60),d=Math.floor(c/24);return n<60?`${n} seconds ago`:u<60?`${u} minutes ago`:c<24?`${c} hours ago`:d<7?`${d} days ago`:i.toLocaleDateString()}catch(i){return console.error("Error calculating relative time:",i),a}}}const ra=new $p,Lp=({username:e,directionFilter:a="all",generalFilter:i="all",rewardFilter:s="all",searchTerm:r="",limit:n=1e3,className:u,onClickPermlink:c,onSelectActivity:d})=>{const[f,o]=P.useState(r),[h,l]=P.useState(a),[p,x]=P.useState(i),[w,b]=P.useState(s),[g,v]=P.useState([]),[_,N]=P.useState([]),[y,m]=P.useState(!1),[k,j]=P.useState(null),[A,D]=P.useState(new Set),[C,O]=P.useState(null),[L,H]=P.useState(!0),[F,B]=P.useState(!1),[$,G]=P.useState(-1),X=P.useRef(null),ee=async(V=!1)=>{if(e){V?B(!0):(m(!0),H(!0),G(-1)),j(null);try{let J;V?J=await ra.getNextAccountHistoryPage(e,$,n):J=await ra.getAccountHistory(e,-1,n);const oe=ra.convertToActivityListItems(J,e);if(oe.sort((K,te)=>new Date(te.timestamp).getTime()-new Date(K.timestamp).getTime()),v(V?K=>[...K,...oe]:oe),J.length>0){const K=Math.min(...J.map(te=>te.index));G(K)}oe.length===0&&H(!1)}catch(J){j("Failed to load activity history"),console.error("Error loading activities:",J),H(!1)}finally{m(!1),B(!1)}}};P.useEffect(()=>{ee()},[e,n]);const R=P.useCallback(()=>{L&&!y&&!F&&ee(!0)},[L,y,F]);P.useEffect(()=>{let V=g;h!=="all"?V=V.filter(J=>J.direction===h):V=V.filter(J=>J.type!=="custom_json"&&J.type!=="comment_options"),p!=="all"&&(p==="votes"?V=V.filter(J=>J.type==="vote"||J.type==="effective_comment_vote"):p==="comments"?V=V.filter(J=>J.type==="comment"):p==="replies"?V=V.filter(J=>J.type==="comment"&&J.direction==="in"):p==="curation"?V=V.filter(J=>J.type==="curation_reward"):p==="others"&&(V=g.filter(J=>J.type==="custom_json"||J.type==="comment_options"))),w!=="all"&&(w==="author"?V=V.filter(J=>J.type==="effective_comment_vote"&&J.direction==="in"):w==="curation"?V=V.filter(J=>J.type==="effective_comment_vote"&&J.direction==="out"):w==="benefactor"&&(V=V.filter(J=>J.type==="comment_options"))),f&&(V=V.filter(J=>J.description.toLowerCase().includes(f.toLowerCase())||J.author?.toLowerCase().includes(f.toLowerCase())||J.permlink?.toLowerCase().includes(f.toLowerCase()))),N(V)},[g,h,p,w,f]),P.useEffect(()=>{const V=J=>{X.current&&!X.current.contains(J.target)&&O(null)};return document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[]);const se=V=>{switch(V.type){case"vote":case"effective_comment_vote":return t.jsx(z.Wallet,{className:"h-4 w-4"});case"comment":return t.jsx(z.MessageCircle,{className:"h-4 w-4"});case"custom_json":return t.jsx(z.FileText,{className:"h-4 w-4"});case"curation_reward":return t.jsx(z.Wallet,{className:"h-4 w-4"});case"author_reward":return t.jsx(z.DollarSign,{className:"h-4 w-4"});case"comment_benefactor_reward":return t.jsx(z.User,{className:"h-4 w-4"});default:return t.jsx(z.Eye,{className:"h-4 w-4"})}},I=(V,J)=>V.split(/(\s+)/).map((K,te)=>{if(K.includes("/")){const[pe,Ee]=K.split("/");if(pe&&Ee)return t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:Z=>{Z.stopPropagation(),console.log("Clicked permlink:",pe,Ee),c?.(pe,Ee)},children:K},te)}return t.jsx("span",{children:K},te)});return y?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-start lg:items-center justify-between",children:[t.jsx("div",{className:"flex-1 max-w-md",children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),t.jsx("div",{className:"w-full h-10 bg-gray-200 dark:bg-gray-700 rounded-md animate-pulse"})]})}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from({length:5}).map((V,J)=>t.jsx("div",{className:"w-24 h-10 bg-gray-200 dark:bg-gray-700 rounded-md animate-pulse"},J))})]}),t.jsx("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:Array.from({length:4}).map((V,J)=>t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-20"},J))})]}),t.jsx("div",{className:"space-y-4",children:Array.from({length:5}).map((V,J)=>t.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx("div",{className:"w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded-full animate-pulse flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0 space-y-2",children:t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/4"})})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-4",children:[t.jsx("div",{className:"w-3 h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-16"})]})]},J))})]}):k?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load activities"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:k}),t.jsxs("button",{onClick:()=>ee(),className:"inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-start lg:items-center justify-between",children:[t.jsx("div",{className:"flex-1 max-w-md",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search activities...",value:f,onChange:V=>o(V.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("select",{value:h,onChange:V=>l(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Directions"}),t.jsx("option",{value:"in",children:"Incoming"}),t.jsx("option",{value:"out",children:"Outgoing"})]}),t.jsxs("select",{value:p,onChange:V=>x(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Types"}),t.jsx("option",{value:"votes",children:"Votes"}),t.jsx("option",{value:"comments",children:"Comments"}),t.jsx("option",{value:"replies",children:"Replies"}),t.jsx("option",{value:"curation",children:"Curation"}),t.jsx("option",{value:"others",children:"Others"})]}),t.jsxs("select",{value:w,onChange:V=>b(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Rewards"}),t.jsx("option",{value:"author",children:"Author"}),t.jsx("option",{value:"curation",children:"Curation"}),t.jsx("option",{value:"benefactor",children:"Benefactor"})]}),t.jsx("button",{onClick:()=>ee(),disabled:y||F,className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Total: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:g.length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Filtered: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:_.length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Incoming: ",t.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:g.filter(V=>V.direction==="in").length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Outgoing: ",t.jsx("span",{className:"font-semibold text-blue-600 dark:text-blue-400",children:g.filter(V=>V.direction==="out").length})]})]})]}),t.jsx("div",{className:"space-y-4",children:_.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[200px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:g.length===0?"No activities found for this user.":"No activities match the current filters."})}):t.jsxs(t.Fragment,{children:[_.map((V,J)=>t.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors cursor-pointer",onClick:oe=>{d?.(V)},children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[V.type==="vote"&&V.voter?t.jsx("img",{src:`https://images.hive.blog/u/${V.voter}/avatar`,alt:V.voter,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):V.type==="comment_benefactor_reward"&&V.author?t.jsx("img",{src:`https://images.hive.blog/u/${V.author}/avatar`,alt:V.author,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):V.type==="comment"&&V.author?t.jsx("img",{src:`https://images.hive.blog/u/${V.author}/avatar`,alt:V.author,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):null,t.jsx("div",{className:`w-8 h-8 bg-purple-100 dark:bg-purple-900/20 rounded-full flex items-center justify-center flex-shrink-0 ${V.type==="vote"&&V.voter||V.type==="comment_benefactor_reward"&&V.author||V.type==="comment"&&V.author?"hidden":""}`,children:se(V)}),t.jsx("div",{className:"flex-1 min-w-0",children:V.type==="custom_json"||V.type==="comment_options"?t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words font-medium",children:I(V.description)}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:ra.getRelativeTime(V.timestamp+"Z")}),t.jsx("div",{className:"border border-gray-200 dark:border-gray-600 rounded p-2 bg-gray-50 dark:bg-gray-700/50 mt-1",children:t.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400 space-y-1 font-mono break-words",children:[V.type==="custom_json"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"id:"})," ",V.details.id]}),t.jsxs("div",{className:"break-all",children:[t.jsx("span",{className:"font-medium",children:"json:"})," ",JSON.stringify(V.details.json).replace(/\\\"/g,'"').replace(/^"|"$/g,"")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"required_auths:"})," ",JSON.stringify(V.details.required_auths)]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"required_posting_auths:"})," ",JSON.stringify(V.details.required_posting_auths)]})]}),V.type==="comment_options"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"author:"}),t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",children:V.details.author})]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"permlink:"}),t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:oe=>{oe.stopPropagation(),console.log("Clicked permlink:",V.details.author,V.details.permlink),c?.(V.details.author,V.details.permlink)},children:V.details.permlink})]})]})]})})]}):t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words",children:I(V.description)}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 sm:hidden",children:ra.getRelativeTime(V.timestamp+"Z")})]})})]}),t.jsx("div",{className:"flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 flex-shrink-0 ml-4 hidden sm:flex",children:V.type!=="custom_json"&&V.type!=="comment_options"&&t.jsxs(t.Fragment,{children:[t.jsx(z.Clock,{className:"h-3 w-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:ra.getRelativeTime(V.timestamp+"Z")})]})})]},`${V.id}-${J}`)),L&&g.length>0&&t.jsx("div",{className:"flex justify-center py-6",children:t.jsx("button",{onClick:R,disabled:y||F,className:"px-6 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white rounded-lg font-medium transition-colors disabled:cursor-not-allowed flex items-center gap-2",children:F?t.jsxs(t.Fragment,{children:[t.jsx(z.RefreshCw,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):"Load More Activities"})}),!L&&g.length>0&&t.jsx("div",{className:"text-center text-sm text-gray-400 py-4",children:"No more activities to load"})]})})]})},Gn=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Mp{async getWitnessesByVote(a="",i=60){try{return await Gn.call("condenser_api","get_witnesses_by_vote",[a,i])}catch(s){throw console.error("Error fetching witnesses by vote:",s),s}}async getAccount(a){try{const i=await Gn.call("condenser_api","get_accounts",[[a]]);return i&&i.length>0?i[0]:null}catch(i){return console.error("Error fetching account:",i),null}}async getAccounts(a){try{return await Gn.call("condenser_api","get_accounts",[a])}catch(i){return console.error("Error fetching accounts:",i),[]}}async getWitnessVotes(a,i="",s=250){try{return await Gn.call("database_api","list_witness_votes",{start:[a,i],limit:s,order:"by_witness_account"})}catch(r){throw console.error("Error fetching witness votes:",r),r}}async getAllWitnessVotes(a){const i=[];let s="";try{for(;;){const n=await this.getWitnessVotes(a,s,250);if(i.push(...n.votes),n.votes.length<250)break;s=n.votes[n.votes.length-1].account}return i}catch(n){return console.error("Error fetching all witness votes:",n),[]}}async hasUserVotedForWitness(a,i){try{const s=await this.getAccount(a);return!s||!s.witness_votes?!1:s.witness_votes.includes(i)}catch(s){return console.error("Error checking witness vote:",s),!1}}async getUserWitnessVotes(a){try{return(await this.getAccount(a))?.witness_votes||[]}catch(i){return console.error("Error fetching user witness votes:",i),[]}}formatVotesToMHP(a){return`${(parseFloat(a)/1e6).toFixed(1)}m`}calculateAPR(a){return a/100}getVersionStatus(a,i){const s=this.parseVersion(a),r=this.parseVersion(i);return this.compareVersions(s,r)>=0?"green":this.compareVersions(s,r)<0?"red":"grey"}parseVersion(a){return a.split(".").map(i=>parseInt(i,10))}compareVersions(a,i){const s=Math.max(a.length,i.length);for(let r=0;r<s;r++){const n=a[r]||0,u=i[r]||0;if(n>u)return 1;if(n<u)return-1}return 0}getWitnessDescription(a){try{let i;if(a.json_metadata&&a.json_metadata!=="{}"){i=JSON.parse(a.json_metadata);const s=i.profile?.witness_description;if(s)return s}return a.posting_json_metadata&&a.posting_json_metadata!=="{}"?(i=JSON.parse(a.posting_json_metadata),i.profile?.about||""):""}catch(i){return console.error("Error parsing witness description:",i),""}}formatTimeAgo(a){const i=new Date(a),r=Math.floor((new Date().getTime()-i.getTime())/1e3);if(r<60)return`${r} second${r>1?"s":""} ago`;if(r<3600){const n=Math.floor(r/60);return`${n} minute${n>1?"s":""} ago`}else if(r<86400){const n=Math.floor(r/3600);return`${n} hour${n>1?"s":""} ago`}else if(r<604800){const n=Math.floor(r/86400);return`${n} day${n>1?"s":""} ago`}else if(r<2592e3){const n=Math.floor(r/604800);return`${n} week${n>1?"s":""} ago`}else if(r<31536e3){const n=Math.floor(r/2592e3);return`${n} month${n>1?"s":""} ago`}else{const n=Math.floor(r/31536e3);return`${n} year${n>1?"s":""} ago`}}}const ct=new Mp,Ue=_c.create((e,a)=>({witnesses:[],witnessVotes:[],userWitnessVotes:[],witnessDetails:new Map,witnessAccounts:new Map,loadingWitnesses:!1,loadingMoreWitnesses:!1,loadingVotes:!1,loadingMoreVotes:!1,loadingUserVotes:!1,error:null,nextWitnessStart:"",nextVotesStart:"",hasMoreWitnesses:!0,hasMoreVotes:!1,selectedWitness:null,filters:{status:"all",name:"",version:""},loadWitnesses:async(i="",s=50)=>{const{witnesses:r}=a();if(r.length>=500){e({hasMoreWitnesses:!1});return}e(i!==""?{loadingMoreWitnesses:!0}:{loadingWitnesses:!0,error:null});try{const u=await ct.getWitnessesByVote(i,s);e(d=>{const f=new Set(d.witnesses.map(h=>h.owner)),o=u.filter(h=>!f.has(h.owner));return{witnesses:[...d.witnesses,...o],nextWitnessStart:u.length>0?u[u.length-1].owner:"",hasMoreWitnesses:u.length===s}});const c=u.filter(d=>!a().witnessDetails.has(d.owner)).map(d=>d.owner);c.length>0&&a().loadWitnessDetails(c)}catch(u){console.error("Error loading witnesses:",u),e({error:"Failed to load witnesses data"})}finally{e({loadingWitnesses:!1,loadingMoreWitnesses:!1})}},loadMoreWitnesses:async()=>{const{nextWitnessStart:i,hasMoreWitnesses:s,loadingMoreWitnesses:r}=a();!s||r||!i||await a().loadWitnesses(i,50)},loadWitnessVotes:async i=>{e({loadingVotes:!0,witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:i});try{const s=await ct.getWitnessVotes(i,"",250);e({witnessVotes:s.votes,nextVotesStart:s.votes.length>0?s.votes[s.votes.length-1].account:"",hasMoreVotes:s.votes.length===250,loadingVotes:!1})}catch(s){console.error("Error loading witness votes:",s),e({error:"Failed to load witness votes",loadingVotes:!1})}},loadMoreVotes:async()=>{const{hasMoreVotes:i,loadingMoreVotes:s,nextVotesStart:r,selectedWitness:n,witnessVotes:u}=a();if(!i||s||!r||u.length>=1e3){u.length>=1e3&&e({hasMoreVotes:!1});return}e({loadingMoreVotes:!0});try{const c=await ct.getWitnessVotes(n||"",r,250);e(d=>{const o=[...d.witnessVotes,...c.votes].filter((l,p,x)=>x.findIndex(w=>w.account===l.account)===p),h=c.votes.filter((l,p,x)=>x.findIndex(w=>w.account===l.account)===p);return{witnessVotes:o,nextVotesStart:h.length>0?h[h.length-1].account:"",hasMoreVotes:c.votes.length===250}})}catch(c){console.error("Error loading more witness votes:",c)}finally{e({loadingMoreVotes:!1})}},loadUserWitnessVotes:async i=>{if(i){e({loadingUserVotes:!0});try{const s=await ct.getUserWitnessVotes(i);e({userWitnessVotes:s})}catch(s){console.error("Error loading user witness votes:",s)}finally{e({loadingUserVotes:!1})}}},loadWitnessDetails:async i=>{try{const s=await ct.getAccounts(i);e(r=>{const n=new Map(r.witnessDetails),u=new Map(r.witnessAccounts);return s.forEach(c=>{const d=ct.getWitnessDescription(c);d&&n.set(c.name,d),u.set(c.name,c)}),{witnessDetails:n,witnessAccounts:u}})}catch(s){console.error("Error loading witness details:",s)}},setFilters:i=>e({filters:i}),setSelectedWitness:i=>e({selectedWitness:i}),clearVotes:()=>e({witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:null})})),vc=({filters:e,onFiltersChange:a,theme:i="dark"})=>{const s=i==="dark"?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-800",r=c=>{const d=e.status===c?"all":c;a({...e,status:d})},n=c=>{a({...e,name:c})},u=c=>{a({...e,version:c})};return t.jsxs("div",{className:`rounded-lg p-4 mb-6 border ${i==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsx("h3",{className:`text-lg font-semibold mb-4 ${i==="dark"?"text-white":"text-gray-900"}`,children:"FILTERS"}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"WITNESS"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="active",onChange:()=>r("active"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Active"})]}),t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="disabled",onChange:()=>r("disabled"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Disabled/Stale"})]}),t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="approved",onChange:()=>r("approved"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Approved"})]}),e.status!=="all"&&t.jsx("button",{onClick:()=>a({...e,status:"all"}),className:`text-sm underline ${s}`,children:"Clear Status Filter"})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"NAME"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:`w-4 h-4 ${i==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:"Search",value:e.name,onChange:c=>n(c.target.value),className:`w-full pl-10 pr-4 py-2 border-b focus:outline-none focus:border-blue-500 ${i==="dark"?"bg-slate-900 border-gray-700 text-white placeholder-gray-400":"bg-gray-50 border-gray-300 text-gray-900 placeholder-gray-500"}`})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"VERSION"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:`w-4 h-4 ${i==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:"Version",value:e.version,onChange:c=>u(c.target.value),className:`w-full pl-10 pr-4 py-2 border-b focus:outline-none focus:border-blue-500 ${i==="dark"?"bg-slate-900 border-gray-700 text-white placeholder-gray-400":"bg-gray-50 border-gray-300 text-gray-900 placeholder-gray-500"}`})]})]})]})},Ci=768;function Ed(){const[e,a]=Qn.useState(void 0);return Qn.useEffect(()=>{const i=window.matchMedia(`(max-width: ${Ci-1}px)`),s=()=>{a(window.innerWidth<Ci)};return i.addEventListener("change",s),a(window.innerWidth<Ci),()=>i.removeEventListener("change",s)},[]),!!e}const Rp=({isOpen:e,onClose:a,witness:i,votes:s,loadingMore:r,hasMore:n,loadingInitial:u,scrollContainerRef:c,sentinelRef:d,loadMoreVotes:f,theme:o="dark"})=>{const h=P.useCallback(l=>{l[0].isIntersecting&&n&&!r&&f()},[n,r,f]);return P.useEffect(()=>{const l=new IntersectionObserver(h,{threshold:.1,root:c.current});return d.current&&l.observe(d.current),()=>{d.current&&l.unobserve(d.current)}},[h,c,d]),e?t.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:`rounded-lg max-w-2xl w-full max-h-[80vh] overflow-hidden border ${o==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${o==="dark"?"border-gray-800":"border-gray-200"}`,children:[t.jsxs("h3",{className:`text-lg font-semibold ${o==="dark"?"text-white":"text-gray-900"}`,children:["Votes for @",i," (showing ",s.length,")"]}),t.jsx("button",{onClick:a,className:`text-xl font-bold ${o==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:"×"})]}),t.jsxs("div",{ref:c,className:"p-4 overflow-y-auto max-h-[60vh]",children:[t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.map((l,p)=>t.jsxs("div",{className:`flex items-center space-x-3 p-3 rounded-lg border ${o==="dark"?"bg-gray-800 border-gray-800":"bg-gray-50 border-gray-200"}`,children:[t.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${o==="dark"?"bg-gray-600 text-white":"bg-gray-200 text-gray-900"}`,children:t.jsx("img",{className:"w-8 h-8 rounded-full",src:`https://images.hive.blog/u/${l.account}/avatar`,alt:l.account,onError:x=>{x.target.src="https://images.hive.blog/u/null/avatar"}})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:`font-medium ${o==="dark"?"text-white":"text-gray-900"}`,children:l.account}),t.jsxs("div",{className:`text-sm ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:["Vote #",p+1]})]}),t.jsx("div",{className:`text-sm ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"25"})]},l.account))}),s.length===0&&!u&&t.jsx("div",{className:`text-center py-8 ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"No votes found for this witness."}),r&&t.jsx("div",{className:`text-center py-4 ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more votes..."}),n&&!r&&t.jsx("div",{className:"text-center py-4",children:t.jsx("button",{onClick:f,className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded",children:"Load More Votes"})}),n&&t.jsx("div",{ref:d,className:"h-4"})]})]})}):null},Ip=({username:e,filters:a={status:"all",name:"",version:""},onWitnessVoteClick:i,onWitnessStatsClick:s,onWitnessUrlClick:r,theme:n="dark"})=>{const u=Ed(),c=Ue(I=>I.witnesses),d=Ue(I=>I.userWitnessVotes),f=Ue(I=>I.loadingWitnesses),o=Ue(I=>I.error),h=Ue(I=>I.selectedWitness),l=Ue(I=>I.witnessVotes),p=Ue(I=>I.hasMoreVotes),x=Ue(I=>I.loadingMoreVotes),w=Ue(I=>I.loadingVotes),b=Ue(I=>I.filters),g=Ue(I=>I.hasMoreWitnesses),v=Ue(I=>I.loadingWitnesses),_=Ue(I=>I.witnessDetails);Ue(I=>I.witnessAccounts);const N=Ue(I=>I.loadWitnesses),y=Ue(I=>I.loadMoreWitnesses),m=Ue(I=>I.loadWitnessVotes),k=Ue(I=>I.loadMoreVotes),j=Ue(I=>I.loadUserWitnessVotes),A=Ue(I=>I.setFilters),[D,C]=P.useState(!1),[O,L]=P.useState(!1),H=P.useRef(null),F=P.useRef(null),B=P.useRef(null),$=P.useCallback(I=>{I[0].isIntersecting&&g&&!v&&y()},[g,v,y]);P.useEffect(()=>{const I=new IntersectionObserver($,{threshold:.1});return B.current&&I.observe(B.current),()=>{B.current&&I.unobserve(B.current)}},[$]),P.useEffect(()=>{N()},[N]),P.useEffect(()=>{e&&j(e)},[e,j]),P.useEffect(()=>{A(a)},[]);const G=P.useMemo(()=>c.filter(I=>{if(b.status!=="all"){if(b.status==="active"){const V=new Date;if(V.setFullYear(V.getFullYear()-1),new Date(I.last_hbd_exchange_update+"Z")<=V)return!1}else if(b.status==="disabled"){const V=new Date;if(V.setFullYear(V.getFullYear()-1),new Date(I.last_hbd_exchange_update+"Z")>V)return!1}else if(b.status==="approved"&&!d.includes(I.owner))return!1}return!(b.name&&!I.owner.toLowerCase().includes(b.name.toLowerCase())||b.version&&!I.running_version.includes(b.version))}),[c,b,d]),X=async I=>{i?i(I):(await m(I),C(!0))},ee=I=>{s?s(I):window.open(`https://hivehub.dev/witnesses/@${I}`,"_blank")},R=I=>{r?r(I):window.open(I,"_blank")},se=I=>e?d.includes(I):!1;return f?t.jsx("div",{className:"flex items-center justify-center p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):o?t.jsx("div",{className:"text-center p-8 text-red-400",children:o}):t.jsxs("div",{className:"w-full",children:[t.jsx(Rp,{isOpen:D,onClose:()=>C(!1),witness:h||"",votes:l,loadingMore:x,hasMore:p,loadingInitial:w,scrollContainerRef:F,sentinelRef:H,loadMoreVotes:k,theme:n}),u?t.jsxs("div",{className:`w-full p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h2",{className:`text-lg font-semibold ${n==="dark"?"text-white":"text-gray-900"}`,children:"Witnesses"}),t.jsxs("button",{onClick:()=>L(!O),className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded flex items-center space-x-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),t.jsx("span",{children:O?"Hide Filters":"Show Filters"})]})]}),O&&t.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:`rounded-lg w-full max-w-md max-h-[80vh] overflow-hidden border ${n==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${n==="dark"?"border-gray-800":"border-gray-200"}`,children:[t.jsx("h3",{className:`text-lg font-semibold ${n==="dark"?"text-white":"text-gray-900"}`,children:"Filters"}),t.jsx("button",{onClick:()=>L(!1),className:`text-xl font-bold ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:"×"})]}),t.jsx("div",{className:"p-4 overflow-y-auto max-h-[60vh]",children:t.jsx(vc,{filters:b,onFiltersChange:A,theme:n})})]})}),t.jsxs("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:[G.map((I,V)=>{const J=ct.getVersionStatus(I.running_version,I.hardfork_version_vote),oe=se(I.owner),K=c.findIndex(te=>te.owner===I.owner)+1;return t.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${n==="dark"?"bg-slate-900 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("span",{className:`text-lg font-bold ${n==="dark"?"text-white":"text-gray-900"}`,children:["#",K]}),t.jsx("img",{className:"w-10 h-10 rounded-full",src:`https://images.hive.blog/u/${I.owner}/avatar`,alt:I.owner,onError:te=>{te.target.src="https://images.hive.blog/u/null/avatar"}}),t.jsxs("div",{children:[t.jsx("div",{className:`font-medium ${n==="dark"?"text-white":"text-gray-900"}`,children:I.owner}),t.jsxs("div",{className:`text-xs ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["Since ",new Date(I.created).getFullYear()]})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("svg",{className:`w-6 h-6 ${oe?"text-green-600":n==="dark"?"text-gray-500":"text-gray-400"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}),t.jsxs("div",{className:"flex space-x-1",children:[t.jsx("button",{onClick:()=>R(I.url),className:`${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"Visit witness URL",children:"🔗"}),t.jsx("button",{onClick:()=>ee(I.owner),className:`${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"View witness stats",children:"📊"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-3",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Version"}),t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium mt-1 block ${J==="green"?"bg-green-100 text-green-800":J==="red"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:I.running_version})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Votes (MHP)"}),t.jsx("button",{onClick:()=>X(I.owner),className:"text-blue-600 hover:text-blue-800 cursor-pointer text-sm font-medium mt-1",disabled:w,children:w&&h===I.owner?"Loading...":ct.formatVotesToMHP(I.votes)})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"APR"}),t.jsxs("div",{className:`font-medium mt-1 ${n==="dark"?"text-white":"text-gray-900"}`,children:[ct.calculateAPR(I.props.hbd_interest_rate),"%"]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-xs",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Last Block"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.last_confirmed_block_num.toLocaleString()})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Miss"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.total_missed.toLocaleString()})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Price Feed"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.hbd_exchange_rate.base}),t.jsx("div",{className:`${n==="dark"?"text-gray-400":"text-gray-500"}`,children:ct.formatTimeAgo(I.last_hbd_exchange_update+"Z")})]})]}),_.get(I.owner)&&t.jsx("div",{className:`mt-3 pt-3 border-t ${n==="dark"?"border-gray-800":"border-gray-200"}`,children:t.jsx("div",{className:`text-xs line-clamp-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:_.get(I.owner)})})]},I.owner)}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more witnesses..."})]}),g&&t.jsx("div",{ref:B,className:"h-1"})]})]}):t.jsx("div",{className:`max-w-7xl mx-auto p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:t.jsxs("div",{className:"grid grid-cols-5 gap-4",children:[t.jsx("div",{className:"col-span-1 sticky top-0 h-screen overflow-y-auto",children:t.jsx(vc,{filters:b,onFiltersChange:A,theme:n})}),t.jsxs("div",{className:"col-span-4 overflow-auto max-h-screen",children:[t.jsxs("table",{className:`w-full text-xs text-left ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("thead",{className:`text-xs uppercase ${n==="dark"?"text-gray-400 bg-slate-900":"text-gray-700 bg-gray-50"}`,children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Rank"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Witness"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Version"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Votes"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Last Block"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Miss"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Feed"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"APR"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Vote"})]})}),t.jsx("tbody",{children:G.map((I,V)=>{const J=ct.getVersionStatus(I.running_version,I.hardfork_version_vote),oe=se(I.owner);return t.jsxs("tr",{className:`border-b hover:bg-gray-50 ${n==="dark"?"border-gray-800 hover:bg-gray-800":"border-gray-200"}`,children:[t.jsx("td",{className:`px-2 py-2 font-medium text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:c.findIndex(K=>K.owner===I.owner)+1}),t.jsx("td",{className:"px-2 py-2",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("img",{className:"w-6 h-6 rounded-full",src:`https://images.hive.blog/u/${I.owner}/avatar`,alt:I.owner,onError:K=>{K.target.src="https://images.hive.blog/u/null/avatar"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`font-medium text-xs truncate ${n==="dark"?"text-white":"text-gray-900"}`,children:I.owner}),t.jsxs("div",{className:`text-xs ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["Since ",new Date(I.created).getFullYear()]})]}),t.jsxs("div",{className:"flex space-x-1 flex-shrink-0",children:[t.jsx("button",{onClick:()=>R(I.url),className:`text-xs ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"Visit witness URL",children:"🔗"}),t.jsx("button",{onClick:()=>ee(I.owner),className:`text-xs ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"View witness stats",children:"📊"})]})]})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("span",{className:`px-1 py-0.5 rounded text-xs font-medium ${J==="green"?"bg-green-100 text-green-800":J==="red"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:I.running_version})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("button",{onClick:()=>X(I.owner),className:"text-blue-600 hover:text-blue-800 cursor-pointer text-xs",disabled:w,children:w&&h===I.owner?"...":ct.formatVotesToMHP(I.votes)})}),t.jsx("td",{className:"px-2 py-2 text-right",children:t.jsx("div",{className:`text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:I.last_confirmed_block_num.toLocaleString()})}),t.jsx("td",{className:"px-2 py-2 text-right text-xs",children:t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.total_missed.toLocaleString()})}),t.jsx("td",{className:"px-2 py-2 text-right",children:t.jsx("div",{className:`text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:I.hbd_exchange_rate.base})}),t.jsx("td",{className:"px-2 py-2 text-right text-xs",children:t.jsxs("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:[ct.calculateAPR(I.props.hbd_interest_rate),"%"]})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("svg",{className:`w-4 h-4 ${oe?"text-green-600":n==="dark"?"text-gray-500":"text-gray-400"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})})]},I.owner)})})]}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more witnesses..."})]}),g&&t.jsx("div",{ref:B,className:"h-1"})]})]})})]})},Fp=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class qp{async getTransactionHistory(a,i=-1,s=1e3,r=null,n=null){try{const u=[a,i,s];r!==null&&n!==null&&u.push(r,n);const c=await Fp.call("condenser_api","get_account_history",u);return Array.isArray(c)?c.map(d=>Array.isArray(d)&&d.length>=2?d[1]:d):[]}catch(u){return console.error("Error in getTransactionHistory:",u),[]}}async getFilteredTransactionHistory(a,i=[],s=100){try{const r=await this.getTransactionHistory(a,-1,1e3);let n=r;return i.length>0&&(n=r.filter(u=>{const c=u.op?.[0];return i.includes(c)})),n.slice(0,s)}catch(r){return console.error("Error in getFilteredTransactionHistory:",r),[]}}async getRecentTransfers(a,i=50){return this.getFilteredTransactionHistory(a,["transfer"],i)}async getRecentVotes(a,i=50){return this.getFilteredTransactionHistory(a,["vote"],i)}async getRecentComments(a,i=50){return this.getFilteredTransactionHistory(a,["comment"],i)}parseOperation(a){try{if(!a.op||!Array.isArray(a.op)||a.op.length<2)return null;const[i,s]=a.op;switch(i){case"transfer":return{type:"transfer",value:{from:s.from||"",to:s.to||"",amount:s.amount||"",memo:s.memo||""}};case"vote":return{type:"vote",value:{voter:s.voter||"",author:s.author||"",permlink:s.permlink||"",weight:s.weight||0}};case"comment":return{type:"comment",value:{parent_author:s.parent_author||"",parent_permlink:s.parent_permlink||"",author:s.author||"",permlink:s.permlink||"",title:s.title||"",body:s.body||"",json_metadata:s.json_metadata||""}};case"custom_json":return{type:"custom_json",value:{required_auths:s.required_auths||[],required_posting_auths:s.required_posting_auths||[],id:s.id||"",json:s.json||""}};case"comment_payout_update":return{type:"comment_payout_update",value:{author:s.author||"",permlink:s.permlink||""}};case"comment_options":return{type:"comment_options",value:{author:s.author||"",permlink:s.permlink||"",max_accepted_payout:s.max_accepted_payout||"",percent_hbd:s.percent_hbd||0,allow_votes:s.allow_votes||!1,allow_curation_rewards:s.allow_curation_rewards||!1,extensions:s.extensions||[]}};case"effective_comment_vote":return{type:"effective_comment_vote",value:{voter:s.voter||"",author:s.author||"",permlink:s.permlink||"",pending_payout:s.pending_payout||"",weight:s.weight||0,rshares:s.rshares||0,total_vote_weight:s.total_vote_weight||0}};default:return console.warn("Unknown operation type:",i,a.op),null}}catch(i){return console.error("Error parsing operation:",i,a.op),null}}formatTimestamp(a){try{return new Date(a).toLocaleString()}catch(i){return console.error("Error formatting timestamp:",i),a}}getTransactionSummary(a){const i={};let s="",r="";return a.forEach(n=>{const u=n.op?.[0]||"unknown";i[u]=(i[u]||0)+1,(!s||n.timestamp<s)&&(s=n.timestamp),(!r||n.timestamp>r)&&(r=n.timestamp)}),{totalTransactions:a.length,operationCounts:i,dateRange:{earliest:s,latest:r}}}}const aa=new qp;function Bp({account:e,className:a}){const[i,s]=P.useState([]),[r,n]=P.useState([]),[u,c]=P.useState(!1),[d,f]=P.useState(null),[o,h]=P.useState(""),[l,p]=P.useState("all"),[x,w]=P.useState(50),b=[{value:"all",label:"All Operations",icon:z.Activity},{value:"transfer",label:"Transfers",icon:z.Send},{value:"vote",label:"Votes",icon:z.TrendingUp},{value:"comment",label:"Comments",icon:z.MessageCircle},{value:"custom_json",label:"Custom JSON",icon:z.ArrowUpDown},{value:"comment_payout_update",label:"Payout Updates",icon:z.RefreshCw},{value:"comment_options",label:"Comment Options",icon:z.Filter},{value:"effective_comment_vote",label:"Effective Votes",icon:z.Users}],g=async()=>{if(e){c(!0),f(null);try{const y=await aa.getTransactionHistory(e,-1,x);s(y),n(y)}catch(y){f("Failed to load transaction history"),console.error("Error loading transactions:",y)}finally{c(!1)}}};P.useEffect(()=>{g()},[e,x]),P.useEffect(()=>{let y=i;if(l!=="all"&&(y=y.filter(m=>m.op?.[0]===l)),o){const m=o.toLowerCase();y=y.filter(k=>{const j=aa.parseOperation(k);if(!j)return!1;switch(j.type){case"transfer":return j.value.from.toLowerCase().includes(m)||j.value.to.toLowerCase().includes(m)||j.value.memo.toLowerCase().includes(m);case"vote":return j.value.voter.toLowerCase().includes(m)||j.value.author.toLowerCase().includes(m)||j.value.permlink.toLowerCase().includes(m);case"comment":return j.value.author.toLowerCase().includes(m)||j.value.title.toLowerCase().includes(m)||j.value.permlink.toLowerCase().includes(m);default:return!1}})}n(y)},[i,l,o]);const v=y=>{if(!y)return t.jsx(z.Activity,{className:"h-4 w-4"});const m=b.find(k=>k.value===y.type)?.icon||z.Activity;return t.jsx(m,{className:"h-4 w-4"})},_=y=>{const m=aa.parseOperation(y);if(!m)return t.jsx("span",{className:"text-gray-400",children:"Unknown operation"});switch(m.type){case"transfer":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Transfer"}),t.jsx("span",{className:"text-sm font-medium text-white",children:m.value.amount})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"From:"}),t.jsx("img",{src:be.userAvatar(m.value.from),alt:`${m.value.from} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.from)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.from})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"To:"}),t.jsx("img",{src:be.userAvatar(m.value.to),alt:`${m.value.to} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.to)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.to})]}),m.value.memo&&t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Memo:"})," ",m.value.memo]})]});case"vote":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Vote"}),t.jsxs("span",{className:"text-sm font-medium text-white",children:[m.value.weight,"%"]})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Voter:"}),t.jsx("img",{src:be.userAvatar(m.value.voter),alt:`${m.value.voter} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.voter)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.voter})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"comment":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Comment"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Title:"})," ",m.value.title]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"custom_json":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Custom JSON"})}),t.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",m.value.id]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["JSON: ",m.value.json.substring(0,100),"..."]})]});case"comment_payout_update":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Payout Update"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"comment_options":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Comment Options"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Max Payout:"})," ",m.value.max_accepted_payout]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"HBD Percent:"})," ",m.value.percent_hbd,"%"]})]});case"effective_comment_vote":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Effective Vote"}),t.jsx("span",{className:"text-sm font-medium text-white",children:m.value.weight})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Voter:"," ",t.jsx("span",{className:"font-mono text-gray-300",children:m.value.voter})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Post: @",m.value.author,"/",m.value.permlink]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Pending Payout: ",m.value.pending_payout]})]});default:return t.jsx("span",{className:"text-gray-400",children:"Unknown operation"})}},N=aa.getTransactionSummary(i);return u?t.jsxs("div",{className:`bg-gray-800 border border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsxs("div",{className:"p-2 md:p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(z.Activity,{className:"h-5 w-5 text-gray-300"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction History"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Loading transaction history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:y=>{y.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-400",children:["@",e]})]})]}),t.jsx("div",{className:"p-2 md:p-6 space-y-2 md:space-y-4",children:Array.from({length:5}).map((y,m)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-700 rounded animate-pulse w-3/4"}),t.jsx("div",{className:"h-3 bg-gray-700 rounded animate-pulse w-1/2"})]},m))})]}):t.jsxs("div",{className:`bg-gray-800 border border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsxs("div",{className:"p-4 md:p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(z.Activity,{className:"h-5 w-5 text-gray-300"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction History"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Transaction history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:y=>{y.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-400",children:["@",e]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.totalTransactions}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.transfer||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Transfers"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.vote||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Votes"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.comment||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Comments"})]})]})]}),t.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsx("div",{className:"flex-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search transactions...",value:o,onChange:y=>h(y.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsx("select",{value:l,onChange:y=>p(y.target.value),className:"w-full sm:w-48 px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:b.map(y=>t.jsx("option",{value:y.value,children:y.label},y.value))}),t.jsxs("select",{value:x.toString(),onChange:y=>w(parseInt(y.target.value)),className:"w-full sm:w-32 px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"25",children:"25"}),t.jsx("option",{value:"50",children:"50"}),t.jsx("option",{value:"100",children:"100"}),t.jsx("option",{value:"200",children:"200"})]}),t.jsx("button",{onClick:g,className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded-md hover:bg-gray-600 text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]}),d&&t.jsx("div",{className:"p-4 border border-red-700 bg-red-900 rounded-md",children:t.jsx("p",{className:"text-red-300",children:d})}),t.jsx("div",{className:"space-y-4",children:r.length===0?t.jsx("div",{className:"text-center py-8 text-gray-400",children:"No transactions found"}):r.map(y=>{const m=aa.parseOperation(y);return t.jsxs("div",{className:"border border-gray-600 rounded-lg p-3 md:p-4 space-y-3 hover:bg-gray-700 transition-colors",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[v(m),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:m?.type?m.type.charAt(0).toUpperCase()+m.type.slice(1):"Unknown"}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-1",children:[t.jsx(z.Clock,{className:"h-3 w-3"}),aa.formatTimestamp(y.timestamp)]})]})]})}),t.jsx("div",{className:"ml-6 md:ml-7",children:_(y)})]},`${y.trx_id}-${y.op_in_trx}`)})}),r.length>0&&t.jsxs("div",{className:"text-center text-sm text-gray-400",children:["Showing ",r.length," of ",i.length," ","transactions"]})]})]})}const Vp=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Up{async getUserChannel(a,i="posts",s=20,r=null,n=null,u=null){const c={account:a,sort:i,limit:s};r&&(c.start_author=r),n&&(c.start_permlink=n),u&&(c.observer=u);try{const d=await Vp.call("bridge","get_account_posts",c);return Array.isArray(d)?d:[]}catch(d){return console.error("Error in getUserChannel:",d),[]}}async getUserPosts(a,i=20){return this.getUserChannel(a,"posts",i)}async getUserComments(a,i=20){return this.getUserChannel(a,"comments",i)}async getUserReplies(a,i=20){return this.getUserChannel(a,"replies",i)}async getAllUserActivity(a,i=10){try{const[s,r,n]=await Promise.all([this.getUserPosts(a,i),this.getUserComments(a,i),this.getUserReplies(a,i)]);return[...s,...r,...n].sort((c,d)=>new Date(d.created).getTime()-new Date(c.created).getTime())}catch(s){return console.error("Error in getAllUserActivity:",s),[]}}convertToDisplayItem(a){return{id:a.id,author:a.author,permlink:a.permlink,title:a.title,body:a.body,created:a.created,category:a.category,net_votes:a.net_votes,children:a.children,total_payout_value:a.total_payout_value,pending_payout_value:a.pending_payout_value,url:a.url,type:a.parent_author===""?"post":"comment"}}formatTimestamp(a){try{return new Date(a).toLocaleString()}catch(i){return console.error("Error formatting timestamp:",i),a}}getRelativeTime(a){try{const i=new Date(a),r=new Date().getTime()-i.getTime(),n=Math.floor(r/1e3),u=Math.floor(n/60),c=Math.floor(u/60),d=Math.floor(c/24);return n<60?`${n} seconds ago`:u<60?`${u} minutes ago`:c<24?`${c} hours ago`:d<7?`${d} days ago`:i.toLocaleDateString()}catch(i){return console.error("Error calculating relative time:",i),a}}truncateText(a,i=150){return a.length<=i?a:a.substring(0,i)+"..."}getActivitySummary(a){let i=0,s=0,r=0,n=0;return a.forEach(u=>{u.parent_author===""?i++:s++,r+=u.net_votes||0;const c=u.total_payout_value?.match(/(\d+\.?\d*)/);c&&(n+=parseFloat(c[1]))}),{totalActivities:a.length,postsCount:i,commentsCount:s,totalVotes:r,totalPayout:`${n.toFixed(3)} HIVE`,averageVotes:a.length>0?Math.round(r/a.length):0}}filterByCategory(a,i){return a.filter(s=>s.category===i)}filterByDateRange(a,i,s){return a.filter(r=>{const n=new Date(r.created);return n>=i&&n<=s})}searchActivities(a,i){const s=i.toLowerCase();return a.filter(r=>r.title.toLowerCase().includes(s)||r.body.toLowerCase().includes(s)||r.category.toLowerCase().includes(s))}}const na=new Up,zp=({username:e,className:a})=>{const[i,s]=P.useState([]),[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState([]),[o,h]=P.useState([]),[l,p]=P.useState(!1),[x,w]=P.useState(null),[b,g]=P.useState(""),[v,_]=P.useState(20),[N,y]=P.useState("all"),[m,k]=P.useState(new Set),[j,A]=P.useState(!1),D=async()=>{if(!(!e||j)){p(!0),w(null);try{const[$,G,X]=await Promise.all([na.getUserPosts(e,v),na.getUserComments(e,v),na.getUserReplies(e,v)]);s($),n(G),c(X),A(!0)}catch($){w("Failed to load activity history"),console.error("Error loading activities:",$)}finally{p(!1)}}};P.useEffect(()=>{D()},[e]),P.useEffect(()=>{if(!j)return;let $=[];switch(N){case"posts":$=i;break;case"comments":$=r;break;case"replies":$=u;break;default:$=[...i,...r,...u].sort((G,X)=>new Date(X.created).getTime()-new Date(G.created).getTime());break}f($),h($)},[N,i,r,u,j]),P.useEffect(()=>{let $=d;b&&($=na.searchActivities(d,b)),h($)},[d,b]);const C=$=>!$||$==="0.000 HIVE"?"0 HIVE":$,O=$=>$.parent_author===""?"Post":$.depth===1?"Comment":"Reply",L=new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:$=>$,usertagUrlFn:$=>`/@${$}`,hashtagUrlFn:$=>`/trending/${$}`,isLinkSafeFn:$=>!0,addExternalCssClassToMatchingLinksFn:$=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"}),H=$=>{const G=new Set(m);G.has($)?G.delete($):G.add($),k(G)},F=$=>{const G=`${$.author}-${$.permlink}`,X=m.has(G),ee=$.body.length>100;return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-3 sm:p-4 space-y-3 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors relative",children:[t.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3",children:t.jsx("div",{className:"flex items-start gap-3 flex-1",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[t.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${$.parent_author===""?"bg-blue-900 text-blue-300":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300"}`,children:O($)}),t.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:["in #",$.category]})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("img",{src:be.userAvatar($.author),alt:`${$.author} avatar`,className:"w-5 h-5 sm:w-6 sm:h-6 rounded-full flex-shrink-0",onError:R=>{R.target.src=be.userAvatar($.author)}}),t.jsx("h3",{className:"font-medium text-base sm:text-lg leading-tight text-gray-900 dark:text-white break-words",children:$.title||"Untitled"})]}),t.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-3 text-gray-500 dark:text-gray-400 comment-content overflow-hidden",children:[t.jsx("div",{className:"break-words overflow-wrap-anywhere",dangerouslySetInnerHTML:{__html:L.render(ee&&!X?$.body.substring(0,50)+".....":$.body)}}),ee&&t.jsxs("button",{onClick:()=>H(G),className:"mt-2 text-blue-400 hover:text-blue-300 text-sm font-medium flex items-center gap-1",children:[t.jsx(z.ChevronDown,{className:`h-3 w-3 transition-transform ${X?"rotate-180":""}`}),X?"Show less":"Show more"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 text-sm text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.Clock,{className:"h-3 w-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:na.getRelativeTime($.created)})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.ThumbsUp,{className:"h-3 w-3 flex-shrink-0"}),t.jsxs("span",{children:[$.net_votes," votes"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.Reply,{className:"h-3 w-3 flex-shrink-0"}),t.jsxs("span",{children:[$.children," replies"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{children:"💰"}),t.jsx("span",{children:C($.total_payout_value)})]})]})]})})}),t.jsx("button",{onClick:()=>window.open(`https://peakd.com/@${$.author}/${$.permlink}`,"_blank"),className:"absolute top-3 right-3 flex-shrink-0 p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:t.jsx(z.ExternalLink,{className:"h-4 w-4"})})]},G)},B=na.getActivitySummary(d);return l?t.jsxs("div",{className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading activity history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:$=>{$.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["@",e]})]})}),t.jsx("div",{className:"p-6 space-y-4",children:Array.from({length:5}).map(($,G)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/4"}),t.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-1/2"}),t.jsx("div",{className:"h-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-full"})]},G))})]}):t.jsxs("div",{className:`space-y-6 ${a}`,children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:t.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-16 h-16 rounded-full object-cover",onError:$=>{$.target.src=be.userAvatar(e)}}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:["@",e]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"Activity History"}),t.jsx("div",{className:"flex flex-wrap gap-6 text-sm",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.FileText,{className:"w-4 h-4"}),t.jsxs("span",{children:[B.totalActivities," Total Activities"]})]})})]})]})}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex md:grid md:grid-cols-4 overflow-x-auto md:overflow-visible w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsx("button",{onClick:()=>y("all"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="all"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"All"}),t.jsx("button",{onClick:()=>y("posts"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="posts"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Posts"}),t.jsx("button",{onClick:()=>y("comments"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="comments"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Comments"}),t.jsx("button",{onClick:()=>y("replies"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="replies"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Replies"})]}),t.jsxs("div",{className:"mt-6",children:[t.jsxs("div",{className:"flex flex-row gap-4 mb-6",children:[t.jsx("div",{className:"flex-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-500 dark:text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search activities...",value:b,onChange:$=>g($.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsx("button",{onClick:()=>{A(!1),D()},className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]}),x&&t.jsx("div",{className:"p-4 border border-red-200 dark:border-red-700 bg-red-50 dark:bg-red-900 rounded-md",children:t.jsx("p",{className:"text-red-600 dark:text-red-300",children:x})}),t.jsx("div",{className:"space-y-4",children:o.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No activities found"}):o.map(F)}),o.length>0&&t.jsxs("div",{className:"text-center text-sm text-gray-500 dark:text-gray-400",children:["Showing ",o.length," of ",d.length," ","activities"]})]})]})]})};function Hp({author:e,permlink:a,currentUser:i,hiveValue:s=0,onUpvote:r,onSubmitComment:n,onComments:u,onReblog:c,onShare:d,onTip:f,onReport:o,onClickCommentUpvote:h}){const l=i==null||i===""?null:i,p=l!=null,[x,w]=P.useState([]),[b,g]=P.useState(0),[v,_]=P.useState(!1),[N,y]=P.useState(!1),[m,k]=P.useState(!1),[j,A]=P.useState({message:"",visible:!1}),[D,C]=P.useState(!1),O=P.useCallback(K=>{A({message:K,visible:!0}),setTimeout(()=>A(te=>({...te,visible:!1})),2500)},[]),L=P.useCallback(async()=>{const K=await Re.getActiveVotes(e,a);w(K)},[e,a]);P.useEffect(()=>{L()},[L]),P.useEffect(()=>{Re.getCommentsList(e,a).then(K=>{g(K.length)})},[e,a]);const H=p&&!!l&&x.some(K=>K.voter.toLowerCase()===l.toLowerCase()),F=(K,te)=>{if(!p){O(`Please Login to ${K}`);return}te()},B=()=>{F("Upvote",()=>{if(H){O("You have already upvoted this post");return}_(!0)})},$=async K=>{if(r){C(!0);try{await Promise.resolve(r(K)),_(!1),await L(),O("Vote submitted successfully")}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";O(pe)}finally{C(!1)}}},G=()=>{y(!0)},X=()=>{y(!1),p&&!H?_(!0):O(p?"You have already upvoted this post":"Please Login to Upvote")},ee=()=>{F("Comment",()=>{u?.(),k(!0)})},R=()=>{F("Reblog",()=>c?.())},se=()=>{F("Report",()=>o?.())},I=()=>{F("Tip",()=>f?.())},V=()=>{if(d){d();return}typeof navigator<"u"&&navigator.share?navigator.share({title:`${e}'s post`,url:`https://peakd.com/@${e}/${a}`,text:`Check out this post by @${e}`}).then(()=>O("Shared")).catch(()=>{}):(navigator.clipboard?.writeText(`https://peakd.com/@${e}/${a}`),O("Link copied to clipboard"))},J=async(K,te,pe)=>{if(!p){O("Please Login to comment");return}if(n)try{await Promise.resolve(n(K,te,pe)),O("Comment posted")}catch(Ee){const Z=Ee instanceof Error?Ee.message:"Failed to post comment";throw O(Z),Ee}},oe="absolute left-1/2 -translate-x-1/2 bottom-full mb-1 px-2 py-1 text-xs font-medium text-white bg-gray-800 dark:bg-gray-700 rounded shadow-lg whitespace-nowrap opacity-0 pointer-events-none group-hover:opacity-100 transition-opacity duration-150 z-[60]";return t.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-4 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Upvote"}),t.jsx("button",{type:"button",onClick:B,disabled:D,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-50","aria-label":"Upvote",children:D?t.jsx(z.Loader2,{className:"w-4 h-4 sm:w-5 sm:h-5 animate-spin text-blue-600"}):t.jsx(z.ThumbsUp,{className:`w-4 h-4 sm:w-5 sm:h-5 ${H?"text-blue-600 dark:text-blue-400 fill-current":"text-gray-600 dark:text-gray-400"}`})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"View upvotes"}),t.jsx("button",{type:"button",onClick:G,className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":"View upvotes",children:t.jsx("span",{children:x.length})})]})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Comments"}),t.jsxs("button",{type:"button",onClick:ee,className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":"Comments",children:[t.jsx(z.MessageCircle,{className:"w-4 h-4 sm:w-5 sm:h-5"}),t.jsx("span",{children:b})]})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Reblog"}),t.jsx("button",{type:"button",onClick:R,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors p-1 rounded","aria-label":"Reblog",children:t.jsx(z.Repeat2,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Share"}),t.jsx("button",{type:"button",onClick:V,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors p-1 rounded","aria-label":"Share",children:t.jsx(z.Share2,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Report"}),t.jsx("button",{type:"button",onClick:se,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors p-1 rounded","aria-label":"Report",children:t.jsx(z.Flag,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Tip"}),t.jsx("button",{type:"button",onClick:I,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 transition-colors p-1 rounded","aria-label":"Tip",children:t.jsx(z.Gift,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),s>0&&t.jsxs("span",{className:"font-semibold text-green-600 dark:text-green-400",children:["$",s.toFixed(2)]}),v&&t.jsx(ro,{author:e,permlink:a,onUpvote:$,onCancel:()=>_(!1)}),N&&t.jsx(yd,{author:e,permlink:a,onClose:()=>y(!1),currentUser:l??void 0,token:void 0,onClickUpvoteButton:X}),m&&t.jsx(ao,{author:e,permlink:a,onClose:()=>{k(!1),Re.getCommentsList(e,a).then(K=>g(K.length))},currentUser:l??void 0,token:void 0,onSubmitComment:n?J:void 0,onClickCommentUpvote:h}),j.visible&&t.jsx("div",{className:"fixed bottom-4 right-4 z-[100] max-w-[280px] rounded-lg bg-gray-800 dark:bg-gray-900 text-white px-3 py-2 shadow-lg text-sm",children:j.message})]})}const Di="_communityLocalKey",Zn={getBookmarkedCommunities:()=>{const e=localStorage.getItem(Di);return e?JSON.parse(e):[]},isUserPresentLocally:e=>{const a=localStorage.getItem(Di);return a?JSON.parse(a).includes(e):!1},storeLikedCommunityLocally:(e,a=!1)=>{let i=Zn.getBookmarkedCommunities();return i.includes(e)?i=i.filter(s=>s!==e):a||i.push(e),localStorage.setItem(Di,JSON.stringify(i)),i}},so=({id:e,toastType:a,isLiked:i,onAdd:s,onRemove:r,onFavourite:n})=>{const[u,c]=P.useState(i??Zn.isUserPresentLocally(e));P.useEffect(()=>{i!==void 0&&c(i)},[i]);const d=()=>{n&&n(),u?(r?r(e,"remove_bookmark"):Zn.storeLikedCommunityLocally(e,!0),f(!1)):(s?s(e,"add_bookmark"):Zn.storeLikedCommunityLocally(e),f(!0)),c(!u)},f=o=>{alert(`The ${a} is ${o?"added to":"removed from"} your bookmarks`)};return t.jsx("button",{onClick:d,className:"p-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:u?t.jsx(z.BookmarkCheck,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}):t.jsx(z.Bookmark,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})};class Wp{HIVE_API_URL="https://api.hive.blog";async getListOfCommunities(a,i=20,s){const r={limit:i};s&&s.trim()!==""&&(r.last=s),a&&a.trim()!==""&&(r.query=a);const n={jsonrpc:"2.0",method:"bridge.list_communities",params:r,id:1};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return(await u.json()).result||[]}catch(u){throw console.error("Error fetching communities:",u),u}}async getCommunityDetails(a){const i={jsonrpc:"2.0",method:"bridge.get_community",params:{name:a},id:1};try{const s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(s){throw console.error("Error fetching community details:",s),s}}async getCommunitySubscribers(a,i=100,s){const r={community:a,limit:i};s&&s.trim()!==""&&(r.last=s);const n={jsonrpc:"2.0",method:"bridge.list_community_roles",params:r,id:1};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return((await u.json()).result||[]).map(d=>({username:d[0],role:d[1],extra:d[2],subscribedAt:d[3]}))}catch(u){throw console.error("Error fetching community subscribers:",u),u}}async getCommunitySubscribersList(a,i=100,s){const r={community:a,limit:i};s&&s.trim()!==""&&(r.last=s);const n={jsonrpc:"2.0",method:"bridge.list_subscribers",params:r,id:2};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return((await u.json()).result||[]).map(d=>({username:d[0],role:d[1],extra:d[2],subscribedAt:d[3]}))}catch(u){throw console.error("Error fetching community subscribers list:",u),u}}async getCommunityAccounts(a){const i={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[[a]],id:2};try{const s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result||[]}catch(s){throw console.error("Error fetching community accounts:",s),s}}async getRankedPosts(a,i="created",s=20,r,n){const u={tag:a,sort:i,limit:s};r&&n&&(u.start_author=r,u.start_permlink=n);const c={jsonrpc:"2.0",method:"bridge.get_ranked_posts",params:u,id:3};try{const d=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return(await d.json()).result||[]}catch(d){throw console.error("Error fetching ranked posts:",d),d}}communityIcon(a){return`https://images.hive.blog/u/${a}/avatar?size=icon`}userOwnerThumb(a){return`https://images.hive.blog/u/${a}/avatar`}async getCommunityActivities(a,i=100,s){const r={account:a,limit:i};s&&(r.last_id=s);const n={jsonrpc:"2.0",method:"bridge.account_notifications",params:r,id:19};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return(await u.json()).result||[]}catch(u){throw console.error("Error fetching community activities:",u),u}}}const ot=new Wp,Gp=({onSelectCommunity:e,theme:a="dark"})=>{const[i,s]=P.useState([]),[r,n]=P.useState(""),[u,c]=P.useState(!0),[d,f]=P.useState(!1),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=20,g=P.useRef(null),v=P.useCallback(async(y=!1)=>{if(!(!y&&(d||!o)))try{y?(c(!0),w(null),s([]),p(null),h(!0)):f(!0);const m=r.trim(),k=await ot.getListOfCommunities(m.length>=3?m:void 0,b,y?void 0:l||void 0);s(j=>y?k:[...j,...k]),k.length<b||k.length>0&&k[k.length-1].name===l?h(!1):k.length>0&&p(k[k.length-1].name||null)}catch(m){w(m instanceof Error?m.message:"Failed to load communities"),h(!1)}finally{c(!1),f(!1)}},[r,d,o,l]);P.useEffect(()=>{const y=setTimeout(()=>{v(!0)},r.length>=3||r.length===0?0:500);return()=>clearTimeout(y)},[r]),P.useEffect(()=>{g.current?.focus()},[r,u,x]),P.useEffect(()=>{const y=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!d&&!u&&o&&v()};return window.addEventListener("scroll",y),()=>window.removeEventListener("scroll",y)},[v,d,u,o]);const _=()=>{v(!0)},N=()=>t.jsx("div",{className:"space-y-4",children:Array.from({length:6}).map((y,m)=>t.jsx("div",{className:`${a==="dark"?"bg-slate-900 border-gray-800":"bg-white border-gray-200"} border rounded-xl p-4 animate-pulse`,children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:`w-12 h-12 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded-full`}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:`h-4 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-3/4`}),t.jsx("div",{className:`h-3 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-1/2`})]}),t.jsx("div",{className:`h-3 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-16`})]})},m))});return u&&i.length===0?t.jsxs("div",{className:`space-y-6 ${a==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${a==="dark"?"text-gray-400":"text-gray-500"} w-5 h-5`}),t.jsx("input",{type:"text",placeholder:"Search communities...",value:r,onChange:y=>n(y.target.value),ref:g,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 ${a==="dark"?"bg-slate-900 border-gray-800 text-white placeholder-gray-400":"bg-white border-gray-200 text-gray-900 placeholder-gray-500"}
1096
+ disabled:opacity-50 disabled:cursor-not-allowed`,children:[t.jsx(z.X,{className:"w-4 h-4 sm:w-5 sm:h-5 mr-1"}),"Cancel"]})]})]})})}const bd=({comment:e,allComments:a,onReply:i,currentUser:s,token:r,searchQuery:n,depth:u=0,onVotedRefresh:c,onClickCommentUpvote:d,onClickCommentReply:f,onClickUpvoteButton:o})=>{const[h,l]=P.useState(!1),[p,x]=P.useState(!0),[w,b]=P.useState(!1),g=P.useMemo(()=>{const K=e.active_votes||[];if(!s)return!1;const te=s.toLowerCase();return K.some(pe=>(pe.voter||"").toLowerCase()===te)},[e.active_votes,s]),[v,_]=P.useState(!1),[N,y]=P.useState(""),[m,k]=P.useState(!1),j=K=>{y(K),_(!0),setTimeout(()=>_(!1),2500)},A=e.depth||0;let C=a.filter(K=>K.parent_author===e.author&&K.parent_permlink===e.permlink&&(typeof K.depth!="number"||K.depth===A+1));if((!C||C.length===0)&&Array.isArray(e.replies)&&e.replies.length>0){const K=new Set(e.replies);C=a.filter(te=>K.has(`${te.author}/${te.permlink}`))}const O=C.length>0,L=u>=4,H=(K,te)=>{if(!te)return K;const pe=new RegExp(`(${te})`,"gi");return K.replace(pe,'<mark class="bg-yellow-200 dark:bg-yellow-800">$1</mark>')},F=()=>{b(!0)},B=async K=>{if(d){try{await Promise.resolve(d(e.author,e.permlink,K)),l(!0),b(!1),setTimeout(()=>{c?.(),j("Vote submitted successfully!")},3e3)}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";alert(pe)}return}if(!r){j("Please login or provide an upvote handler to vote");return}try{const te=Math.round(K*100);await Re.handleUpvote({author:e.author,permlink:e.permlink,weight:te,authToken:r}),l(!0),b(!1),k(!0),setTimeout(()=>{c?.(),k(!1),j("Vote submitted successfully ✅")},3e3)}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";alert(pe)}},$=()=>{s?i(e.author,e.permlink):j("Please login to upvote")},G=e.json_metadata_parsed||(()=>{try{return e.json_metadata?JSON.parse(e.json_metadata):void 0}catch{return}})(),X=e.body||"",R=(K=>{const te=/^(\s*(?:#[\p{L}\p{N}_-]+\s*(?:,\s*)?)+\s*)$/gimu;return K.replace(te,"").trim()})(X),se=n?H(R,n):R,I=/!\[[^\]]*\]\([^)]+\)/.test(R)||/<img\s/i.test(R),V=Array.isArray(G?.image)?G.image:[],J=new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:K=>K,usertagUrlFn:K=>`/@${K}`,hashtagUrlFn:K=>`/trending/${K}`,isLinkSafeFn:K=>!0,addExternalCssClassToMatchingLinksFn:K=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"}),oe=e.stats?.total_votes||e.net_votes||0;return t.jsxs("div",{className:`${u>0?"ml-4 md:ml-8 border-l-2 border-gray-200 dark:border-gray-700 pl-4 md:pl-6":""}`,children:[t.jsx("div",{className:"group hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors duration-200 p-4 md:p-6",children:t.jsxs("div",{className:"flex items-start space-x-3 md:space-x-4",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("img",{src:`https://images.hive.blog/u/${e.author}/avatar`,alt:e.author,className:"w-8 h-8 md:w-10 md:h-10 rounded-full object-cover ring-2 ring-gray-200 dark:ring-gray-700",onError:K=>{K.target.src=`https://ui-avatars.com/api/?name=${e.author}&background=random`}})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center flex-wrap gap-2 mb-2",children:[t.jsxs("button",{className:"font-semibold text-gray-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 text-sm md:text-base",onClick:()=>{},children:["@",e.author]}),t.jsxs("div",{className:"flex items-center text-xs md:text-sm text-gray-500 dark:text-gray-400 space-x-1",children:[t.jsx(z.Clock,{className:"w-3 h-3 md:w-4 md:h-4"}),t.jsx("span",{children:ns.formatDistanceToNow(new Date(e.created+"Z"),{addSuffix:!0})})]}),e.author===s&&t.jsx("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded-full",children:"You"})]}),t.jsx("div",{className:"prose prose-sm md:prose-base dark:prose-invert max-w-none mb-3 comment-content text-left text-gray-900 dark:text-gray-100 prose-a:text-blue-600 dark:prose-a:text-blue-400 [&>*]:text-left",children:n?t.jsx("div",{className:"text-left",dangerouslySetInnerHTML:{__html:se}}):t.jsx("div",{className:"text-left",dangerouslySetInnerHTML:{__html:J.render(R)}})}),!I&&V.length>0&&t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-3",children:V.map((K,te)=>t.jsx("img",{src:K,alt:`image-${te}`,className:"max-w-full h-auto rounded-lg shadow-sm cursor-pointer hover:shadow-md transition-shadow duration-200",onClick:()=>window.open(K,"_blank")},K+te))}),t.jsxs("div",{className:"flex items-center space-x-4 md:space-x-6",children:[t.jsxs("button",{onClick:()=>{if(d){if(!s){j("Please login to upvote");return}if(g||h){j("You have already upvoted this comment");return}F()}else if(o){if(!s){j("Please login to upvote");return}if(g||h){j("You have already upvoted this comment");return}F()}else{if(!s){j("Please login to upvote");return}r?g?j("You have already upvoted this comment"):F():(c?.(),j("Vote submitted successfully ✅"))}},className:`flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium transition-colors duration-200 ${h?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"}`,children:[t.jsx(z.ThumbsUp,{className:`w-4 h-4 ${g||h?"fill-current text-blue-600 dark:text-blue-400":""}`}),t.jsx("span",{children:oe})]}),t.jsxs("button",{onClick:()=>{f?f(e):$()},className:"flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200",children:[t.jsx(z.MessageSquare,{className:"w-4 h-4"}),t.jsx("span",{children:"Reply"})]}),O&&t.jsx("button",{onClick:()=>x(!p),className:"flex items-center space-x-1 md:space-x-2 text-xs md:text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200",children:t.jsxs("span",{children:[p?"Hide":"Show"," ",C.length," ",C.length===1?"reply":"replies"]})}),t.jsx("button",{onClick:()=>f?.(e),className:"opacity-0 group-hover:opacity-100 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-all duration-200",children:t.jsx(z.MoreHorizontal,{className:"w-4 h-4 text-gray-400"})})]}),w&&!g&&t.jsx("div",{className:"mt-3",children:t.jsx(ro,{author:e.author,permlink:e.permlink,onUpvote:B,onCancel:()=>b(!1)})}),m&&t.jsxs("div",{className:"mt-3 inline-flex items-center text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin mr-2"}),"Updating votes..."]}),v&&t.jsx("div",{className:"fixed bottom-4 right-4 w-[280px] z-50",children:t.jsx("div",{className:"bg-gray-800 text-white rounded px-3 py-2 shadow-lg text-sm",children:N})})]})]})}),O&&p&&!L&&t.jsx("div",{className:"space-y-0",children:C.map(K=>t.jsx(bd,{comment:K,allComments:a,onReply:i,currentUser:s,searchQuery:n,depth:u+1,onVotedRefresh:c,onClickCommentUpvote:d,onClickCommentReply:f,onClickUpvoteButton:o},K.permlink))}),O&&L&&t.jsx("div",{className:"ml-4 md:ml-8 p-3 text-sm text-gray-500 dark:text-gray-400 border-l-2 border-gray-200 dark:border-gray-700 pl-4",children:t.jsxs("button",{onClick:()=>{console.log("Show more replies for:",e.author,e.permlink)},className:"text-blue-600 dark:text-blue-400 hover:underline",children:["View ",C.length," more ",C.length===1?"reply":"replies"]})})]})},xd=({onSubmit:e,onCancel:a,currentUser:i,placeholder:s="Write your comment...",parentAuthor:r,parentPermlink:n})=>{const[u,c]=P.useState(""),[d,f]=P.useState(!1),o=P.useRef(null);P.useEffect(()=>{o.current&&o.current.focus()},[]);const h=async()=>{if(!(!u.trim()||d)){f(!0);try{await e(u.trim()),c("")}catch(p){console.error("Failed to submit comment:",p)}finally{f(!1)}}},l=p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),h()),p.key==="Escape"&&a()};return t.jsxs("div",{className:"p-4 md:p-6 space-y-4 bg-white dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-start space-x-3 text-left",children:[t.jsx("div",{className:"flex-shrink-0",children:i?t.jsx("img",{src:`https://images.hive.blog/u/${i}/avatar`,alt:i,className:"w-10 h-10 rounded-full object-cover border-2 border-gray-200 dark:border-gray-600",onError:p=>{p.target.src=`https://ui-avatars.com/api/?name=${i}&background=random`}}):t.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:t.jsx(z.User,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white font-medium",children:i?`@${i}`:"Anonymous"}),r&&t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Replying to @",r]})]})]}),t.jsx("div",{className:"relative",children:t.jsx("textarea",{ref:o,value:u,onChange:p=>c(p.target.value),onKeyDown:l,placeholder:s,disabled:d,className:"w-full min-h-[100px] max-h-[300px] p-4 border border-gray-200 dark:border-gray-600 rounded-lg resize-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors duration-200 disabled:opacity-50",style:{height:"auto"},onInput:p=>{const x=p.target;x.style.height="auto",x.style.height=x.scrollHeight+"px"}})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Press Cmd+Enter to post"}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("button",{onClick:a,disabled:d,className:"px-4 py-2 text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors duration-200 disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:h,disabled:d||!u.trim(),className:"px-6 py-2 bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 dark:disabled:bg-gray-600 text-white rounded-lg font-medium transition-all duration-200 transform hover:scale-[1.02] disabled:transform-none disabled:opacity-50 flex items-center space-x-2",children:d?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),t.jsx("span",{children:"Posting..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(z.Send,{className:"w-4 h-4"}),t.jsx("span",{children:"Post"})]})})]})]})]})},op=({parentAuthor:e,parentPermlink:a,onClose:i,onCommentSubmitted:s,currentUser:r})=>{const[n,u]=P.useState(!1),c=async d=>{if(!(!d.trim()||n)){u(!0);try{await s(e,a,d),i()}catch(f){console.error("Failed to submit reply:",f)}finally{u(!1)}}};return P.useEffect(()=>{const d=f=>{f.key==="Escape"&&i()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[i]),t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900 rounded-lg",children:t.jsx(z.Send,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Reply to Comment"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["@",e]})]})]}),t.jsx("button",{onClick:i,disabled:n,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 disabled:opacity-50",children:t.jsx(z.X,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(xd,{onSubmit:c,onCancel:i,currentUser:r,parentAuthor:e,parentPermlink:a,placeholder:`Reply to @${e}...`})}),t.jsx("div",{className:"p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:t.jsxs("div",{className:"flex items-center justify-between text-xs md:text-sm text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("span",{children:"• Markdown supported"}),t.jsx("span",{children:"• Be respectful"})]}),t.jsx("div",{className:"hidden md:block",children:"Press Esc to close"})]})})]})})},up=({isVisible:e,searchQuery:a,onSearchChange:i,onClose:s})=>{const r=P.useRef(null);P.useEffect(()=>{e&&r.current&&r.current.focus()},[e]);const n=()=>{i(""),s()};return t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${e?"max-h-20 opacity-100":"max-h-0 opacity-0"}`,children:t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400"}),t.jsx("input",{ref:r,type:"text",value:a,onChange:u=>i(u.target.value),placeholder:"Search comments and authors...",className:"w-full pl-10 pr-10 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors duration-200"}),a&&t.jsx("button",{onClick:()=>i(""),className:"absolute right-8 top-1/2 transform -translate-y-1/2 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-4 h-4 text-gray-400"})}),t.jsx("button",{onClick:n,className:"absolute right-3 top-1/2 transform -translate-y-1/2 p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-4 h-4 text-gray-400"})})]})})})},ao=({author:e,permlink:a,onClose:i,currentUser:s,token:r,onClickCommentUpvote:n,onClickCommentReply:u,onClickUpvoteButton:c,onSubmitComment:d})=>{const[f,o]=P.useState([]),[h,l]=P.useState([]),[p,x]=P.useState(!0),[w,b]=P.useState(null),[g,v]=P.useState(null),[_,N]=P.useState(!1),[y,m]=P.useState(""),[k,j]=P.useState(!1),[A,D]=P.useState(!1),C=P.useCallback(async($=!1)=>{$?D(!0):x(!0),b(null);try{const G=await Re.getCommentsList(e,a);o(G),l(G)}catch(G){b(G instanceof Error?G.message:"Failed to load comments")}finally{x(!1),D(!1)}},[e,a]);P.useEffect(()=>{C()},[C]),P.useEffect(()=>{if(!y.trim())l(f);else{const $=f.filter(G=>G.body?.toLowerCase().includes(y.toLowerCase())||G.author.toLowerCase().includes(y.toLowerCase()));l($)}},[y,f]);const O=($,G)=>{v({author:$,permlink:G})},L=$=>{$.target===$.currentTarget&&i()},H=async($,G,X)=>{if(d){try{await Promise.resolve(d($,G,X)),j(!1),D(!0),setTimeout(async()=>{await C(!0),D(!1)},3e3)}catch(ee){const R=ee instanceof Error?ee.message:"Failed to post comment";alert(R)}return}if(!r){alert("Please login to comment");return}try{await Re.handleComment({author:$,permlink:G,body:X,authToken:r}),j(!1),D(!0),setTimeout(async()=>{await C(!0),D(!1)},3e3)}catch(ee){const R=ee instanceof Error?ee.message:"Failed to post comment";alert(R)}},F=P.useMemo(()=>{if(!s?.trim())return h;const $=s.toLowerCase();return[...h].sort((G,X)=>{const ee=G.author?.toLowerCase()===$,R=X.author?.toLowerCase()===$;return ee&&!R?-1:!ee&&R?1:0})},[h,s]),B=F.filter($=>$.parent_author===e&&$.parent_permlink===a);return p?t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4 h-screen",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl h-[90vh] flex flex-col",children:t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center",children:[t.jsx(z.Loader2,{className:"w-12 h-12 animate-spin text-blue-500 mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Loading comments..."})]})})})}):w?t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-40 p-4 h-screen",onClick:L,children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl h-[90vh] flex flex-col overflow-hidden",children:t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center p-6",children:[t.jsx(z.AlertCircle,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load comments"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6",children:w}),t.jsx("button",{onClick:()=>C(),className:"px-6 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors duration-200",children:"Try Again"})]})})})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-40 p-4 h-screen",onClick:L,children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex justify-between items-center p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("h2",{className:"text-lg md:text-xl font-bold text-gray-900 dark:text-white",children:["Comments (",f.length,")"]}),A&&t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin text-blue-500"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>C(!0),disabled:A,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 disabled:opacity-50",title:"Refresh comments",children:t.jsx(z.RefreshCw,{className:`w-5 h-5 text-gray-500 dark:text-gray-400 ${A?"animate-spin":""}`})}),t.jsx("button",{onClick:()=>N(!_),className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",title:"Search comments",children:t.jsx(z.Search,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})}),t.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200",children:t.jsx(z.X,{className:"w-6 h-6 text-gray-500 dark:text-gray-400"})})]})]}),t.jsx(up,{isVisible:_,searchQuery:y,onSearchChange:m,onClose:()=>N(!1)}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[k&&t.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:t.jsx(xd,{onSubmit:$=>H(e,a,$),onCancel:()=>j(!1),currentUser:s,placeholder:"Add a comment..."})}),B.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-8 text-center",children:[t.jsx(z.MessageCirclePlus,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mb-4"}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:y?"No comments found":"No comments yet"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-6",children:y?"Try adjusting your search terms":"Be the first to share your thoughts!"}),!y&&s&&t.jsx("button",{onClick:()=>j(!0),className:"px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition-colors duration-200",children:"Add Comment"})]}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:B.map($=>t.jsx(bd,{comment:$,allComments:F,onReply:O,currentUser:s,token:r,searchQuery:y,depth:0,onVotedRefresh:()=>C(!0),onClickCommentUpvote:n,onClickCommentReply:u,onClickUpvoteButton:c},$.permlink))})]}),!k&&s&&B.length>0&&t.jsx("div",{className:"p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:t.jsxs("button",{onClick:()=>j(!0),className:"w-full md:w-auto px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition-all duration-200 transform hover:scale-[1.02] flex items-center justify-center space-x-2",children:[t.jsx(z.MessageCirclePlus,{className:"w-5 h-5"}),t.jsx("span",{children:"Add Comment"})]})})]})}),g&&t.jsx(op,{parentAuthor:g.author,parentPermlink:g.permlink,onClose:()=>v(null),onCommentSubmitted:H,currentUser:s})]})};function lp(e){const a=typeof e=="string"?new Date(e):e,i=Math.floor((Date.now()-a.getTime())/1e3),s={year:31536e3,month:2628e3,day:86400,hour:3600,minute:60};for(const[r,n]of Object.entries(s)){const u=Math.floor(i/n);if(u>1)return`${u} ${r}s ago`;if(u===1)return`${u} ${r} ago`}return"just now"}const yd=({author:e,permlink:a,onClose:i,currentUser:s,token:r,onClickUpvoteButton:n})=>{const[u,c]=P.useState([]),[d,f]=P.useState(!0),[o,h]=P.useState(!1),l=!!s&&u.some(k=>k.voter===s),[p,x]=P.useState(!1),[w,b]=P.useState(""),[g,v]=P.useState(!1),_=k=>{b(k),x(!0),setTimeout(()=>x(!1),2500)},N=async()=>{f(!0);const k=await Re.getActiveVotes(e,a);k.sort((j,A)=>!j.time||!A.time?0:new Date(A.time).getTime()-new Date(j.time).getTime()),c(k),f(!1)};P.useEffect(()=>{N()},[e,a]);const y=k=>{k.target===k.currentTarget&&i()},m=async k=>{if(!r||!s){alert("Please login to upvote");return}try{const j=Math.round(k*100);await Re.handleUpvote({author:e,permlink:a,weight:j,authToken:r}),h(!1),v(!0),setTimeout(async()=>{await N(),v(!1),_("Vote submitted successfully ✅"),i()},3e3)}catch(j){const A=j instanceof Error?j.message:"Failed to upvote";alert(A)}};return t.jsxs("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 px-4 h-screen",onClick:y,children:[t.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-md max-h-[80vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50 flex items-center justify-between",children:[t.jsxs("h2",{className:"text-lg font-bold text-gray-900 dark:text-white flex items-center space-x-2",children:[t.jsxs("span",{children:["Voters (",u.length,")"]}),g&&t.jsx("span",{className:"inline-flex items-center ml-2",children:t.jsx("span",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})})]}),!o&&t.jsx("button",{onClick:()=>{if(n){n(s,r);return}if(!s||!r){_("Please login to upvote");return}l?_("You have already upvoted this post"):h(!0)},"aria-label":"Open Vote Slider",className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",type:"button",children:t.jsx(z.ThumbsUp,{className:`w-5 h-5 ${l?"text-blue-600 dark:text-blue-400 fill-current":"text-gray-600 dark:text-gray-300"}`})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?t.jsx("div",{className:"flex justify-center items-center h-full p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"})}):o&&!l?t.jsx(ro,{author:e,permlink:a,onUpvote:m,onCancel:()=>h(!1)}):t.jsx("ul",{children:u.map(k=>t.jsxs("li",{className:"flex items-center p-4 border-b dark:border-gray-700",children:[t.jsx("img",{src:`https://images.hive.blog/u/${k.voter}/avatar`,alt:k.voter,className:"w-10 h-10 rounded-full mr-4",onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${k.voter}&background=random`}}),t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold text-gray-900 dark:text-white",children:k.voter}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[((k.percent||0)/100).toFixed(0),"%",k.time&&` · ${lp(k.time+"Z")}`]})]})]},k.voter))})})]}),p&&t.jsx("div",{className:"fixed bottom-4 right-4 w-[280px] z-50",children:t.jsx("div",{className:"bg-gray-800 text-white rounded px-3 py-2 shadow-lg text-sm",children:w})})]})},vd=({isOpen:e,onClose:a,title:i,children:s,maxWidth:r="max-w-2xl"})=>e?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),t.jsxs("div",{className:`relative bg-card border border-border rounded-xl shadow-xl w-full mx-4 ${r} max-h-[90vh] overflow-hidden animate-scale-in`,children:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[t.jsx("h2",{className:"text-xl font-bold text-card-foreground",children:i}),t.jsx("button",{onClick:a,className:"p-2 rounded-lg hover:bg-muted transition-colors",children:t.jsx(z.X,{className:"w-5 h-5 text-muted-foreground"})})]}),t.jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-80px)] custom-scrollbar",children:s})]})]}):null,cp=({author:e,permlink:a,content:i,onClose:s})=>t.jsx(vd,{isOpen:!0,onClose:s,title:"Video Description",maxWidth:"max-w-2xl",children:t.jsxs("div",{className:"p-6",children:[i?t.jsx("div",{className:"prose prose-sm max-w-none",children:t.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:t.jsx("pre",{className:"whitespace-pre-wrap text-sm text-card-foreground font-sans leading-relaxed",children:i})})}):t.jsxs("div",{className:"text-center py-8",children:[t.jsx(z.FileText,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),t.jsx("p",{className:"text-muted-foreground",children:"No description available"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video doesn't have a description yet."})]}),t.jsx("div",{className:"mt-6 pt-4 border-t border-border",children:t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsxs("span",{children:["By @",e]}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:["/",a]})]})})]})}),dp=({username:e,permlink:a,onAuthorClick:i,onVideoClick:s,onTagClick:r,onBack:n,onCommentsModal:u,onUpvotesModal:c,onDescriptionModal:d,onVideoInfo:f,onShare:o,onBookmark:h}={})=>{const l=e,p=a,[x,w]=P.useState(null),[b,g]=P.useState(!0),[v,_]=P.useState(null),[N,y]=P.useState(!1),[m,k]=P.useState(null),[j,A]=P.useState(!1),[D,C]=P.useState(!1),[O,L]=P.useState(!1),[H,F]=P.useState(!1),B=P.useRef(null),$=P.useRef(null),G=P.useRef(null);P.useEffect(()=>{(async()=>{if(!(!l||!p))try{g(!0),_(null);const J=await Re.getVideoDetails(l,p);w(J),y(!1),k(null)}catch(J){_(J instanceof Error?J.message:"Failed to load video")}finally{g(!1)}})()},[l,p]);const X=V=>V?V.startsWith("ipfs://")?`https://ipfs-3speak.b-cdn.net/ipfs/${V.replace("ipfs://","").split("/")[0]}/manifest.m3u8`:V:"";P.useEffect(()=>((async()=>{const J=x?.video_v2;if(!N||!J||!B.current)return;const oe=B.current,K=X(J);$.current&&($.current.destroy(),$.current=null),oe.src="",oe.load();try{let te=!1;const pe=()=>{te||(te=!0,oe.play().then(()=>k(null)).catch(xe=>k(`Playback failed: ${xe.message}`)))};if(Qr.isSupported()){const xe=new Qr({debug:!1,enableWorker:!1,lowLatencyMode:!1,backBufferLength:90,maxLoadingDelay:4,maxBufferLength:30,maxMaxBufferLength:600,startLevel:-1});$.current=xe,xe.on(Qr.Events.MANIFEST_PARSED,()=>{}),xe.on(Qr.Events.ERROR,(ge,ke)=>{if(ke.fatal)switch(ke.type){case Qr.ErrorTypes.NETWORK_ERROR:k("Network error, retrying..."),setTimeout(()=>xe.startLoad(),1e3);break;case Qr.ErrorTypes.MEDIA_ERROR:k("Media error, retrying..."),setTimeout(()=>xe.recoverMediaError(),1e3);break;default:k(`Fatal error: ${ke.details}`),xe.destroy(),$.current=null;break}}),xe.attachMedia(oe),xe.loadSource(K)}else if(oe.canPlayType("application/vnd.apple.mpegurl"))oe.src=K;else{const xe=K.replace("/manifest.m3u8","/480p/index.m3u8");oe.src=xe}const Ee=()=>A(!0),Z=()=>{A(!1),pe()},ae=xe=>{const ge=xe.target;k(`Video error: ${ge.error?.message||"Unknown error"}`),A(!1)},re=()=>A(!1);oe.addEventListener("loadstart",Ee),oe.addEventListener("canplay",Z),oe.addEventListener("error",ae),oe.addEventListener("loadeddata",re);const ce=async()=>{const xe=!!document.fullscreenElement;try{xe?"orientation"in screen&&await(screen.orientation?.lock?.("landscape")??Promise.resolve()):"orientation"in screen&&screen.orientation?.unlock?.()}catch{}};return document.addEventListener("fullscreenchange",ce),G.current=()=>{document.removeEventListener("fullscreenchange",ce)},()=>{oe.removeEventListener("loadstart",Ee),oe.removeEventListener("canplay",Z),oe.removeEventListener("error",ae),oe.removeEventListener("loadeddata",re),G.current&&G.current()}}catch(te){k(`Setup error: ${te instanceof Error?te.message:"Unknown"}`)}})(),()=>{$.current&&($.current.destroy(),$.current=null)}),[N,x?.video_v2]);const ee=()=>{if(!x?.video_v2){k("No video source available");return}y(!0),k(null),A(!0)},R=V=>{s&&s(V)},se=V=>{i&&i(V)},I=V=>{if(!V)return"00:00";const J=Math.floor(V),oe=Math.floor(J/3600),K=Math.floor(J%3600/60),te=J%60,pe=Ee=>Ee.toString().padStart(2,"0");return J<60?`00:${pe(te)}`:oe===0?`${pe(K)}:${pe(te)}`:`${pe(oe)}:${pe(K)}:${pe(te)}`};return b?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("div",{className:"sticky top-0 z-50 w-full bg-background border-b border-border",children:t.jsx("div",{className:"container mx-auto px-4 py-3",children:t.jsx("div",{className:"h-8 w-24 bg-muted rounded-full animate-pulse"})})}),t.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:t.jsxs("div",{className:"animate-pulse space-y-6",children:[t.jsx("div",{className:"aspect-video bg-muted rounded-xl"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})]})})]}):v||!x?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsxs("div",{className:"text-center max-w-md mx-auto px-4",children:[t.jsx("h2",{className:"text-xl font-semibold text-card-foreground mb-2",children:"Failed to Load Video"}),t.jsx("p",{className:"text-muted-foreground mb-4",children:v||"Video not found"}),t.jsxs("button",{onClick:()=>{n&&n()},className:"inline-flex items-center gap-2 px-4 py-2 bg-card border border-border text-card-foreground rounded-lg hover:bg-card-hover transition-colors",children:[t.jsx(z.ArrowLeft,{className:"w-4 h-4"}),"Go Back"]})]})}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("div",{className:"sticky top-0 z-50 w-full bg-background/95 backdrop-blur-sm border-b border-border",children:t.jsx("div",{className:"container mx-auto px-4 py-3",children:t.jsxs("button",{onClick:()=>{n&&n()},className:"inline-flex items-center gap-2 text-muted-foreground hover:text-card-foreground transition-colors",children:[t.jsx(z.ArrowLeft,{className:"w-4 h-4"}),"Back"]})})}),t.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsx("div",{className:"w-full aspect-video bg-black rounded-xl overflow-hidden relative shadow-card",children:N?t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("video",{ref:B,controls:!0,poster:Br(x.thumbnail),className:"w-full h-full object-contain bg-black",onDoubleClick:async V=>{const J=V.currentTarget;try{document.fullscreenElement?await document.exitFullscreen():await J.requestFullscreen()}catch{}}}),j&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),m&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80",children:t.jsxs("div",{className:"text-center text-white",children:[t.jsx("p",{className:"mb-4",children:m}),t.jsx("button",{onClick:()=>{y(!1),k(null)},className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover transition-colors",children:"Try Again"})]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("img",{src:Br(x.thumbnail)||`https://images.hive.blog/u/${x.owner}/avatar`,alt:x.title,className:"w-full h-full object-cover",onError:V=>{V.target.src=`https://images.hive.blog/u/${x.owner}/avatar`}}),t.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-30"}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("button",{onClick:ee,className:"bg-primary hover:bg-primary-hover rounded-full p-6 transform hover:scale-110 transition-all duration-300 shadow-lg",children:t.jsx(z.Play,{className:"w-8 h-8 text-primary-foreground ml-1",fill:"currentColor"})})}),x.duration&&t.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/80 text-white text-sm px-3 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[t.jsx(z.Clock,{className:"w-3 h-3"}),I(x.duration)]}),x.views&&t.jsxs("div",{className:"absolute bottom-4 left-4 bg-black/80 text-white text-sm px-3 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[t.jsx(z.Eye,{className:"w-3 h-3"}),x.views.toLocaleString()," views"]})]})}),t.jsx(Ec,{title:x.title||"",author:x.owner||"",permlink:x.permlink||"",createdAt:x.created,description:x.description||"",video:{title:x.title||"",author:x.owner||"",permlink:x.permlink||"",created:x.created||new Date,category:x.category||"",numOfUpvotes:void 0,numOfComments:void 0,hiveValue:void 0,duration:x.duration,thumbnail:x.thumbnail,views:x.views},onTapComment:()=>{u?u(l,p):C(!0)},onTapUpvote:()=>{c?c(l,p):L(!0)},onTapInfo:()=>{d?d(l,p,x.description||""):F(!0)},onTapAuthor:()=>{i&&i(x.owner)},onTapShare:()=>{o&&o(l,p)},onTapBookmark:()=>{h&&h(l,p)}}),x.tags&&t.jsx("div",{className:"flex flex-wrap gap-2",children:x.tags.split(",").map((V,J)=>t.jsxs("span",{className:"bg-primary/10 text-primary px-3 py-1 rounded-full text-sm font-medium hover:bg-primary/20 transition-colors cursor-pointer",onClick:()=>{r&&r(V.trim())},children:["#",V.trim()]},J))})]}),t.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 sticky top-24",children:[t.jsx("h3",{className:"font-semibold text-card-foreground mb-4 text-lg",children:"Related Videos"}),t.jsx("div",{className:"space-y-4",children:t.jsx(ss,{feedType:Ge.RELATED,username:x.owner,onVideoClick:R,onAuthorClick:se})})]})]})}),D&&l&&p&&t.jsx(ao,{author:l,permlink:p,onClose:()=>C(!1)}),O&&l&&p&&t.jsx(yd,{author:l,permlink:p,onClose:()=>L(!1)}),H&&l&&p&&t.jsx(cp,{author:l,permlink:p,content:x.description||"",onClose:()=>F(!1)})]})};var wd={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},hc=P.createContext&&P.createContext(wd),fp=["attr","size","title"];function hp(e,a){if(e==null)return{};var i=pp(e,a),s,r;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)s=n[r],!(a.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(i[s]=e[s])}return i}function pp(e,a){if(e==null)return{};var i={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(a.indexOf(s)>=0)continue;i[s]=e[s]}return i}function rs(){return rs=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},rs.apply(this,arguments)}function pc(e,a){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function as(e){for(var a=1;a<arguments.length;a++){var i=arguments[a]!=null?arguments[a]:{};a%2?pc(Object(i),!0).forEach(function(s){mp(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):pc(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function mp(e,a,i){return a=gp(a),a in e?Object.defineProperty(e,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[a]=i,e}function gp(e){var a=bp(e,"string");return typeof a=="symbol"?a:a+""}function bp(e,a){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function _d(e){return e&&e.map((a,i)=>P.createElement(a.tag,as({key:i},a.attr),_d(a.child)))}function la(e){return a=>P.createElement(xp,rs({attr:as({},e.attr)},a),_d(e.child))}function xp(e){var a=i=>{var{attr:s,size:r,title:n}=e,u=hp(e,fp),c=r||i.size||"1em",d;return i.className&&(d=i.className),e.className&&(d=(d?d+" ":"")+e.className),P.createElement("svg",rs({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,s,u,{className:d,style:as(as({color:e.color||i.color},i.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),n&&P.createElement("title",null,n),e.children)};return hc!==void 0?P.createElement(hc.Consumer,null,i=>a(i)):a(wd)}function yp(e){return la({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M296 160H180.6l42.6-129.8C227.2 15 215.7 0 200 0H56C44 0 33.8 8.9 32.2 20.8l-32 240C-1.7 275.2 9.5 288 24 288h118.7L96.6 482.5c-3.6 15.2 8 29.5 23.3 29.5 8.4 0 16.4-4.4 20.8-12l176-304c9.3-15.9-2.2-36-20.7-36z"},child:[]}]})(e)}function vp(e){return la({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 405.3V448c0 35.3 86 64 192 64s192-28.7 192-64v-42.7C342.7 434.4 267.2 448 192 448S41.3 434.4 0 405.3zM320 128c106 0 192-28.7 192-64S426 0 320 0 128 28.7 128 64s86 64 192 64zM0 300.4V352c0 35.3 86 64 192 64s192-28.7 192-64v-51.6c-41.3 34-116.9 51.6-192 51.6S41.3 334.4 0 300.4zm416 11c57.3-11.1 96-31.7 96-55.4v-42.7c-23.2 16.4-57.3 27.6-96 34.5v63.6zM192 160C86 160 0 195.8 0 240s86 80 192 80 192-35.8 192-80-86-80-192-80zm219.3 56.3c60-10.8 100.7-32 100.7-56.3v-42.7c-35.5 25.1-96.5 38.6-160.7 41.8 29.5 14.3 51.2 33.5 60 57.2z"},child:[]}]})(e)}function wp(e){return la({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(e)}function _p(e){return la({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M608 64H32C14.33 64 0 78.33 0 96v320c0 17.67 14.33 32 32 32h576c17.67 0 32-14.33 32-32V96c0-17.67-14.33-32-32-32zM48 400v-64c35.35 0 64 28.65 64 64H48zm0-224v-64h64c0 35.35-28.65 64-64 64zm272 176c-44.19 0-80-42.99-80-96 0-53.02 35.82-96 80-96s80 42.98 80 96c0 53.03-35.83 96-80 96zm272 48h-64c0-35.35 28.65-64 64-64v64zm0-224c-35.35 0-64-28.65-64-64h64v64z"},child:[]}]})(e)}function kp(e){return la({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M560 224h-29.5c-8.8-20-21.6-37.7-37.4-52.5L512 96h-32c-29.4 0-55.4 13.5-73 34.3-7.6-1.1-15.1-2.3-23-2.3H256c-77.4 0-141.9 55-156.8 128H56c-14.8 0-26.5-13.5-23.5-28.8C34.7 215.8 45.4 208 57 208h1c3.3 0 6-2.7 6-6v-20c0-3.3-2.7-6-6-6-28.5 0-53.9 20.4-57.5 48.6C-3.9 258.8 22.7 288 56 288h40c0 52.2 25.4 98.1 64 127.3V496c0 8.8 7.2 16 16 16h64c8.8 0 16-7.2 16-16v-48h128v48c0 8.8 7.2 16 16 16h64c8.8 0 16-7.2 16-16v-80.7c11.8-8.9 22.3-19.4 31.3-31.3H560c8.8 0 16-7.2 16-16V240c0-8.8-7.2-16-16-16zm-128 64c-8.8 0-16-7.2-16-16s7.2-16 16-16 16 7.2 16 16-7.2 16-16 16zM256 96h128c5.4 0 10.7.4 15.9.8 0-.3.1-.5.1-.8 0-53-43-96-96-96s-96 43-96 96c0 2.1.5 4.1.6 6.2 15.2-3.9 31-6.2 47.4-6.2z"},child:[]}]})(e)}function Np(e){return la({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M461.2 128H80c-8.84 0-16-7.16-16-16s7.16-16 16-16h384c8.84 0 16-7.16 16-16 0-26.51-21.49-48-48-48H64C28.65 32 0 60.65 0 96v320c0 35.35 28.65 64 64 64h397.2c28.02 0 50.8-21.53 50.8-48V176c0-26.47-22.78-48-50.8-48zM416 336c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z"},child:[]}]})(e)}const no=new Id.Client(["https://api.hive.blog"]),jp=async e=>{try{const a=await no.database.getAccounts([e]);if(!a||a.length===0)throw new Error("Account not found");return a[0]}catch(a){return console.error("Error in getWalletDataDetail:",a),{error:a instanceof Error?a.message:"Unknown error"}}},Ep=async e=>{try{const a=await no.database.getDynamicGlobalProperties(),i=parseFloat(e.split(" ")[0]),s=parseFloat(String(a.total_vesting_shares).split(" ")[0]),r=parseFloat(String(a.total_vesting_fund_hive).split(" ")[0]);return(i*r/s).toFixed(3)}catch(a){return console.error("Error in convertVestingSharesToHiveData:",a),"0"}},Ap=async e=>{try{const i=(await no.database.call("get_feed_history",[])).current_median_history,s=parseFloat(i.base.split(" ")[0]),r=typeof e=="string"?parseFloat(e):e;return(s*r).toFixed(2)}catch(a){return console.error("Error in convertHivetoUSDData:",a),"0"}},kd=_c.create(e=>({walletData:null,isLoading:!1,error:null,setWalletData:a=>e({walletData:a}),clearWalletData:()=>e({walletData:null,error:null}),fetchWalletData:async a=>{e({isLoading:!0,error:null});try{const i=await jp(a),s=w=>"error"in w;if(!i||s(i))throw new Error(s(i)?i.error:"Account not found");const r=typeof i.vesting_shares=="string"?i.vesting_shares:"0.000000 VESTS",n=typeof i.balance=="string"?i.balance:i.balance.toString(),u=typeof i.hbd_balance=="string"?i.hbd_balance:i.hbd_balance.toString(),c=typeof i.savings_balance=="string"?i.savings_balance:i.savings_balance.toString(),d=typeof i.savings_hbd_balance=="string"?i.savings_hbd_balance:i.savings_hbd_balance.toString(),f=await Ep(r),o=parseFloat(n.split(" ")[0]||"0"),h=parseFloat(f),l=(o+h).toFixed(3),p=await Ap(l),x={balance:n,hbd_balance:u,savings_balance:c,savings_hbd_balance:d,hive_power:`${f} HP`,estimated_value:`$${p}`};return e({walletData:x}),x}catch(i){const s=i instanceof Error?i.message:"Failed to fetch wallet data";console.error("Wallet fetch error:",s);const r={balance:"0.000 HIVE",hbd_balance:"0.000 HBD",savings_balance:"0.000 HIVE",savings_hbd_balance:"0.000 HBD",hive_power:"0 HP",estimated_value:"$0.00",error:s};return e({walletData:r,error:s}),r}finally{e({isLoading:!1})}}})),Sp=({username:e,className:a=""})=>{const{walletData:i,fetchWalletData:s,isLoading:r,error:n}=kd();P.useEffect(()=>{e&&s(e)},[e,s]);const u=({label:c,value:d,icon:f,colorClass:o="bg-primary/10"})=>t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-card border border-border shadow-sm mb-3 transition-all duration-200 hover:shadow-md",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[f&&t.jsx("div",{className:`p-2 rounded-full flex items-center justify-center ${o} text-primary`,children:f}),t.jsx("span",{className:"font-semibold text-card-foreground",children:c})]}),t.jsx("span",{className:"font-medium text-muted-foreground",children:d??"-"})]});return t.jsx("div",{className:`min-h-screen bg-gradient-elegant p-4 transition-all duration-300 ${a}`,children:t.jsxs("div",{className:"max-w-md mx-auto",children:[t.jsxs("div",{className:"flex flex-col items-center p-6 mb-6 rounded-xl bg-card border border-border shadow-elegant",children:[e&&t.jsx("img",{src:`https://images.hive.blog/u/${e}/avatar`,alt:`${e} avatar`,className:"w-20 h-20 rounded-full border-4 border-primary/20 mb-3 transition-transform hover:scale-105",onError:c=>{c.target.src=`https://ui-avatars.com/api/?name=${e}&background=random`}}),t.jsx("div",{className:"text-lg font-bold text-card-foreground",children:e}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Hive Wallet Overview"})]}),t.jsxs("div",{className:"text-center rounded-xl bg-gradient-primary shadow-glow p-6 mb-6 transition-all duration-300 hover:shadow-elegant",children:[t.jsx("div",{className:"text-sm font-semibold text-primary-foreground/80",children:"Estimated Value"}),t.jsx("div",{className:"text-3xl font-bold mt-2 text-primary-foreground",children:r?t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"}),"Loading..."]}):i?.estimated_value??"-"})]}),n&&t.jsxs("div",{className:"flex items-center p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive mb-4",children:[t.jsx(wp,{className:"mr-2"}),t.jsx("span",{children:n})]}),t.jsx(u,{label:"Balance",value:i?.balance,icon:t.jsx(Np,{}),colorClass:"bg-blue-500/10"}),t.jsx(u,{label:"HBD Balance",value:i?.hbd_balance,icon:t.jsx(_p,{}),colorClass:"bg-green-500/10"}),t.jsx(u,{label:"Savings Balance",value:i?.savings_balance,icon:t.jsx(kp,{}),colorClass:"bg-yellow-500/10"}),t.jsx(u,{label:"Savings HBD Balance",value:i?.savings_hbd_balance,icon:t.jsx(vp,{}),colorClass:"bg-purple-500/10"}),t.jsx(u,{label:"Hive Power",value:i?.hive_power,icon:t.jsx(yp,{}),colorClass:"bg-orange-500/10"})]})})};function Nd({sort:e="trending",tag:a="",observer:i="hive.blog",limit:s=20,showSortDropdown:r=!0,theme:n="dark",onAuthorClick:u,onPostClick:c,onCommunityClick:d,onPayoutClick:f,onUpvoteClick:o,onCommentClick:h,onReblogClick:l}){const[p,x]=P.useState([]),[w,b]=P.useState(!0),[g,v]=P.useState(null),[_,N]=P.useState(e),[y,m]=P.useState(!0),[k,j]=P.useState(!1),A=P.useRef(null);new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:B=>B,usertagUrlFn:B=>`/@${B}`,hashtagUrlFn:B=>`/trending/${B}`,isLinkSafeFn:B=>!0,addExternalCssClassToMatchingLinksFn:B=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"});const D=P.useCallback(async(B,$=!1)=>{$?j(!0):(b(!0),m(!0)),v(null);try{const G=$&&p.length>0?p[p.length-1]:null,X=await Re.getRankedPosts(B,a,i,s,G?.author,G?.permlink);$?(x(ee=>{const R=new Set(ee.map(I=>I.post_id)),se=X.filter(I=>!R.has(I.post_id));return[...ee,...se]}),m(X.length===s)):(x(X),m(X.length===s))}catch(G){v(G instanceof Error?G.message:"Failed to load posts"),m(!1)}finally{b(!1),j(!1)}},[a,i,s,p]),C=P.useCallback(()=>{!k&&y&&!w&&D(_,!0)},[k,y,w,_,D]);P.useEffect(()=>{D(_)},[_,a,i,s]),P.useEffect(()=>{const B=new IntersectionObserver($=>{$[0].isIntersecting&&C()},{threshold:1});return A.current&&B.observe(A.current),()=>{A.current&&B.unobserve(A.current)}},[C]);const O=B=>{N(B),x([]),m(!0)},L=B=>B>=1e6?`${(B/1e6).toFixed(1)}M`:B>=1e3?`${(B/1e3).toFixed(1)}K`:B.toString(),H=B=>{const $=B.payout*.5,G=B.payout*.5,ee=(B.beneficiaries.find(R=>R.account==="commentrewarder")?.weight||0)/1e4*100;return{pending:`$${B.payout.toFixed(2)}`,breakdown:`${$.toFixed(2)} HBD, ${G.toFixed(2)} HP`,commentRewarder:`${ee.toFixed(2)}%`,payoutInDays:Math.ceil((new Date(B.payout_at).getTime()-Date.now())/(1e3*60*60*24))}},F=B=>{const G=(B.body||"").replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#+\s*/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/<[^>]*>/g,"").replace(/\n+/g," ").trim();return G.length>200?G.substring(0,200)+"...":G};return w?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(z.Loader2,{className:"w-8 h-8 animate-spin"})}):g?t.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-card-foreground",children:"Failed to load posts"}),t.jsx("p",{className:"text-muted-foreground",children:g}),t.jsx("button",{onClick:()=>D(_),className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90",children:"Retry"})]}):t.jsx("div",{className:n==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[r&&t.jsx("div",{className:"flex justify-center",children:t.jsxs("select",{value:_,onChange:B=>O(B.target.value),className:`px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary ${n==="dark"?"bg-slate-950 text-white":"bg-card text-card-foreground"}`,children:[t.jsx("option",{value:"trending",children:"Trending"}),t.jsx("option",{value:"hot",children:"Hot"}),t.jsx("option",{value:"created",children:"New"})]})}),t.jsxs("div",{className:"space-y-4",children:[p.map(B=>{const $=B.json_metadata?.image?.[0],G=H(B);return t.jsxs("div",{className:`border border-border rounded-xl p-4 shadow-card hover:shadow-card-hover transition-shadow ${n==="dark"?"bg-slate-900 text-white":"bg-slate-50 text-black"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("img",{src:`https://images.hive.blog/u/${B.author}/avatar`,alt:B.author,className:"w-8 h-8 rounded-full cursor-pointer flex-shrink-0",onClick:()=>u?.(B.author,`https://images.hive.blog/u/${B.author}/avatar`),onError:X=>{X.target.src=`https://ui-avatars.com/api/?name=${B.author}&background=random`}}),t.jsx("span",{className:"font-medium cursor-pointer hover:text-primary",onClick:()=>u?.(B.author,`https://images.hive.blog/u/${B.author}/avatar`),children:B.author}),t.jsxs("span",{className:n==="dark"?"text-gray-400":"text-muted-foreground",children:["(",B.author_reputation.toFixed(2),")"]}),t.jsx("span",{className:`cursor-pointer hover:text-primary ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>d?.(B.community_title),children:B.community_title}),t.jsx("span",{className:`hidden sm:inline ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"•"}),t.jsx("span",{className:`text-sm ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:ns.formatDistanceToNow(new Date(B.created+"Z"),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex gap-3 sm:gap-4",children:[t.jsx("div",{className:"flex-shrink-0",children:$?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:$.startsWith("http")?$:`https://images.hive.blog/u/320x0/${$}`,alt:B.title,className:"w-20 h-20 sm:w-32 sm:h-32 object-cover rounded-lg cursor-pointer",onClick:()=>c?.(B),onError:X=>{X.target.src!==`https://images.hive.blog/u/${B.author}/avatar`?X.target.src=`https://images.hive.blog/u/${B.author}/avatar`:X.target.src="https://images.hive.blog/u/null/avatar"}}),(()=>{const X=B.body?.match(/!\[[^\]]*\]\(([^)]+)\)/g)?.map(ee=>{const R=ee.match(/\(([^)]+)\)/);return R?R[1]:null}).filter(Boolean)||[];return X.length>0?t.jsx("div",{className:"absolute -bottom-1 -right-1 sm:-bottom-2 sm:-right-2 flex space-x-1",children:X.slice(0,3).map((ee,R)=>t.jsx("img",{src:ee,alt:`body-image-${R}`,className:"w-6 h-6 sm:w-8 sm:h-8 object-cover rounded border-2 border-white shadow-sm cursor-pointer",onClick:se=>{se.stopPropagation();const I=se.currentTarget.parentElement?.parentElement?.querySelector("img:not(.w-6):not(.w-8)");I&&(I.src=ee)}},R))}):null})()]}):t.jsx("img",{src:`https://images.hive.blog/u/${B.author}/avatar`,alt:B.author,className:"w-20 h-20 sm:w-32 sm:h-32 rounded-lg cursor-pointer",onClick:()=>c?.(B)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-1 sm:mb-2 cursor-pointer hover:text-primary line-clamp-2",onClick:()=>c?.(B),children:B.title}),t.jsx("p",{className:`mb-2 sm:mb-3 line-clamp-2 sm:line-clamp-3 cursor-pointer hover:text-primary text-sm sm:text-base ${n==="dark"?"text-gray-300":"text-gray-600"}`,onClick:()=>c?.(B),children:B.json_metadata?.description||F(B)||"No description available"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"relative group",children:[t.jsxs("span",{className:"font-semibold text-green-600 cursor-pointer hover:text-green-700 text-sm sm:text-base",onClick:()=>f?.(B.payout),children:["$",B.payout.toFixed(2)]}),t.jsxs("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block bg-black text-white text-xs p-2 rounded shadow-lg whitespace-nowrap z-10",children:[t.jsxs("div",{children:["Pending payout amount: ",G.pending]}),t.jsxs("div",{children:["Breakdown: ",G.breakdown]}),t.jsxs("div",{children:["commentrewarder: ",G.commentRewarder]}),t.jsxs("div",{children:["Payout in ",G.payoutInDays," days"]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[t.jsxs("div",{className:`flex items-center gap-1 hover:text-primary transition-colors cursor-pointer ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>o?.(B),children:[t.jsx(z.ThumbsUp,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.stats.total_votes)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-blue-400 transition-colors cursor-pointer ${n==="dark"?"text-blue-400":"text-blue-600"}`,onClick:()=>h?.(B),children:[t.jsx(z.MessageCircle,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.children)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-gray-400 transition-colors cursor-pointer ${n==="dark"?"text-gray-400":"text-gray-600"}`,onClick:()=>l?.(B),children:[t.jsx(z.Repeat2,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:L(B.reblogs)})]})]})]})]})]})]},B.post_id)}),k&&t.jsxs("div",{className:"flex justify-center items-center py-4",children:[t.jsx(z.Loader2,{className:"w-6 h-6 animate-spin"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"Loading more posts..."})]}),y&&!k&&t.jsx("div",{ref:A,className:"h-10"})]})]})})}class sa{static instance;static getInstance(){return sa.instance||(sa.instance=new sa),sa.instance}async getProposals(a){return a==="expired"?this.getExpiredProposals():this.getActiveProposals()}async getActiveProposals(){try{const s=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:72,jsonrpc:"2.0",method:"database_api.list_proposals",params:{start:[-1],limit:500,order:"by_total_votes",order_direction:"descending",status:"votable"}})})).json()).result.proposals,n=await(await fetch("https://stats.hivehub.dev/dhf_proposals")).json(),u={};n.forEach(h=>{u[h.proposal_id]=h});const f=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:73,jsonrpc:"2.0",method:"database_api.list_proposal_votes",params:{start:["shaktimaaan"],limit:1e3,order:"by_voter_proposal",order_direction:"ascending",status:"votable"}})})).json()).result.proposal_votes||[],o={};return f.forEach(h=>{o[h.proposal.proposal_id]||(o[h.proposal.proposal_id]=[]),o[h.proposal.proposal_id].push(h)}),s.map(h=>{const l=h.id,p=u[l],x=o[l]||[],w=x.reduce((b,g)=>b+parseFloat(g.total_hbd||"0"),0);return{proposal_id:l,subject:h.subject,permlink:h.permlink,creator:h.creator,receiver:h.receiver,start_date:h.start_date,end_date:h.end_date,total_hbd_received:p?p.total_hbd_received:"0",max_hbd_remaining:p?p.max_hbd_remaining:"0",all_votes_num:h.total_votes||"0",all_votes_hp:p?p.all_votes_hp:w.toString(),votes:p?p.votes:x,status:h.status,daily_pay:h.daily_pay,total_votes:h.total_votes,daily_pay_hbd:h.daily_pay?Number(h.daily_pay.amount)/Math.pow(10,h.daily_pay.precision):0,remaining_days:Math.max(0,Math.ceil((new Date(h.end_date).getTime()-new Date().getTime())/(1e3*60*60*24))),vote_value_total:p?parseFloat(p.all_votes_hp):w}})}catch(a){return console.error("Error fetching active proposals:",a),[]}}async getExpiredProposals(){try{const s=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:65,jsonrpc:"2.0",method:"database_api.list_proposals",params:{start:[-1],limit:500,order:"by_total_votes",order_direction:"descending",status:"expired"}})})).json()).result.proposals,n=await(await fetch("https://stats.hivehub.dev/dhf_proposals")).json(),u={};n.forEach(h=>{u[h.proposal_id]=h});const f=(await(await fetch("https://api.hive.blog/",{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7","content-type":"application/json",origin:"https://peakd.com","sec-ch-ua":'"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"macOS"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"},body:JSON.stringify({id:76,jsonrpc:"2.0",method:"database_api.list_proposal_votes",params:{start:["shaktimaaan"],limit:1e3,order:"by_voter_proposal",order_direction:"ascending",status:"expired"}})})).json()).result.proposal_votes||[],o={};return f.forEach(h=>{o[h.proposal_id]||(o[h.proposal_id]=[]),o[h.proposal_id].push(h)}),s.map(h=>{const l=h.id,p=u[l],x=o[l]||[],w=x.reduce((b,g)=>b+parseFloat(g.total_hbd||"0"),0);return{proposal_id:l,subject:h.subject,permlink:h.permlink,creator:h.creator,receiver:h.receiver,start_date:h.start_date,end_date:h.end_date,total_hbd_received:p?p.total_hbd_received:"0",max_hbd_remaining:p?p.max_hbd_remaining:"0",all_votes_num:h.total_votes||"0",all_votes_hp:p?p.all_votes_hp:w.toString(),votes:p?p.votes:x,status:h.status,daily_pay:h.daily_pay,total_votes:h.total_votes,daily_pay_hbd:h.daily_pay?Number(h.daily_pay.amount)/Math.pow(10,h.daily_pay.precision):0,remaining_days:0,vote_value_total:p?parseFloat(p.all_votes_hp):w}})}catch(a){return console.error("Error fetching expired proposals:",a),[]}}}const mc=sa.getInstance(),Cp=["All","Active","Upcoming","Expired","By Peak Projects"],jd=["Votes","Start Date","End Date","Creator"],gc=e=>e==="By Peak Projects"?["Creator"]:jd,it=e=>{const a=typeof e=="string"?parseFloat(e):e;return isNaN(a)?e.toString():a.toLocaleString()},Si=e=>{const a=new Date(e.start_date),i=new Date(e.end_date);return`(${Math.ceil((i.getTime()-a.getTime())/(1e3*60*60*24))} days)`},Dp=({onClickSupport:e,onClickVoteValue:a,onClickSelect:i,onClickUser:s,onClickAvatar:r,theme:n="dark"})=>{const[u,c]=P.useState([]),[d,f]=P.useState("All"),[o,h]=P.useState("Votes");P.useEffect(()=>{d==="By Peak Projects"&&!gc(d).includes(o)?h("Creator"):d!=="By Peak Projects"&&o==="Creator"&&!jd.includes(o)&&h("Votes")},[d,o]);const[l,p]=P.useState(!0);P.useEffect(()=>{(async()=>{p(!0);try{const[g,v]=await Promise.all([mc.getProposals("active"),mc.getProposals("expired")]);c([...g,...v])}catch(g){console.error("Error fetching proposals:",g),c([])}p(!1)})()},[]);const x=u.filter(b=>d==="All"?b.status==="active"||new Date(b.start_date+"Z")>new Date:d==="Active"?b.status==="active":d==="Upcoming"?new Date(b.start_date+"Z")>new Date:d==="Expired"?new Date(b.end_date+"Z")<new Date:d==="By Peak Projects"?b.creator==="peakd":!0).sort((b,g)=>d==="By Peak Projects"?g.creator.localeCompare(b.creator):0),w=d==="All"?(()=>{const b=x.filter(_=>_.status==="active"),g=x.filter(_=>new Date(_.start_date+"Z")>new Date),v=(_,N)=>o==="Votes"?Number(N.all_votes_num)-Number(_.all_votes_num):o==="Start Date"?new Date(N.start_date+"Z").getTime()-new Date(_.start_date+"Z").getTime():o==="End Date"?new Date(_.end_date+"Z").getTime()-new Date(N.end_date+"Z").getTime():o==="Creator"?_.creator.localeCompare(N.creator):0;return[...b.sort(v),...g.sort(v)]})():x.sort((b,g)=>o==="Votes"?Number(g.all_votes_num)-Number(b.all_votes_num):o==="Start Date"?new Date(g.start_date+"Z").getTime()-new Date(b.start_date+"Z").getTime():o==="End Date"?new Date(b.end_date+"Z").getTime()-new Date(g.end_date+"Z").getTime():o==="Creator"?b.creator.localeCompare(g.creator):0);return l?t.jsx("div",{className:"flex justify-center items-center py-8",children:t.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading proposals..."})}):t.jsx("div",{className:n==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:Cp.map(b=>t.jsx("button",{className:`px-3 py-1 rounded text-sm ${d===b?"bg-blue-500 text-white":`${n==="dark"?"bg-slate-900 text-gray-300":"bg-gray-200 text-gray-700"}`}`,onClick:()=>f(b),children:b},b))}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:`${n==="dark"?"text-gray-300":"text-gray-700"} mr-2`,children:"Sort by:"}),t.jsx("select",{value:o,onChange:b=>h(b.target.value),className:`px-3 py-1 border rounded ${n==="dark"?"border-gray-600 bg-slate-900 text-gray-100":"border-gray-300 bg-white text-gray-900"}`,children:gc(d).map(b=>t.jsx("option",{value:b,children:b},b))})]}),t.jsxs("div",{children:[d==="All"&&(()=>{const b=w.filter(v=>v.status==="active"),g=w.filter(v=>new Date(v.start_date+"Z")>new Date);return t.jsxs(t.Fragment,{children:[b.map(v=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-900":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(v),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${v.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${v.creator} avatar`})}),t.jsxs("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(v),children:["by ",v.creator]}),v.receiver&&t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:v.receiver})]})]}),t.jsxs("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(v),children:[v.subject," ",t.jsxs("span",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-500":"text-gray-600"}`,children:["#",v.proposal_id]})]}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(v.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(v.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":v.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(v.start_date+"Z")>new Date?"upcoming":new Date(v.end_date+"Z")<new Date?"expired":v.status})," - "+new Date(v.start_date+"Z").toLocaleDateString()+" - "+new Date(v.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(v)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/${v.creator}/${v.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${v.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(v),children:["Vote value: ",v.vote_value_total?it(v.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Daily Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[v.daily_pay_hbd?it(v.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Remaining:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.remaining_days||0)," Days"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Paid:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"To Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(v),children:"Support"})})]})]})},v.proposal_id)),g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"my-6 text-center",children:[t.jsx("h3",{className:`text-xl font-bold mb-2 ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:"Upcoming proposals"}),t.jsx("p",{className:`${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"The proposals listed below will start in the future. You can already support them."})]}),g.map(v=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-950":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(v),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${v.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${v.creator} avatar`})}),t.jsx("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(v),children:v.creator}),t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:v.receiver})]})]}),t.jsx("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(v),children:v.subject}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(v.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(v.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":v.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(v.start_date+"Z")>new Date?"upcoming":new Date(v.end_date+"Z")<new Date?"expired":v.status})," - "+new Date(v.start_date+"Z").toLocaleDateString()+" - "+new Date(v.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(v)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/${v.creator}/${v.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${v.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(v),children:["Vote value: ",v.vote_value_total?it(v.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Daily Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[v.daily_pay_hbd?it(v.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Remaining:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.remaining_days||0)," Days"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"Paid:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:`font-mono text-xs sm:text-sm ${n==="dark"?"text-gray-400":"text-gray-600"}`,children:"To Pay:"}),t.jsxs("strong",{className:`text-xs sm:text-sm ${n==="dark"?"text-gray-100":"text-gray-900"}`,children:[it(v.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(v),children:"Support"})})]})]})},v.proposal_id))]})]})})(),d!=="All"&&w.map(b=>t.jsx("div",{className:`border rounded-lg mb-4 p-2 sm:p-4 shadow ${n==="dark"?"border-gray-800 bg-slate-950":"border-gray-200 bg-white"}`,children:t.jsxs("div",{className:"flex flex-col sm:flex-row",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx("span",{onClick:()=>r(b),className:"inline-block mr-2 cursor-pointer",children:t.jsx("img",{src:`https://images.hive.blog/u/${b.creator}/avatar`,className:"w-8 h-8 rounded-full inline",alt:`${b.creator} avatar`})}),t.jsx("span",{className:`font-bold cursor-pointer ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>s(b),children:b.creator}),t.jsxs("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["with receiver ",t.jsx("strong",{className:`${n==="dark"?"text-gray-100":"text-gray-900"}`,children:b.receiver})]})]}),t.jsxs("div",{className:`cursor-pointer text-lg font-semibold mb-1 ${n==="dark"?"text-gray-100":"text-gray-900"}`,onClick:()=>i(b),children:[b.subject," #",b.proposal_id]}),t.jsxs("div",{className:`text-sm mb-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${new Date(b.start_date+"Z")>new Date?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":new Date(b.end_date+"Z")<new Date?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":b.status==="active"?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:new Date(b.start_date+"Z")>new Date?"upcoming":new Date(b.end_date+"Z")<new Date?"expired":b.status})," - "+new Date(b.start_date+"Z").toLocaleDateString()+" - "+new Date(b.end_date+"Z").toLocaleDateString()," ",t.jsx("span",{className:`text-xs ${n==="dark"?"text-gray-500":"text-gray-400"}`,children:Si(b)})]}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("button",{onClick:()=>window.open(`https://peakd.com/@${b.creator}/${b.permlink}`,"_blank"),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",title:"View on Peakd",children:t.jsx(z.ExternalLink,{size:16})}),t.jsxs("button",{onClick:()=>window.open(`https://hivehub.dev/proposals/${b.proposal_id}`,"_blank"),className:"flex text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300",title:"View Stats",children:[t.jsx(z.PieChart,{size:16})," Stats"]})]}),t.jsx("div",{className:"mb-2",children:t.jsxs("span",{className:`inline-block cursor-pointer px-2 py-1 rounded ${n==="dark"?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"}`,onClick:()=>a(b),children:["Vote value: ",b.vote_value_total?it(b.vote_value_total):0," HP"]})})]}),t.jsxs("div",{className:"mt-4 sm:mt-0 sm:ml-4 w-full sm:w-48 flex flex-col space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Daily Pay:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[b.daily_pay_hbd?it(b.daily_pay_hbd):0," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Remaining:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.remaining_days||0)," Days"]})]}),d!=="Expired"&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"Paid:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.total_hbd_received||0)," HBD"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-400 text-xs sm:text-sm",children:"To Pay:"}),t.jsxs("strong",{className:"text-gray-900 dark:text-gray-100 text-xs sm:text-sm",children:[it(b.max_hbd_remaining||0)," HBD"]})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{className:"px-3 sm:px-5 py-2 bg-green-600 hover:bg-green-700 text-white rounded cursor-pointer w-full text-xs sm:text-sm",onClick:()=>e(b),children:"Support"})})]})]})},b.proposal_id))]})]})})};class Tp{HIVE_API_URL="https://api.hive.blog";async getProfile(a){const i={jsonrpc:"2.0",method:"bridge.get_profile",params:{account:a},id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getFollowers(a){const i={jsonrpc:"2.0",method:"condenser_api.get_followers",params:[a,null,"blog"],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getFollowing(a){const i={jsonrpc:"2.0",method:"condenser_api.get_following",params:[a,null,"blog"],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getAccounts(a){const i={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[a],id:1},s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result}async getDynamicGlobalProperties(){const a={jsonrpc:"2.0",method:"condenser_api.get_dynamic_global_properties",params:[],id:1},i=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return(await i.json()).result}async convertVestingSharesToHive(a){try{const i=await this.getDynamicGlobalProperties(),s=parseFloat(a.split(" ")[0]),r=parseFloat(i.total_vesting_shares.split(" ")[0]),n=parseFloat(i.total_vesting_fund_hive.split(" ")[0]);return(s*n/r).toFixed(3)}catch(i){return console.error("Error converting vesting shares:",i),"0"}}async getFeedHistory(){const a={jsonrpc:"2.0",method:"condenser_api.get_feed_history",params:[],id:1},i=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return(await i.json()).result}async getVoteValue(a,i=1e4){try{const s=await this.getAccounts([a]);if(s.length===0)throw new Error("Account not found!");const r=s[0],n=await this.getDynamicGlobalProperties(),u=await this.getFeedHistory(),c=parseFloat(r.vesting_shares)+parseFloat(r.received_vesting_shares)-parseFloat(r.delegated_vesting_shares)-parseFloat(r.vesting_withdraw_rate),d=Math.floor(Date.now()/1e3)-r.voting_manabar.last_update_time,f=c*1e6/4;let o=parseFloat(r.voting_manabar.current_mana.toString())+d*f/(300*60*24);o>f&&(o=f);const h=o*100/f,l=r.vesting_shares||"0 VESTS",p=parseFloat(l.toString().split(" ")[0]),x=n.total_vesting_shares||"0 VESTS",w=parseFloat(x.toString().split(" ")[0]),b=i/1e4,g=h*b/100,v=n.vote_power_reserve_rate*(300*60*24)/(3600*24),_=g*f/100,N=parseFloat(n.recent_claims||"0"),y=n.reward_balance||"0 HIVE",m=parseFloat(y.toString().split(" ")[0]),k=n.current_supply||"0 HIVE",j=parseFloat(k.toString().split(" ")[0]),A=n.current_sbd_supply||"0 HBD",D=parseFloat(A.toString().split(" ")[0]),C=m/N*(p/w)*(_/f)*j,O=u?.current_median_history;if(!O||!O.base)return"0.00";const L=parseFloat(O.base.toString().split(" ")[0]);return(C*L).toFixed(2)}catch(s){return console.error("Error calculating vote value:",s),"0.00"}}userAvatar(a){return`https://images.hive.blog/u/${a}/avatar`}}const be=new Tp,bc=({vestingShares:e})=>{const[a,i]=P.useState("...");return P.useEffect(()=>{(async()=>{try{const r=await be.convertVestingSharesToHive(e);i(r)}catch(r){console.error("Error calculating HP:",r);const n=parseFloat(e.split(" ")[0]);i((n/1e6).toFixed(3))}})()},[e]),t.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a," HP"]})},Op=({username:e,onClickAuthor:a,onClickAddRemoveFromLists:i,onClickFollow:s})=>{const[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState({}),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=P.useRef(null),g=async()=>{try{h(!0),p(null);const N=await be.getFollowers(e);if(n(N),N.length>0){const y=N.map(A=>A.follower),m=await be.getAccounts(y);c(m);const k={},j={};for(const A of N)try{const D=await be.getVoteValue(A.follower);j[A.follower]=D}catch(D){console.warn(`Failed to get voting data for ${A.follower}:`,D),k[A.follower]={upvotepower:"0",downvote:"0"},j[A.follower]="0.00"}f(j)}}catch(N){p(N instanceof Error?N.message:"Failed to load followers data")}finally{h(!1)}};P.useEffect(()=>{g()},[e]),P.useEffect(()=>{const N=y=>{b.current&&!b.current.contains(y.target)&&w(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]);const v=N=>{const y=u.find(m=>m.name===N);if(!y)return null;try{return JSON.parse(y.posting_json_metadata)?.profile||{}}catch{return{}}},_=N=>{const y=new Date,m=new Date(N),k=y.getTime()-m.getTime(),j=Math.floor(k/(1e3*60*60*24));if(Math.floor(j/30)>=1)return m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});const D=Math.floor(k/1e3),C=Math.floor(D/60),O=Math.floor(C/60),L=Math.floor(j/7),H=Math.floor(j/365);return H>0?`${H} year${H>1?"s":""} ago`:L>0?`${L} week${L>1?"s":""} ago`:j>0?`${j} day${j>1?"s":""} ago`:O>0?`${O} hour${O>1?"s":""} ago`:C>0?`${C} minute${C>1?"s":""} ago`:"Just now"};return o?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading followers..."]})}):l?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load followers"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),t.jsxs("button",{onClick:g,className:"m-2 inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):r.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user has no followers."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"hidden md:block overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Avatar"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Username"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Last Post"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"HP"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Vote Value"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Manage"})]})}),t.jsx("tbody",{children:r.map((N,y)=>{const m=u.find(j=>j.name===N.follower),k=v(N.follower);return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[t.jsx("td",{className:"py-4 px-4",children:t.jsx("img",{src:k?.profile_image||be.userAvatar(N.follower),alt:N.follower,className:"w-12 h-12 rounded-full object-cover cursor-pointer",onClick:()=>a&&a(N.follower),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.follower}&background=random`}})}),t.jsxs("td",{className:"py-4 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>a&&a(N.follower),children:["@",N.follower]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),k?.about&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1 truncate max-w-xs",children:k.about})]}),t.jsx("td",{className:"py-4 px-4",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:_(m.last_root_post)}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"Never"})}),t.jsx("td",{className:"py-4 px-4",children:m?t.jsx(bc,{vestingShares:m.vesting_shares}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:d[N.follower]?t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["$",d[N.follower]]}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:t.jsxs("div",{className:"relative",ref:x===N.follower?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.follower?null:N.follower),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),x===N.follower&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.follower),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-4 h-4"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.follower),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-4 h-4"}),"Follow"]})]})]})})]},`${N.follower}-${y}`)})})]})}),t.jsx("div",{className:"md:hidden space-y-4",children:r.map((N,y)=>{const m=u.find(j=>j.name===N.follower),k=v(N.follower);return t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:k?.profile_image||be.userAvatar(N.follower),alt:N.follower,className:"w-10 h-10 rounded-full object-cover cursor-pointer flex-shrink-0",onClick:()=>a&&a(N.follower),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.follower}&background=random`}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 text-sm",onClick:()=>a&&a(N.follower),children:["@",N.follower]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?_(m.last_root_post):t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Never"})})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsx("div",{className:"flex items-center gap-4",children:m&&t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:t.jsx(bc,{vestingShares:m.vesting_shares})})}),t.jsxs("div",{className:"relative",ref:x===N.follower?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.follower?null:N.follower),className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),x===N.follower&&t.jsxs("div",{className:"absolute right-0 mt-1 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.follower),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-3 h-3"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.follower),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-3 h-3"}),"Follow"]})]})]})]})]})]})},`${N.follower}-${y}`)})})]})},xc=({vestingShares:e})=>{const[a,i]=P.useState("...");return P.useEffect(()=>{(async()=>{try{const r=await be.convertVestingSharesToHive(e);i(r)}catch(r){console.error("Error calculating HP:",r);const n=parseFloat(e.split(" ")[0]);i((n/1e6).toFixed(3))}})()},[e]),t.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[a," HP"]})},Pp=({username:e,onClickAuthor:a,onClickAddRemoveFromLists:i,onClickUnfollow:s})=>{const[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState({}),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=P.useRef(null),g=async()=>{try{h(!0),p(null);const N=await be.getFollowing(e);if(n(N),N.length>0){const y=N.map(j=>j.following),m=await be.getAccounts(y);c(m);const k={};for(const j of N)try{const A=await be.getVoteValue(j.following);k[j.following]=A}catch(A){console.warn(`Failed to get voting data for ${j.following}:`,A),k[j.following]="0.00"}f(k)}}catch(N){p(N instanceof Error?N.message:"Failed to load following data")}finally{h(!1)}};P.useEffect(()=>{g()},[e]),P.useEffect(()=>{const N=y=>{b.current&&!b.current.contains(y.target)&&w(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]);const v=N=>{const y=u.find(m=>m.name===N);if(!y)return null;try{return JSON.parse(y.posting_json_metadata)?.profile||{}}catch{return{}}},_=N=>{const y=new Date,m=new Date(N),k=y.getTime()-m.getTime(),j=Math.floor(k/(1e3*60*60*24));if(Math.floor(j/30)>=1)return m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});const D=Math.floor(k/1e3),C=Math.floor(D/60),O=Math.floor(C/60),L=Math.floor(j/7),H=Math.floor(j/365);return H>0?`${H} year${H>1?"s":""} ago`:L>0?`${L} week${L>1?"s":""} ago`:j>0?`${j} day${j>1?"s":""} ago`:O>0?`${O} hour${O>1?"s":""} ago`:C>0?`${C} minute${C>1?"s":""} ago`:"Just now"};return o?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading following..."]})}):l?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load following"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),t.jsxs("button",{onClick:g,className:"m-2 inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):r.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user is not following anyone."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"hidden md:block overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Avatar"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Username"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Last Post"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"HP"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Vote Value"}),t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-900 dark:text-white",children:"Manage"})]})}),t.jsx("tbody",{children:r.map((N,y)=>{const m=u.find(j=>j.name===N.following),k=v(N.following);return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[t.jsx("td",{className:"py-4 px-4",children:t.jsx("img",{src:k?.profile_image||be.userAvatar(N.following),alt:N.following,className:"w-12 h-12 rounded-full object-cover cursor-pointer",onClick:()=>a&&a(N.following),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.following}&background=random`}})}),t.jsxs("td",{className:"py-4 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>a&&a(N.following),children:["@",N.following]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),k?.about&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1 truncate max-w-xs",children:k.about})]}),t.jsx("td",{className:"py-4 px-4",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:_(m.last_root_post)}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"Never"})}),t.jsx("td",{className:"py-4 px-4",children:m?t.jsx(xc,{vestingShares:m.vesting_shares}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:d[N.following]?t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["$",d[N.following]]}):t.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),t.jsx("td",{className:"py-4 px-4",children:t.jsxs("div",{className:"relative",ref:x===N.following?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.following?null:N.following),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),x===N.following&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.following),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-4 h-4"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.following),w(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-4 h-4"}),"Unfollow"]})]})]})})]},`${N.following}-${y}`)})})]})}),t.jsx("div",{className:"md:hidden space-y-4",children:r.map((N,y)=>{const m=u.find(j=>j.name===N.following),k=v(N.following);return t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:k?.profile_image||be.userAvatar(N.following),alt:N.following,className:"w-10 h-10 rounded-full object-cover cursor-pointer flex-shrink-0",onClick:()=>a&&a(N.following),onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.following}&background=random`}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 text-sm",onClick:()=>a&&a(N.following),children:["@",N.following]}),k?.location&&t.jsxs("div",{className:"relative group",children:[t.jsx(z.MapPin,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10",children:k.location})]})]}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:m?.last_post&&m.last_post!=="1970-01-01T00:00:00"?_(m.last_root_post):t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Never"})})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsx("div",{className:"flex items-center gap-4",children:m&&t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:t.jsx(xc,{vestingShares:m.vesting_shares})})}),t.jsxs("div",{className:"relative",ref:x===N.following?b:null,children:[t.jsx("button",{onClick:()=>w(x===N.following?null:N.following),className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(z.MoreVertical,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),x===N.following&&t.jsxs("div",{className:"absolute right-0 mt-1 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10",children:[t.jsxs("button",{onClick:()=>{i&&i(N.following),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserPlus,{className:"w-3 h-3"}),"Add/remove from lists"]}),t.jsxs("button",{onClick:()=>{s&&s(N.following),w(null)},className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(z.UserMinus,{className:"w-3 h-3"}),"Unfollow"]})]})]})]})]})]})},`${N.following}-${y}`)})})]})},yc=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class $p{async getAccountHistory(a,i=-1,s=1e3,r,n){try{const u=[a,i,s];return r!==void 0&&n!==void 0&&u.push(r,n),(await yc.call("condenser_api","get_account_history",u)).map(([d,f])=>({index:d,block:f.block,op:{type:f.op[0],value:f.op[1]},op_in_trx:f.op_in_trx,timestamp:f.timestamp,trx_id:f.trx_id,trx_in_block:f.trx_in_block,virtual_op:f.virtual_op}))}catch(u){return console.error("Error fetching account history:",u),[]}}async getNextAccountHistoryPage(a,i,s=1e3){try{const r=i-1;return(await yc.call("condenser_api","get_account_history",[a,r,s])).map(([c,d])=>({index:c,block:d.block,op:{type:d.op[0],value:d.op[1]},op_in_trx:d.op_in_trx,timestamp:d.timestamp,trx_id:d.trx_id,trx_in_block:d.trx_in_block,virtual_op:d.virtual_op})).filter(c=>c.index<i)}catch(r){return console.error("Error fetching next page of account history:",r),[]}}convertToActivityListItems(a,i){return a.filter(s=>{const r=s.op.type;return r!=="effective_comment_vote"&&r!=="witness_set_properties"&&r!=="producer_reward"&&r!=="comment_reward"&&r!=="comment_payout_update"&&r!=="claim_reward_balance"&&r!=="transfer"&&r!=="claim_account"&&r!=="transfer_to_vesting"&&r!=="transfer_to_vesting_completed"}).map(s=>{const r=this.parseOperation(s,i);return{id:`${s.index}-${s.trx_id}`,type:r.type,direction:r.direction,timestamp:s.timestamp,block:s.block,description:r.description,details:s.op.value,index:s.index,...r.extraFields}}).filter(s=>s!==null)}parseOperation(a,i){const{op:s}=a,r=s.type,n=s.value;switch(r){case"vote":return this.parseVoteOperation(n,i);case"comment":return this.parseCommentOperation(n,i);case"custom_json":return this.parseCustomJsonOperation(n,i);case"comment_options":return this.parseCommentOptionsOperation(n,i);case"effective_comment_vote":return this.parseEffectiveCommentVoteOperation(n,i);case"curation_reward":return this.parseCurationRewardOperation(n,i);case"author_reward":return this.parseAuthorRewardOperation(n,i);case"comment_benefactor_reward":return this.parseCommentBenefactorRewardOperation(n,i);default:return{type:"other",direction:"out",description:`${r} operation`,extraFields:{}}}}parseVoteOperation(a,i){const{voter:s,author:r,permlink:n,weight:u}=a,c=r===i,d=c?"in":"out",f=(u/100).toFixed(0);let o="";return c?o=`${s} voted ${r}/${n} with ${f}%`:o=`Voted ${r}/${n} with ${f}%`,{type:"vote",direction:d,description:o,extraFields:{voter:s,author:r,permlink:n,weight:parseInt(f)}}}parseCommentOperation(a,i){const{author:s,parent_author:r,parent_permlink:n,permlink:u}=a,d=r===i?"in":"out",o=`Commented on ${n} by ${r||s}.`;return{type:"comment",direction:d,description:o,extraFields:{author:s,permlink:u,parent_author:r,parent_permlink:n}}}parseCustomJsonOperation(a,i){const{id:s,json:r,required_auths:n,required_posting_auths:u}=a;let c={};try{c=JSON.parse(r)}catch{}let d="Custom Json";if(s==="follow"){const[f,o]=c;f==="follow"&&(d="Custom Json")}return{type:"custom_json",direction:"out",description:d,extraFields:{}}}parseCommentOptionsOperation(a,i){const{author:s,permlink:r,max_accepted_payout:n}=a;return{type:"comment_options",direction:"out",description:"Comment Payout Update",extraFields:{author:s,permlink:r,payout:n}}}parseEffectiveCommentVoteOperation(a,i){const{voter:s,author:r,permlink:n,pending_payout:u}=a,c=r===i,d=c?"in":"out",f=c?`${s} voted on ${r}/${n} (effective vote)`:`Effective vote on ${r}/${n}`;return{type:"effective_comment_vote",direction:d,description:f,extraFields:{voter:s,author:r,permlink:n,payout:u}}}parseCurationRewardOperation(a,i){const{author:s,curator:r,permlink:n,reward:u}=a,d=r===i?"in":"out",h=`${(parseFloat(u.split(" ")[0])*1e-6).toFixed(3)} HP`,l=`Curation reward for ${r}/${n} by ${s}`;return{type:"curation_reward",direction:d,description:l,extraFields:{author:s,curator:r,permlink:n,reward:h}}}parseAuthorRewardOperation(a,i){const{author:s,permlink:r,hbd_payout:n,hive_payout:u,vesting_payout:c}=a,f=s===i?"in":"out",h=(parseFloat(c.split(" ")[0])*1e-6).toFixed(3),l=n.split(" ")[0],p=u.split(" ")[0],x=`Author reward: ${l} HBD, ${p} HIVE, ${h} HP for ${r}`;return{type:"author_reward",direction:f,description:x,extraFields:{author:s,permlink:r,hbd_payout:n,hive_payout:u,vesting_payout:c}}}parseCommentBenefactorRewardOperation(a,i){const{author:s,benefactor:r,permlink:n,hbd_payout:u,hive_payout:c,vesting_payout:d}=a,o=r===i?"in":"out",l=(parseFloat(d.split(" ")[0])*1e-6).toFixed(3),p=u.split(" ")[0],x=c.split(" ")[0],w=`Benefactor reward on ${n} by ${s}: ${p} HBD, ${x} HIVE, ${l} HP`;return{type:"comment_benefactor_reward",direction:o,description:w,extraFields:{author:s,benefactor:r,permlink:n,hbd_payout:u,hive_payout:c,vesting_payout:d}}}filterByDirection(a,i){return i==="all"?a:a.filter(s=>s.direction===i)}filterByGeneralType(a,i){if(i==="all")return a;switch(i){case"votes":return a.filter(s=>s.type==="vote"||s.type==="effective_comment_vote");case"comments":return a.filter(s=>s.type==="comment");case"replies":return a.filter(s=>s.type==="comment"&&s.direction==="in");case"others":return a.filter(s=>s.type==="custom_json"||s.type==="comment_options"||s.type==="other");default:return a}}filterByRewardType(a,i){if(i==="all")return a;switch(i){case"author":return a.filter(s=>s.type==="effective_comment_vote"&&s.direction==="in");case"curation":return a.filter(s=>s.type==="effective_comment_vote"&&s.direction==="out");case"benefactor":return a.filter(s=>s.type==="comment_options"&&s.details?.beneficiaries);default:return a}}searchActivities(a,i){if(!i.trim())return a;const s=i.toLowerCase();return a.filter(r=>r.description.toLowerCase().includes(s)||r.author?.toLowerCase().includes(s)||r.permlink?.toLowerCase().includes(s)||r.voter?.toLowerCase().includes(s))}getRelativeTime(a){try{const i=new Date(a),r=new Date().getTime()-i.getTime(),n=Math.floor(r/1e3),u=Math.floor(n/60),c=Math.floor(u/60),d=Math.floor(c/24);return n<60?`${n} seconds ago`:u<60?`${u} minutes ago`:c<24?`${c} hours ago`:d<7?`${d} days ago`:i.toLocaleDateString()}catch(i){return console.error("Error calculating relative time:",i),a}}}const ra=new $p,Lp=({username:e,directionFilter:a="all",generalFilter:i="all",rewardFilter:s="all",searchTerm:r="",limit:n=1e3,className:u,onClickPermlink:c,onSelectActivity:d})=>{const[f,o]=P.useState(r),[h,l]=P.useState(a),[p,x]=P.useState(i),[w,b]=P.useState(s),[g,v]=P.useState([]),[_,N]=P.useState([]),[y,m]=P.useState(!1),[k,j]=P.useState(null),[A,D]=P.useState(new Set),[C,O]=P.useState(null),[L,H]=P.useState(!0),[F,B]=P.useState(!1),[$,G]=P.useState(-1),X=P.useRef(null),ee=async(V=!1)=>{if(e){V?B(!0):(m(!0),H(!0),G(-1)),j(null);try{let J;V?J=await ra.getNextAccountHistoryPage(e,$,n):J=await ra.getAccountHistory(e,-1,n);const oe=ra.convertToActivityListItems(J,e);if(oe.sort((K,te)=>new Date(te.timestamp).getTime()-new Date(K.timestamp).getTime()),v(V?K=>[...K,...oe]:oe),J.length>0){const K=Math.min(...J.map(te=>te.index));G(K)}oe.length===0&&H(!1)}catch(J){j("Failed to load activity history"),console.error("Error loading activities:",J),H(!1)}finally{m(!1),B(!1)}}};P.useEffect(()=>{ee()},[e,n]);const R=P.useCallback(()=>{L&&!y&&!F&&ee(!0)},[L,y,F]);P.useEffect(()=>{let V=g;h!=="all"?V=V.filter(J=>J.direction===h):V=V.filter(J=>J.type!=="custom_json"&&J.type!=="comment_options"),p!=="all"&&(p==="votes"?V=V.filter(J=>J.type==="vote"||J.type==="effective_comment_vote"):p==="comments"?V=V.filter(J=>J.type==="comment"):p==="replies"?V=V.filter(J=>J.type==="comment"&&J.direction==="in"):p==="curation"?V=V.filter(J=>J.type==="curation_reward"):p==="others"&&(V=g.filter(J=>J.type==="custom_json"||J.type==="comment_options"))),w!=="all"&&(w==="author"?V=V.filter(J=>J.type==="effective_comment_vote"&&J.direction==="in"):w==="curation"?V=V.filter(J=>J.type==="effective_comment_vote"&&J.direction==="out"):w==="benefactor"&&(V=V.filter(J=>J.type==="comment_options"))),f&&(V=V.filter(J=>J.description.toLowerCase().includes(f.toLowerCase())||J.author?.toLowerCase().includes(f.toLowerCase())||J.permlink?.toLowerCase().includes(f.toLowerCase()))),N(V)},[g,h,p,w,f]),P.useEffect(()=>{const V=J=>{X.current&&!X.current.contains(J.target)&&O(null)};return document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[]);const se=V=>{switch(V.type){case"vote":case"effective_comment_vote":return t.jsx(z.Wallet,{className:"h-4 w-4"});case"comment":return t.jsx(z.MessageCircle,{className:"h-4 w-4"});case"custom_json":return t.jsx(z.FileText,{className:"h-4 w-4"});case"curation_reward":return t.jsx(z.Wallet,{className:"h-4 w-4"});case"author_reward":return t.jsx(z.DollarSign,{className:"h-4 w-4"});case"comment_benefactor_reward":return t.jsx(z.User,{className:"h-4 w-4"});default:return t.jsx(z.Eye,{className:"h-4 w-4"})}},I=(V,J)=>V.split(/(\s+)/).map((K,te)=>{if(K.includes("/")){const[pe,Ee]=K.split("/");if(pe&&Ee)return t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:Z=>{Z.stopPropagation(),console.log("Clicked permlink:",pe,Ee),c?.(pe,Ee)},children:K},te)}return t.jsx("span",{children:K},te)});return y?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-start lg:items-center justify-between",children:[t.jsx("div",{className:"flex-1 max-w-md",children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),t.jsx("div",{className:"w-full h-10 bg-gray-200 dark:bg-gray-700 rounded-md animate-pulse"})]})}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from({length:5}).map((V,J)=>t.jsx("div",{className:"w-24 h-10 bg-gray-200 dark:bg-gray-700 rounded-md animate-pulse"},J))})]}),t.jsx("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:Array.from({length:4}).map((V,J)=>t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-20"},J))})]}),t.jsx("div",{className:"space-y-4",children:Array.from({length:5}).map((V,J)=>t.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx("div",{className:"w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded-full animate-pulse flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0 space-y-2",children:t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/4"})})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-4",children:[t.jsx("div",{className:"w-3 h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-16"})]})]},J))})]}):k?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load activities"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:k}),t.jsxs("button",{onClick:()=>ee(),className:"inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-start lg:items-center justify-between",children:[t.jsx("div",{className:"flex-1 max-w-md",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search activities...",value:f,onChange:V=>o(V.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("select",{value:h,onChange:V=>l(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Directions"}),t.jsx("option",{value:"in",children:"Incoming"}),t.jsx("option",{value:"out",children:"Outgoing"})]}),t.jsxs("select",{value:p,onChange:V=>x(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Types"}),t.jsx("option",{value:"votes",children:"Votes"}),t.jsx("option",{value:"comments",children:"Comments"}),t.jsx("option",{value:"replies",children:"Replies"}),t.jsx("option",{value:"curation",children:"Curation"}),t.jsx("option",{value:"others",children:"Others"})]}),t.jsxs("select",{value:w,onChange:V=>b(V.target.value),className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",children:[t.jsx("option",{value:"all",children:"All Rewards"}),t.jsx("option",{value:"author",children:"Author"}),t.jsx("option",{value:"curation",children:"Curation"}),t.jsx("option",{value:"benefactor",children:"Benefactor"})]}),t.jsx("button",{onClick:()=>ee(),disabled:y||F,className:"px-3 py-2 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Total: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:g.length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Filtered: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:_.length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Incoming: ",t.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:g.filter(V=>V.direction==="in").length})]}),t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Outgoing: ",t.jsx("span",{className:"font-semibold text-blue-600 dark:text-blue-400",children:g.filter(V=>V.direction==="out").length})]})]})]}),t.jsx("div",{className:"space-y-4",children:_.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[200px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:g.length===0?"No activities found for this user.":"No activities match the current filters."})}):t.jsxs(t.Fragment,{children:[_.map((V,J)=>t.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors cursor-pointer",onClick:oe=>{d?.(V)},children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[V.type==="vote"&&V.voter?t.jsx("img",{src:`https://images.hive.blog/u/${V.voter}/avatar`,alt:V.voter,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):V.type==="comment_benefactor_reward"&&V.author?t.jsx("img",{src:`https://images.hive.blog/u/${V.author}/avatar`,alt:V.author,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):V.type==="comment"&&V.author?t.jsx("img",{src:`https://images.hive.blog/u/${V.author}/avatar`,alt:V.author,className:"w-8 h-8 rounded-full flex-shrink-0",onError:oe=>{const K=oe.target;K.style.display="none";const te=K.nextElementSibling;te&&(te.style.display="flex")}}):null,t.jsx("div",{className:`w-8 h-8 bg-purple-100 dark:bg-purple-900/20 rounded-full flex items-center justify-center flex-shrink-0 ${V.type==="vote"&&V.voter||V.type==="comment_benefactor_reward"&&V.author||V.type==="comment"&&V.author?"hidden":""}`,children:se(V)}),t.jsx("div",{className:"flex-1 min-w-0",children:V.type==="custom_json"||V.type==="comment_options"?t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words font-medium",children:I(V.description)}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:ra.getRelativeTime(V.timestamp+"Z")}),t.jsx("div",{className:"border border-gray-200 dark:border-gray-600 rounded p-2 bg-gray-50 dark:bg-gray-700/50 mt-1",children:t.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400 space-y-1 font-mono break-words",children:[V.type==="custom_json"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"id:"})," ",V.details.id]}),t.jsxs("div",{className:"break-all",children:[t.jsx("span",{className:"font-medium",children:"json:"})," ",JSON.stringify(V.details.json).replace(/\\\"/g,'"').replace(/^"|"$/g,"")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"required_auths:"})," ",JSON.stringify(V.details.required_auths)]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"required_posting_auths:"})," ",JSON.stringify(V.details.required_posting_auths)]})]}),V.type==="comment_options"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"author:"}),t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",children:V.details.author})]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"permlink:"}),t.jsx("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:oe=>{oe.stopPropagation(),console.log("Clicked permlink:",V.details.author,V.details.permlink),c?.(V.details.author,V.details.permlink)},children:V.details.permlink})]})]})]})})]}):t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words",children:I(V.description)}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 sm:hidden",children:ra.getRelativeTime(V.timestamp+"Z")})]})})]}),t.jsx("div",{className:"flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 flex-shrink-0 ml-4 hidden sm:flex",children:V.type!=="custom_json"&&V.type!=="comment_options"&&t.jsxs(t.Fragment,{children:[t.jsx(z.Clock,{className:"h-3 w-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:ra.getRelativeTime(V.timestamp+"Z")})]})})]},`${V.id}-${J}`)),L&&g.length>0&&t.jsx("div",{className:"flex justify-center py-6",children:t.jsx("button",{onClick:R,disabled:y||F,className:"px-6 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white rounded-lg font-medium transition-colors disabled:cursor-not-allowed flex items-center gap-2",children:F?t.jsxs(t.Fragment,{children:[t.jsx(z.RefreshCw,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):"Load More Activities"})}),!L&&g.length>0&&t.jsx("div",{className:"text-center text-sm text-gray-400 py-4",children:"No more activities to load"})]})})]})},Gn=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Mp{async getWitnessesByVote(a="",i=60){try{return await Gn.call("condenser_api","get_witnesses_by_vote",[a,i])}catch(s){throw console.error("Error fetching witnesses by vote:",s),s}}async getAccount(a){try{const i=await Gn.call("condenser_api","get_accounts",[[a]]);return i&&i.length>0?i[0]:null}catch(i){return console.error("Error fetching account:",i),null}}async getAccounts(a){try{return await Gn.call("condenser_api","get_accounts",[a])}catch(i){return console.error("Error fetching accounts:",i),[]}}async getWitnessVotes(a,i="",s=250){try{return await Gn.call("database_api","list_witness_votes",{start:[a,i],limit:s,order:"by_witness_account"})}catch(r){throw console.error("Error fetching witness votes:",r),r}}async getAllWitnessVotes(a){const i=[];let s="";try{for(;;){const n=await this.getWitnessVotes(a,s,250);if(i.push(...n.votes),n.votes.length<250)break;s=n.votes[n.votes.length-1].account}return i}catch(n){return console.error("Error fetching all witness votes:",n),[]}}async hasUserVotedForWitness(a,i){try{const s=await this.getAccount(a);return!s||!s.witness_votes?!1:s.witness_votes.includes(i)}catch(s){return console.error("Error checking witness vote:",s),!1}}async getUserWitnessVotes(a){try{return(await this.getAccount(a))?.witness_votes||[]}catch(i){return console.error("Error fetching user witness votes:",i),[]}}formatVotesToMHP(a){return`${(parseFloat(a)/1e6).toFixed(1)}m`}calculateAPR(a){return a/100}getVersionStatus(a,i){const s=this.parseVersion(a),r=this.parseVersion(i);return this.compareVersions(s,r)>=0?"green":this.compareVersions(s,r)<0?"red":"grey"}parseVersion(a){return a.split(".").map(i=>parseInt(i,10))}compareVersions(a,i){const s=Math.max(a.length,i.length);for(let r=0;r<s;r++){const n=a[r]||0,u=i[r]||0;if(n>u)return 1;if(n<u)return-1}return 0}getWitnessDescription(a){try{let i;if(a.json_metadata&&a.json_metadata!=="{}"){i=JSON.parse(a.json_metadata);const s=i.profile?.witness_description;if(s)return s}return a.posting_json_metadata&&a.posting_json_metadata!=="{}"?(i=JSON.parse(a.posting_json_metadata),i.profile?.about||""):""}catch(i){return console.error("Error parsing witness description:",i),""}}formatTimeAgo(a){const i=new Date(a),r=Math.floor((new Date().getTime()-i.getTime())/1e3);if(r<60)return`${r} second${r>1?"s":""} ago`;if(r<3600){const n=Math.floor(r/60);return`${n} minute${n>1?"s":""} ago`}else if(r<86400){const n=Math.floor(r/3600);return`${n} hour${n>1?"s":""} ago`}else if(r<604800){const n=Math.floor(r/86400);return`${n} day${n>1?"s":""} ago`}else if(r<2592e3){const n=Math.floor(r/604800);return`${n} week${n>1?"s":""} ago`}else if(r<31536e3){const n=Math.floor(r/2592e3);return`${n} month${n>1?"s":""} ago`}else{const n=Math.floor(r/31536e3);return`${n} year${n>1?"s":""} ago`}}}const ct=new Mp,Ue=_c.create((e,a)=>({witnesses:[],witnessVotes:[],userWitnessVotes:[],witnessDetails:new Map,witnessAccounts:new Map,loadingWitnesses:!1,loadingMoreWitnesses:!1,loadingVotes:!1,loadingMoreVotes:!1,loadingUserVotes:!1,error:null,nextWitnessStart:"",nextVotesStart:"",hasMoreWitnesses:!0,hasMoreVotes:!1,selectedWitness:null,filters:{status:"all",name:"",version:""},loadWitnesses:async(i="",s=50)=>{const{witnesses:r}=a();if(r.length>=500){e({hasMoreWitnesses:!1});return}e(i!==""?{loadingMoreWitnesses:!0}:{loadingWitnesses:!0,error:null});try{const u=await ct.getWitnessesByVote(i,s);e(d=>{const f=new Set(d.witnesses.map(h=>h.owner)),o=u.filter(h=>!f.has(h.owner));return{witnesses:[...d.witnesses,...o],nextWitnessStart:u.length>0?u[u.length-1].owner:"",hasMoreWitnesses:u.length===s}});const c=u.filter(d=>!a().witnessDetails.has(d.owner)).map(d=>d.owner);c.length>0&&a().loadWitnessDetails(c)}catch(u){console.error("Error loading witnesses:",u),e({error:"Failed to load witnesses data"})}finally{e({loadingWitnesses:!1,loadingMoreWitnesses:!1})}},loadMoreWitnesses:async()=>{const{nextWitnessStart:i,hasMoreWitnesses:s,loadingMoreWitnesses:r}=a();!s||r||!i||await a().loadWitnesses(i,50)},loadWitnessVotes:async i=>{e({loadingVotes:!0,witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:i});try{const s=await ct.getWitnessVotes(i,"",250);e({witnessVotes:s.votes,nextVotesStart:s.votes.length>0?s.votes[s.votes.length-1].account:"",hasMoreVotes:s.votes.length===250,loadingVotes:!1})}catch(s){console.error("Error loading witness votes:",s),e({error:"Failed to load witness votes",loadingVotes:!1})}},loadMoreVotes:async()=>{const{hasMoreVotes:i,loadingMoreVotes:s,nextVotesStart:r,selectedWitness:n,witnessVotes:u}=a();if(!i||s||!r||u.length>=1e3){u.length>=1e3&&e({hasMoreVotes:!1});return}e({loadingMoreVotes:!0});try{const c=await ct.getWitnessVotes(n||"",r,250);e(d=>{const o=[...d.witnessVotes,...c.votes].filter((l,p,x)=>x.findIndex(w=>w.account===l.account)===p),h=c.votes.filter((l,p,x)=>x.findIndex(w=>w.account===l.account)===p);return{witnessVotes:o,nextVotesStart:h.length>0?h[h.length-1].account:"",hasMoreVotes:c.votes.length===250}})}catch(c){console.error("Error loading more witness votes:",c)}finally{e({loadingMoreVotes:!1})}},loadUserWitnessVotes:async i=>{if(i){e({loadingUserVotes:!0});try{const s=await ct.getUserWitnessVotes(i);e({userWitnessVotes:s})}catch(s){console.error("Error loading user witness votes:",s)}finally{e({loadingUserVotes:!1})}}},loadWitnessDetails:async i=>{try{const s=await ct.getAccounts(i);e(r=>{const n=new Map(r.witnessDetails),u=new Map(r.witnessAccounts);return s.forEach(c=>{const d=ct.getWitnessDescription(c);d&&n.set(c.name,d),u.set(c.name,c)}),{witnessDetails:n,witnessAccounts:u}})}catch(s){console.error("Error loading witness details:",s)}},setFilters:i=>e({filters:i}),setSelectedWitness:i=>e({selectedWitness:i}),clearVotes:()=>e({witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:null})})),vc=({filters:e,onFiltersChange:a,theme:i="dark"})=>{const s=i==="dark"?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-800",r=c=>{const d=e.status===c?"all":c;a({...e,status:d})},n=c=>{a({...e,name:c})},u=c=>{a({...e,version:c})};return t.jsxs("div",{className:`rounded-lg p-4 mb-6 border ${i==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsx("h3",{className:`text-lg font-semibold mb-4 ${i==="dark"?"text-white":"text-gray-900"}`,children:"FILTERS"}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"WITNESS"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="active",onChange:()=>r("active"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Active"})]}),t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="disabled",onChange:()=>r("disabled"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Disabled/Stale"})]}),t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.status==="approved",onChange:()=>r("approved"),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),t.jsx("span",{className:`${i==="dark"?"text-white":"text-gray-900"}`,children:"Approved"})]}),e.status!=="all"&&t.jsx("button",{onClick:()=>a({...e,status:"all"}),className:`text-sm underline ${s}`,children:"Clear Status Filter"})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"NAME"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:`w-4 h-4 ${i==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:"Search",value:e.name,onChange:c=>n(c.target.value),className:`w-full pl-10 pr-4 py-2 border-b focus:outline-none focus:border-blue-500 ${i==="dark"?"bg-slate-900 border-gray-700 text-white placeholder-gray-400":"bg-gray-50 border-gray-300 text-gray-900 placeholder-gray-500"}`})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:`text-sm font-medium mb-3 ${i==="dark"?"text-gray-300":"text-gray-700"}`,children:"VERSION"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:`w-4 h-4 ${i==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:"Version",value:e.version,onChange:c=>u(c.target.value),className:`w-full pl-10 pr-4 py-2 border-b focus:outline-none focus:border-blue-500 ${i==="dark"?"bg-slate-900 border-gray-700 text-white placeholder-gray-400":"bg-gray-50 border-gray-300 text-gray-900 placeholder-gray-500"}`})]})]})]})},Ci=768;function Ed(){const[e,a]=Qn.useState(void 0);return Qn.useEffect(()=>{const i=window.matchMedia(`(max-width: ${Ci-1}px)`),s=()=>{a(window.innerWidth<Ci)};return i.addEventListener("change",s),a(window.innerWidth<Ci),()=>i.removeEventListener("change",s)},[]),!!e}const Rp=({isOpen:e,onClose:a,witness:i,votes:s,loadingMore:r,hasMore:n,loadingInitial:u,scrollContainerRef:c,sentinelRef:d,loadMoreVotes:f,theme:o="dark"})=>{const h=P.useCallback(l=>{l[0].isIntersecting&&n&&!r&&f()},[n,r,f]);return P.useEffect(()=>{const l=new IntersectionObserver(h,{threshold:.1,root:c.current});return d.current&&l.observe(d.current),()=>{d.current&&l.unobserve(d.current)}},[h,c,d]),e?t.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:`rounded-lg max-w-2xl w-full max-h-[80vh] overflow-hidden border ${o==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${o==="dark"?"border-gray-800":"border-gray-200"}`,children:[t.jsxs("h3",{className:`text-lg font-semibold ${o==="dark"?"text-white":"text-gray-900"}`,children:["Votes for @",i," (showing ",s.length,")"]}),t.jsx("button",{onClick:a,className:`text-xl font-bold ${o==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:"×"})]}),t.jsxs("div",{ref:c,className:"p-4 overflow-y-auto max-h-[60vh]",children:[t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.map((l,p)=>t.jsxs("div",{className:`flex items-center space-x-3 p-3 rounded-lg border ${o==="dark"?"bg-gray-800 border-gray-800":"bg-gray-50 border-gray-200"}`,children:[t.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${o==="dark"?"bg-gray-600 text-white":"bg-gray-200 text-gray-900"}`,children:t.jsx("img",{className:"w-8 h-8 rounded-full",src:`https://images.hive.blog/u/${l.account}/avatar`,alt:l.account,onError:x=>{x.target.src="https://images.hive.blog/u/null/avatar"}})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:`font-medium ${o==="dark"?"text-white":"text-gray-900"}`,children:l.account}),t.jsxs("div",{className:`text-sm ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:["Vote #",p+1]})]}),t.jsx("div",{className:`text-sm ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"25"})]},l.account))}),s.length===0&&!u&&t.jsx("div",{className:`text-center py-8 ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"No votes found for this witness."}),r&&t.jsx("div",{className:`text-center py-4 ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more votes..."}),n&&!r&&t.jsx("div",{className:"text-center py-4",children:t.jsx("button",{onClick:f,className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded",children:"Load More Votes"})}),n&&t.jsx("div",{ref:d,className:"h-4"})]})]})}):null},Ip=({username:e,filters:a={status:"all",name:"",version:""},onWitnessVoteClick:i,onWitnessStatsClick:s,onWitnessUrlClick:r,theme:n="dark"})=>{const u=Ed(),c=Ue(I=>I.witnesses),d=Ue(I=>I.userWitnessVotes),f=Ue(I=>I.loadingWitnesses),o=Ue(I=>I.error),h=Ue(I=>I.selectedWitness),l=Ue(I=>I.witnessVotes),p=Ue(I=>I.hasMoreVotes),x=Ue(I=>I.loadingMoreVotes),w=Ue(I=>I.loadingVotes),b=Ue(I=>I.filters),g=Ue(I=>I.hasMoreWitnesses),v=Ue(I=>I.loadingWitnesses),_=Ue(I=>I.witnessDetails);Ue(I=>I.witnessAccounts);const N=Ue(I=>I.loadWitnesses),y=Ue(I=>I.loadMoreWitnesses),m=Ue(I=>I.loadWitnessVotes),k=Ue(I=>I.loadMoreVotes),j=Ue(I=>I.loadUserWitnessVotes),A=Ue(I=>I.setFilters),[D,C]=P.useState(!1),[O,L]=P.useState(!1),H=P.useRef(null),F=P.useRef(null),B=P.useRef(null),$=P.useCallback(I=>{I[0].isIntersecting&&g&&!v&&y()},[g,v,y]);P.useEffect(()=>{const I=new IntersectionObserver($,{threshold:.1});return B.current&&I.observe(B.current),()=>{B.current&&I.unobserve(B.current)}},[$]),P.useEffect(()=>{N()},[N]),P.useEffect(()=>{e&&j(e)},[e,j]),P.useEffect(()=>{A(a)},[]);const G=P.useMemo(()=>c.filter(I=>{if(b.status!=="all"){if(b.status==="active"){const V=new Date;if(V.setFullYear(V.getFullYear()-1),new Date(I.last_hbd_exchange_update+"Z")<=V)return!1}else if(b.status==="disabled"){const V=new Date;if(V.setFullYear(V.getFullYear()-1),new Date(I.last_hbd_exchange_update+"Z")>V)return!1}else if(b.status==="approved"&&!d.includes(I.owner))return!1}return!(b.name&&!I.owner.toLowerCase().includes(b.name.toLowerCase())||b.version&&!I.running_version.includes(b.version))}),[c,b,d]),X=async I=>{i?i(I):(await m(I),C(!0))},ee=I=>{s?s(I):window.open(`https://hivehub.dev/witnesses/@${I}`,"_blank")},R=I=>{r?r(I):window.open(I,"_blank")},se=I=>e?d.includes(I):!1;return f?t.jsx("div",{className:"flex items-center justify-center p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):o?t.jsx("div",{className:"text-center p-8 text-red-400",children:o}):t.jsxs("div",{className:"w-full",children:[t.jsx(Rp,{isOpen:D,onClose:()=>C(!1),witness:h||"",votes:l,loadingMore:x,hasMore:p,loadingInitial:w,scrollContainerRef:F,sentinelRef:H,loadMoreVotes:k,theme:n}),u?t.jsxs("div",{className:`w-full p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h2",{className:`text-lg font-semibold ${n==="dark"?"text-white":"text-gray-900"}`,children:"Witnesses"}),t.jsxs("button",{onClick:()=>L(!O),className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded flex items-center space-x-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),t.jsx("span",{children:O?"Hide Filters":"Show Filters"})]})]}),O&&t.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:`rounded-lg w-full max-w-md max-h-[80vh] overflow-hidden border ${n==="dark"?"bg-slate-950 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${n==="dark"?"border-gray-800":"border-gray-200"}`,children:[t.jsx("h3",{className:`text-lg font-semibold ${n==="dark"?"text-white":"text-gray-900"}`,children:"Filters"}),t.jsx("button",{onClick:()=>L(!1),className:`text-xl font-bold ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:"×"})]}),t.jsx("div",{className:"p-4 overflow-y-auto max-h-[60vh]",children:t.jsx(vc,{filters:b,onFiltersChange:A,theme:n})})]})}),t.jsxs("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:[G.map((I,V)=>{const J=ct.getVersionStatus(I.running_version,I.hardfork_version_vote),oe=se(I.owner),K=c.findIndex(te=>te.owner===I.owner)+1;return t.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${n==="dark"?"bg-slate-900 border-gray-800":"bg-white border-gray-200"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("span",{className:`text-lg font-bold ${n==="dark"?"text-white":"text-gray-900"}`,children:["#",K]}),t.jsx("img",{className:"w-10 h-10 rounded-full",src:`https://images.hive.blog/u/${I.owner}/avatar`,alt:I.owner,onError:te=>{te.target.src="https://images.hive.blog/u/null/avatar"}}),t.jsxs("div",{children:[t.jsx("div",{className:`font-medium ${n==="dark"?"text-white":"text-gray-900"}`,children:I.owner}),t.jsxs("div",{className:`text-xs ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["Since ",new Date(I.created).getFullYear()]})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("svg",{className:`w-6 h-6 ${oe?"text-green-600":n==="dark"?"text-gray-500":"text-gray-400"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}),t.jsxs("div",{className:"flex space-x-1",children:[t.jsx("button",{onClick:()=>R(I.url),className:`${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"Visit witness URL",children:"🔗"}),t.jsx("button",{onClick:()=>ee(I.owner),className:`${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"View witness stats",children:"📊"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-3",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Version"}),t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium mt-1 block ${J==="green"?"bg-green-100 text-green-800":J==="red"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:I.running_version})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Votes (MHP)"}),t.jsx("button",{onClick:()=>X(I.owner),className:"text-blue-600 hover:text-blue-800 cursor-pointer text-sm font-medium mt-1",disabled:w,children:w&&h===I.owner?"Loading...":ct.formatVotesToMHP(I.votes)})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-xs uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"APR"}),t.jsxs("div",{className:`font-medium mt-1 ${n==="dark"?"text-white":"text-gray-900"}`,children:[ct.calculateAPR(I.props.hbd_interest_rate),"%"]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-xs",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Last Block"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.last_confirmed_block_num.toLocaleString()})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Miss"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.total_missed.toLocaleString()})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`uppercase ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Price Feed"}),t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.hbd_exchange_rate.base}),t.jsx("div",{className:`${n==="dark"?"text-gray-400":"text-gray-500"}`,children:ct.formatTimeAgo(I.last_hbd_exchange_update+"Z")})]})]}),_.get(I.owner)&&t.jsx("div",{className:`mt-3 pt-3 border-t ${n==="dark"?"border-gray-800":"border-gray-200"}`,children:t.jsx("div",{className:`text-xs line-clamp-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:_.get(I.owner)})})]},I.owner)}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more witnesses..."})]}),g&&t.jsx("div",{ref:B,className:"h-1"})]})]}):t.jsx("div",{className:`max-w-7xl mx-auto p-2 ${n==="dark"?"bg-slate-950":"bg-white"}`,children:t.jsxs("div",{className:"grid grid-cols-5 gap-4",children:[t.jsx("div",{className:"col-span-1 sticky top-0 h-screen overflow-y-auto",children:t.jsx(vc,{filters:b,onFiltersChange:A,theme:n})}),t.jsxs("div",{className:"col-span-4 overflow-auto max-h-screen",children:[t.jsxs("table",{className:`w-full text-xs text-left ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("thead",{className:`text-xs uppercase ${n==="dark"?"text-gray-400 bg-slate-900":"text-gray-700 bg-gray-50"}`,children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Rank"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Witness"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Version"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Votes"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Last Block"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Miss"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Feed"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"APR"}),t.jsx("th",{scope:"col",className:"px-2 py-2",children:"Vote"})]})}),t.jsx("tbody",{children:G.map((I,V)=>{const J=ct.getVersionStatus(I.running_version,I.hardfork_version_vote),oe=se(I.owner);return t.jsxs("tr",{className:`border-b hover:bg-gray-50 ${n==="dark"?"border-gray-800 hover:bg-gray-800":"border-gray-200"}`,children:[t.jsx("td",{className:`px-2 py-2 font-medium text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:c.findIndex(K=>K.owner===I.owner)+1}),t.jsx("td",{className:"px-2 py-2",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("img",{className:"w-6 h-6 rounded-full",src:`https://images.hive.blog/u/${I.owner}/avatar`,alt:I.owner,onError:K=>{K.target.src="https://images.hive.blog/u/null/avatar"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`font-medium text-xs truncate ${n==="dark"?"text-white":"text-gray-900"}`,children:I.owner}),t.jsxs("div",{className:`text-xs ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:["Since ",new Date(I.created).getFullYear()]})]}),t.jsxs("div",{className:"flex space-x-1 flex-shrink-0",children:[t.jsx("button",{onClick:()=>R(I.url),className:`text-xs ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"Visit witness URL",children:"🔗"}),t.jsx("button",{onClick:()=>ee(I.owner),className:`text-xs ${n==="dark"?"text-gray-400 hover:text-white":"text-gray-500 hover:text-gray-900"}`,title:"View witness stats",children:"📊"})]})]})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("span",{className:`px-1 py-0.5 rounded text-xs font-medium ${J==="green"?"bg-green-100 text-green-800":J==="red"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:I.running_version})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("button",{onClick:()=>X(I.owner),className:"text-blue-600 hover:text-blue-800 cursor-pointer text-xs",disabled:w,children:w&&h===I.owner?"...":ct.formatVotesToMHP(I.votes)})}),t.jsx("td",{className:"px-2 py-2 text-right",children:t.jsx("div",{className:`text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:I.last_confirmed_block_num.toLocaleString()})}),t.jsx("td",{className:"px-2 py-2 text-right text-xs",children:t.jsx("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:I.total_missed.toLocaleString()})}),t.jsx("td",{className:"px-2 py-2 text-right",children:t.jsx("div",{className:`text-xs ${n==="dark"?"text-white":"text-gray-900"}`,children:I.hbd_exchange_rate.base})}),t.jsx("td",{className:"px-2 py-2 text-right text-xs",children:t.jsxs("div",{className:`${n==="dark"?"text-white":"text-gray-900"}`,children:[ct.calculateAPR(I.props.hbd_interest_rate),"%"]})}),t.jsx("td",{className:"px-2 py-2",children:t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("svg",{className:`w-4 h-4 ${oe?"text-green-600":n==="dark"?"text-gray-500":"text-gray-400"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})})]},I.owner)})})]}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),t.jsx("span",{className:`ml-2 ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"Loading more witnesses..."})]}),g&&t.jsx("div",{ref:B,className:"h-1"})]})]})})]})},Fp=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class qp{async getTransactionHistory(a,i=-1,s=1e3,r=null,n=null){try{const u=[a,i,s];r!==null&&n!==null&&u.push(r,n);const c=await Fp.call("condenser_api","get_account_history",u);return Array.isArray(c)?c.map(d=>Array.isArray(d)&&d.length>=2?d[1]:d):[]}catch(u){return console.error("Error in getTransactionHistory:",u),[]}}async getFilteredTransactionHistory(a,i=[],s=100){try{const r=await this.getTransactionHistory(a,-1,1e3);let n=r;return i.length>0&&(n=r.filter(u=>{const c=u.op?.[0];return i.includes(c)})),n.slice(0,s)}catch(r){return console.error("Error in getFilteredTransactionHistory:",r),[]}}async getRecentTransfers(a,i=50){return this.getFilteredTransactionHistory(a,["transfer"],i)}async getRecentVotes(a,i=50){return this.getFilteredTransactionHistory(a,["vote"],i)}async getRecentComments(a,i=50){return this.getFilteredTransactionHistory(a,["comment"],i)}parseOperation(a){try{if(!a.op||!Array.isArray(a.op)||a.op.length<2)return null;const[i,s]=a.op;switch(i){case"transfer":return{type:"transfer",value:{from:s.from||"",to:s.to||"",amount:s.amount||"",memo:s.memo||""}};case"vote":return{type:"vote",value:{voter:s.voter||"",author:s.author||"",permlink:s.permlink||"",weight:s.weight||0}};case"comment":return{type:"comment",value:{parent_author:s.parent_author||"",parent_permlink:s.parent_permlink||"",author:s.author||"",permlink:s.permlink||"",title:s.title||"",body:s.body||"",json_metadata:s.json_metadata||""}};case"custom_json":return{type:"custom_json",value:{required_auths:s.required_auths||[],required_posting_auths:s.required_posting_auths||[],id:s.id||"",json:s.json||""}};case"comment_payout_update":return{type:"comment_payout_update",value:{author:s.author||"",permlink:s.permlink||""}};case"comment_options":return{type:"comment_options",value:{author:s.author||"",permlink:s.permlink||"",max_accepted_payout:s.max_accepted_payout||"",percent_hbd:s.percent_hbd||0,allow_votes:s.allow_votes||!1,allow_curation_rewards:s.allow_curation_rewards||!1,extensions:s.extensions||[]}};case"effective_comment_vote":return{type:"effective_comment_vote",value:{voter:s.voter||"",author:s.author||"",permlink:s.permlink||"",pending_payout:s.pending_payout||"",weight:s.weight||0,rshares:s.rshares||0,total_vote_weight:s.total_vote_weight||0}};default:return console.warn("Unknown operation type:",i,a.op),null}}catch(i){return console.error("Error parsing operation:",i,a.op),null}}formatTimestamp(a){try{return new Date(a).toLocaleString()}catch(i){return console.error("Error formatting timestamp:",i),a}}getTransactionSummary(a){const i={};let s="",r="";return a.forEach(n=>{const u=n.op?.[0]||"unknown";i[u]=(i[u]||0)+1,(!s||n.timestamp<s)&&(s=n.timestamp),(!r||n.timestamp>r)&&(r=n.timestamp)}),{totalTransactions:a.length,operationCounts:i,dateRange:{earliest:s,latest:r}}}}const aa=new qp;function Bp({account:e,className:a}){const[i,s]=P.useState([]),[r,n]=P.useState([]),[u,c]=P.useState(!1),[d,f]=P.useState(null),[o,h]=P.useState(""),[l,p]=P.useState("all"),[x,w]=P.useState(50),b=[{value:"all",label:"All Operations",icon:z.Activity},{value:"transfer",label:"Transfers",icon:z.Send},{value:"vote",label:"Votes",icon:z.TrendingUp},{value:"comment",label:"Comments",icon:z.MessageCircle},{value:"custom_json",label:"Custom JSON",icon:z.ArrowUpDown},{value:"comment_payout_update",label:"Payout Updates",icon:z.RefreshCw},{value:"comment_options",label:"Comment Options",icon:z.Filter},{value:"effective_comment_vote",label:"Effective Votes",icon:z.Users}],g=async()=>{if(e){c(!0),f(null);try{const y=await aa.getTransactionHistory(e,-1,x);s(y),n(y)}catch(y){f("Failed to load transaction history"),console.error("Error loading transactions:",y)}finally{c(!1)}}};P.useEffect(()=>{g()},[e,x]),P.useEffect(()=>{let y=i;if(l!=="all"&&(y=y.filter(m=>m.op?.[0]===l)),o){const m=o.toLowerCase();y=y.filter(k=>{const j=aa.parseOperation(k);if(!j)return!1;switch(j.type){case"transfer":return j.value.from.toLowerCase().includes(m)||j.value.to.toLowerCase().includes(m)||j.value.memo.toLowerCase().includes(m);case"vote":return j.value.voter.toLowerCase().includes(m)||j.value.author.toLowerCase().includes(m)||j.value.permlink.toLowerCase().includes(m);case"comment":return j.value.author.toLowerCase().includes(m)||j.value.title.toLowerCase().includes(m)||j.value.permlink.toLowerCase().includes(m);default:return!1}})}n(y)},[i,l,o]);const v=y=>{if(!y)return t.jsx(z.Activity,{className:"h-4 w-4"});const m=b.find(k=>k.value===y.type)?.icon||z.Activity;return t.jsx(m,{className:"h-4 w-4"})},_=y=>{const m=aa.parseOperation(y);if(!m)return t.jsx("span",{className:"text-gray-400",children:"Unknown operation"});switch(m.type){case"transfer":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Transfer"}),t.jsx("span",{className:"text-sm font-medium text-white",children:m.value.amount})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"From:"}),t.jsx("img",{src:be.userAvatar(m.value.from),alt:`${m.value.from} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.from)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.from})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"To:"}),t.jsx("img",{src:be.userAvatar(m.value.to),alt:`${m.value.to} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.to)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.to})]}),m.value.memo&&t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Memo:"})," ",m.value.memo]})]});case"vote":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Vote"}),t.jsxs("span",{className:"text-sm font-medium text-white",children:[m.value.weight,"%"]})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Voter:"}),t.jsx("img",{src:be.userAvatar(m.value.voter),alt:`${m.value.voter} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.voter)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.voter})]}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"comment":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Comment"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Title:"})," ",m.value.title]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"custom_json":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Custom JSON"})}),t.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",m.value.id]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["JSON: ",m.value.json.substring(0,100),"..."]})]});case"comment_payout_update":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Payout Update"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Permlink:"})," ",m.value.permlink]})]});case"comment_options":return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Comment Options"})}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-2",children:[t.jsx("span",{className:"flex-shrink-0",children:"Author:"}),t.jsx("img",{src:be.userAvatar(m.value.author),alt:`${m.value.author} avatar`,className:"w-4 h-4 rounded-full flex-shrink-0",onError:k=>{k.target.src=be.userAvatar(m.value.author)}}),t.jsx("span",{className:"font-mono text-gray-300 truncate",children:m.value.author})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"Max Payout:"})," ",m.value.max_accepted_payout]}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("span",{className:"flex-shrink-0",children:"HBD Percent:"})," ",m.value.percent_hbd,"%"]})]});case"effective_comment_vote":return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded text-xs font-medium",children:"Effective Vote"}),t.jsx("span",{className:"text-sm font-medium text-white",children:m.value.weight})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Voter:"," ",t.jsx("span",{className:"font-mono text-gray-300",children:m.value.voter})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Post: @",m.value.author,"/",m.value.permlink]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Pending Payout: ",m.value.pending_payout]})]});default:return t.jsx("span",{className:"text-gray-400",children:"Unknown operation"})}},N=aa.getTransactionSummary(i);return u?t.jsxs("div",{className:`bg-gray-800 border border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsxs("div",{className:"p-2 md:p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(z.Activity,{className:"h-5 w-5 text-gray-300"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction History"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Loading transaction history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:y=>{y.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-400",children:["@",e]})]})]}),t.jsx("div",{className:"p-2 md:p-6 space-y-2 md:space-y-4",children:Array.from({length:5}).map((y,m)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-700 rounded animate-pulse w-3/4"}),t.jsx("div",{className:"h-3 bg-gray-700 rounded animate-pulse w-1/2"})]},m))})]}):t.jsxs("div",{className:`bg-gray-800 border border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsxs("div",{className:"p-4 md:p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(z.Activity,{className:"h-5 w-5 text-gray-300"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction History"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Transaction history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:y=>{y.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-400",children:["@",e]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.totalTransactions}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.transfer||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Transfers"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.vote||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Votes"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:N.operationCounts.comment||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Comments"})]})]})]}),t.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsx("div",{className:"flex-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search transactions...",value:o,onChange:y=>h(y.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsx("select",{value:l,onChange:y=>p(y.target.value),className:"w-full sm:w-48 px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:b.map(y=>t.jsx("option",{value:y.value,children:y.label},y.value))}),t.jsxs("select",{value:x.toString(),onChange:y=>w(parseInt(y.target.value)),className:"w-full sm:w-32 px-3 py-2 bg-gray-700 border border-gray-600 rounded-md text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"25",children:"25"}),t.jsx("option",{value:"50",children:"50"}),t.jsx("option",{value:"100",children:"100"}),t.jsx("option",{value:"200",children:"200"})]}),t.jsx("button",{onClick:g,className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded-md hover:bg-gray-600 text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]}),d&&t.jsx("div",{className:"p-4 border border-red-700 bg-red-900 rounded-md",children:t.jsx("p",{className:"text-red-300",children:d})}),t.jsx("div",{className:"space-y-4",children:r.length===0?t.jsx("div",{className:"text-center py-8 text-gray-400",children:"No transactions found"}):r.map(y=>{const m=aa.parseOperation(y);return t.jsxs("div",{className:"border border-gray-600 rounded-lg p-3 md:p-4 space-y-3 hover:bg-gray-700 transition-colors",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[v(m),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:m?.type?m.type.charAt(0).toUpperCase()+m.type.slice(1):"Unknown"}),t.jsxs("div",{className:"text-sm text-gray-400 flex items-center gap-1",children:[t.jsx(z.Clock,{className:"h-3 w-3"}),aa.formatTimestamp(y.timestamp)]})]})]})}),t.jsx("div",{className:"ml-6 md:ml-7",children:_(y)})]},`${y.trx_id}-${y.op_in_trx}`)})}),r.length>0&&t.jsxs("div",{className:"text-center text-sm text-gray-400",children:["Showing ",r.length," of ",i.length," ","transactions"]})]})]})}const Vp=new oa.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Up{async getUserChannel(a,i="posts",s=20,r=null,n=null,u=null){const c={account:a,sort:i,limit:s};r&&(c.start_author=r),n&&(c.start_permlink=n),u&&(c.observer=u);try{const d=await Vp.call("bridge","get_account_posts",c);return Array.isArray(d)?d:[]}catch(d){return console.error("Error in getUserChannel:",d),[]}}async getUserPosts(a,i=20){return this.getUserChannel(a,"posts",i)}async getUserComments(a,i=20){return this.getUserChannel(a,"comments",i)}async getUserReplies(a,i=20){return this.getUserChannel(a,"replies",i)}async getAllUserActivity(a,i=10){try{const[s,r,n]=await Promise.all([this.getUserPosts(a,i),this.getUserComments(a,i),this.getUserReplies(a,i)]);return[...s,...r,...n].sort((c,d)=>new Date(d.created).getTime()-new Date(c.created).getTime())}catch(s){return console.error("Error in getAllUserActivity:",s),[]}}convertToDisplayItem(a){return{id:a.id,author:a.author,permlink:a.permlink,title:a.title,body:a.body,created:a.created,category:a.category,net_votes:a.net_votes,children:a.children,total_payout_value:a.total_payout_value,pending_payout_value:a.pending_payout_value,url:a.url,type:a.parent_author===""?"post":"comment"}}formatTimestamp(a){try{return new Date(a).toLocaleString()}catch(i){return console.error("Error formatting timestamp:",i),a}}getRelativeTime(a){try{const i=new Date(a),r=new Date().getTime()-i.getTime(),n=Math.floor(r/1e3),u=Math.floor(n/60),c=Math.floor(u/60),d=Math.floor(c/24);return n<60?`${n} seconds ago`:u<60?`${u} minutes ago`:c<24?`${c} hours ago`:d<7?`${d} days ago`:i.toLocaleDateString()}catch(i){return console.error("Error calculating relative time:",i),a}}truncateText(a,i=150){return a.length<=i?a:a.substring(0,i)+"..."}getActivitySummary(a){let i=0,s=0,r=0,n=0;return a.forEach(u=>{u.parent_author===""?i++:s++,r+=u.net_votes||0;const c=u.total_payout_value?.match(/(\d+\.?\d*)/);c&&(n+=parseFloat(c[1]))}),{totalActivities:a.length,postsCount:i,commentsCount:s,totalVotes:r,totalPayout:`${n.toFixed(3)} HIVE`,averageVotes:a.length>0?Math.round(r/a.length):0}}filterByCategory(a,i){return a.filter(s=>s.category===i)}filterByDateRange(a,i,s){return a.filter(r=>{const n=new Date(r.created);return n>=i&&n<=s})}searchActivities(a,i){const s=i.toLowerCase();return a.filter(r=>r.title.toLowerCase().includes(s)||r.body.toLowerCase().includes(s)||r.category.toLowerCase().includes(s))}}const na=new Up,zp=({username:e,className:a})=>{const[i,s]=P.useState([]),[r,n]=P.useState([]),[u,c]=P.useState([]),[d,f]=P.useState([]),[o,h]=P.useState([]),[l,p]=P.useState(!1),[x,w]=P.useState(null),[b,g]=P.useState(""),[v,_]=P.useState(20),[N,y]=P.useState("all"),[m,k]=P.useState(new Set),[j,A]=P.useState(!1),D=async()=>{if(!(!e||j)){p(!0),w(null);try{const[$,G,X]=await Promise.all([na.getUserPosts(e,v),na.getUserComments(e,v),na.getUserReplies(e,v)]);s($),n(G),c(X),A(!0)}catch($){w("Failed to load activity history"),console.error("Error loading activities:",$)}finally{p(!1)}}};P.useEffect(()=>{D()},[e]),P.useEffect(()=>{if(!j)return;let $=[];switch(N){case"posts":$=i;break;case"comments":$=r;break;case"replies":$=u;break;default:$=[...i,...r,...u].sort((G,X)=>new Date(X.created).getTime()-new Date(G.created).getTime());break}f($),h($)},[N,i,r,u,j]),P.useEffect(()=>{let $=d;b&&($=na.searchActivities(d,b)),h($)},[d,b]);const C=$=>!$||$==="0.000 HIVE"?"0 HIVE":$,O=$=>$.parent_author===""?"Post":$.depth===1?"Comment":"Reply",L=new to.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:$=>$,usertagUrlFn:$=>`/@${$}`,hashtagUrlFn:$=>`/trending/${$}`,isLinkSafeFn:$=>!0,addExternalCssClassToMatchingLinksFn:$=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"}),H=$=>{const G=new Set(m);G.has($)?G.delete($):G.add($),k(G)},F=$=>{const G=`${$.author}-${$.permlink}`,X=m.has(G),ee=$.body.length>100;return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-3 sm:p-4 space-y-3 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors relative",children:[t.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3",children:t.jsx("div",{className:"flex items-start gap-3 flex-1",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[t.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${$.parent_author===""?"bg-blue-900 text-blue-300":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300"}`,children:O($)}),t.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:["in #",$.category]})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("img",{src:be.userAvatar($.author),alt:`${$.author} avatar`,className:"w-5 h-5 sm:w-6 sm:h-6 rounded-full flex-shrink-0",onError:R=>{R.target.src=be.userAvatar($.author)}}),t.jsx("h3",{className:"font-medium text-base sm:text-lg leading-tight text-gray-900 dark:text-white break-words",children:$.title||"Untitled"})]}),t.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-3 text-gray-500 dark:text-gray-400 comment-content overflow-hidden",children:[t.jsx("div",{className:"break-words overflow-wrap-anywhere",dangerouslySetInnerHTML:{__html:L.render(ee&&!X?$.body.substring(0,50)+".....":$.body)}}),ee&&t.jsxs("button",{onClick:()=>H(G),className:"mt-2 text-blue-400 hover:text-blue-300 text-sm font-medium flex items-center gap-1",children:[t.jsx(z.ChevronDown,{className:`h-3 w-3 transition-transform ${X?"rotate-180":""}`}),X?"Show less":"Show more"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 text-sm text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.Clock,{className:"h-3 w-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:na.getRelativeTime($.created)})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.ThumbsUp,{className:"h-3 w-3 flex-shrink-0"}),t.jsxs("span",{children:[$.net_votes," votes"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(z.Reply,{className:"h-3 w-3 flex-shrink-0"}),t.jsxs("span",{children:[$.children," replies"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{children:"💰"}),t.jsx("span",{children:C($.total_payout_value)})]})]})]})})}),t.jsx("button",{onClick:()=>window.open(`https://peakd.com/@${$.author}/${$.permlink}`,"_blank"),className:"absolute top-3 right-3 flex-shrink-0 p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:t.jsx(z.ExternalLink,{className:"h-4 w-4"})})]},G)},B=na.getActivitySummary(d);return l?t.jsxs("div",{className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm ${a}`,children:[t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading activity history for"}),t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-6 h-6 rounded-full",onError:$=>{$.target.src=be.userAvatar(e)}}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["@",e]})]})}),t.jsx("div",{className:"p-6 space-y-4",children:Array.from({length:5}).map(($,G)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/4"}),t.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-1/2"}),t.jsx("div",{className:"h-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-full"})]},G))})]}):t.jsxs("div",{className:`space-y-6 ${a}`,children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:t.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[t.jsx("img",{src:be.userAvatar(e),alt:`${e} avatar`,className:"w-16 h-16 rounded-full object-cover",onError:$=>{$.target.src=be.userAvatar(e)}}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:["@",e]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"Activity History"}),t.jsx("div",{className:"flex flex-wrap gap-6 text-sm",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.FileText,{className:"w-4 h-4"}),t.jsxs("span",{children:[B.totalActivities," Total Activities"]})]})})]})]})}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex md:grid md:grid-cols-4 overflow-x-auto md:overflow-visible w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsx("button",{onClick:()=>y("all"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="all"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"All"}),t.jsx("button",{onClick:()=>y("posts"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="posts"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Posts"}),t.jsx("button",{onClick:()=>y("comments"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="comments"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Comments"}),t.jsx("button",{onClick:()=>y("replies"),className:`flex-shrink-0 md:flex-shrink px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="replies"?"bg-blue-600 dark:bg-blue-500 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700"}`,children:"Replies"})]}),t.jsxs("div",{className:"mt-6",children:[t.jsxs("div",{className:"flex flex-row gap-4 mb-6",children:[t.jsx("div",{className:"flex-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-500 dark:text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search activities...",value:b,onChange:$=>g($.target.value),className:"w-full pl-10 pr-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),t.jsx("button",{onClick:()=>{A(!1),D()},className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:t.jsx(z.RefreshCw,{className:"h-4 w-4"})})]}),x&&t.jsx("div",{className:"p-4 border border-red-200 dark:border-red-700 bg-red-50 dark:bg-red-900 rounded-md",children:t.jsx("p",{className:"text-red-600 dark:text-red-300",children:x})}),t.jsx("div",{className:"space-y-4",children:o.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No activities found"}):o.map(F)}),o.length>0&&t.jsxs("div",{className:"text-center text-sm text-gray-500 dark:text-gray-400",children:["Showing ",o.length," of ",d.length," ","activities"]})]})]})]})};function Hp({author:e,permlink:a,currentUser:i,hiveValue:s,onUpvote:r,onSubmitComment:n,onComments:u,onReblog:c,onShare:d,onTip:f,onReport:o,onClickCommentUpvote:h}){const l=i==null||i===""?null:i,p=l!=null,[x,w]=P.useState([]),[b,g]=P.useState(0),[v,_]=P.useState(!1),[N,y]=P.useState(!1),[m,k]=P.useState(!1),[j,A]=P.useState({message:"",visible:!1}),[D,C]=P.useState(!1),O=P.useCallback(K=>{A({message:K,visible:!0}),setTimeout(()=>A(te=>({...te,visible:!1})),2500)},[]),L=P.useCallback(async()=>{const K=await Re.getActiveVotes(e,a);w(K)},[e,a]);P.useEffect(()=>{L()},[L]),P.useEffect(()=>{Re.getCommentsList(e,a).then(K=>{g(K.length)})},[e,a]);const H=p&&!!l&&x.some(K=>K.voter.toLowerCase()===l.toLowerCase()),F=(K,te)=>{if(!p){O(`Please Login to ${K}`);return}te()},B=()=>{F("Upvote",()=>{if(H){O("You have already upvoted this post");return}_(!0)})},$=async K=>{if(r){C(!0);try{await Promise.resolve(r(K)),_(!1),await L(),O("Vote submitted successfully")}catch(te){const pe=te instanceof Error?te.message:"Failed to upvote";O(pe)}finally{C(!1)}}},G=()=>{y(!0)},X=()=>{y(!1),p&&!H?_(!0):O(p?"You have already upvoted this post":"Please Login to Upvote")},ee=()=>{F("Comment",()=>{u?.(),k(!0)})},R=()=>{F("Reblog",()=>c?.())},se=()=>{F("Report",()=>o?.())},I=()=>{F("Tip",()=>f?.())},V=()=>{if(d){d();return}typeof navigator<"u"&&navigator.share?navigator.share({title:`${e}'s post`,url:`https://peakd.com/@${e}/${a}`,text:`Check out this post by @${e}`}).then(()=>O("Shared")).catch(()=>{}):(navigator.clipboard?.writeText(`https://peakd.com/@${e}/${a}`),O("Link copied to clipboard"))},J=async(K,te,pe)=>{if(!p){O("Please Login to comment");return}if(n)try{await Promise.resolve(n(K,te,pe)),O("Comment posted")}catch(Ee){const Z=Ee instanceof Error?Ee.message:"Failed to post comment";throw O(Z),Ee}},oe="absolute left-1/2 -translate-x-1/2 bottom-full mb-1 px-2 py-1 text-xs font-medium text-white bg-gray-800 dark:bg-gray-700 rounded shadow-lg whitespace-nowrap opacity-0 pointer-events-none group-hover:opacity-100 transition-opacity duration-150 z-[60]";return t.jsxs("div",{className:"flex items-center justify-between gap-4 text-sm w-full",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 sm:gap-4 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Upvote"}),t.jsx("button",{type:"button",onClick:B,disabled:D,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-50","aria-label":"Upvote",children:D?t.jsx(z.Loader2,{className:"w-4 h-4 sm:w-5 sm:h-5 animate-spin text-blue-600"}):t.jsx(z.ThumbsUp,{className:`w-4 h-4 sm:w-5 sm:h-5 ${H?"text-blue-600 dark:text-blue-400 fill-current":"text-gray-600 dark:text-gray-400"}`})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"View upvotes"}),t.jsx("button",{type:"button",onClick:G,className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":"View upvotes",children:t.jsx("span",{children:x.length})})]})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Comments"}),t.jsxs("button",{type:"button",onClick:ee,className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":"Comments",children:[t.jsx(z.MessageCircle,{className:"w-4 h-4 sm:w-5 sm:h-5"}),t.jsx("span",{children:b})]})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Reblog"}),t.jsx("button",{type:"button",onClick:R,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors p-1 rounded","aria-label":"Reblog",children:t.jsx(z.Repeat2,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Share"}),t.jsx("button",{type:"button",onClick:V,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors p-1 rounded","aria-label":"Share",children:t.jsx(z.Share2,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Report"}),t.jsx("button",{type:"button",onClick:se,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors p-1 rounded","aria-label":"Report",children:t.jsx(z.Flag,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:oe,children:"Tip"}),t.jsx("button",{type:"button",onClick:I,className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 transition-colors p-1 rounded","aria-label":"Tip",children:t.jsx(z.Gift,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]})]}),t.jsx("div",{className:"flex-1 flex justify-end min-w-0 shrink-0",children:s!=null&&s!==""&&t.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:s})}),v&&t.jsx(ro,{author:e,permlink:a,onUpvote:$,onCancel:()=>_(!1)}),N&&t.jsx(yd,{author:e,permlink:a,onClose:()=>y(!1),currentUser:l??void 0,token:void 0,onClickUpvoteButton:X}),m&&t.jsx(ao,{author:e,permlink:a,onClose:()=>{k(!1),Re.getCommentsList(e,a).then(K=>g(K.length))},currentUser:l??void 0,token:void 0,onSubmitComment:n?J:void 0,onClickCommentUpvote:h}),j.visible&&t.jsx("div",{className:"fixed bottom-4 right-4 z-[100] max-w-[280px] rounded-lg bg-gray-800 dark:bg-gray-900 text-white px-3 py-2 shadow-lg text-sm",children:j.message})]})}const Di="_communityLocalKey",Zn={getBookmarkedCommunities:()=>{const e=localStorage.getItem(Di);return e?JSON.parse(e):[]},isUserPresentLocally:e=>{const a=localStorage.getItem(Di);return a?JSON.parse(a).includes(e):!1},storeLikedCommunityLocally:(e,a=!1)=>{let i=Zn.getBookmarkedCommunities();return i.includes(e)?i=i.filter(s=>s!==e):a||i.push(e),localStorage.setItem(Di,JSON.stringify(i)),i}},so=({id:e,toastType:a,isLiked:i,onAdd:s,onRemove:r,onFavourite:n})=>{const[u,c]=P.useState(i??Zn.isUserPresentLocally(e));P.useEffect(()=>{i!==void 0&&c(i)},[i]);const d=()=>{n&&n(),u?(r?r(e,"remove_bookmark"):Zn.storeLikedCommunityLocally(e,!0),f(!1)):(s?s(e,"add_bookmark"):Zn.storeLikedCommunityLocally(e),f(!0)),c(!u)},f=o=>{alert(`The ${a} is ${o?"added to":"removed from"} your bookmarks`)};return t.jsx("button",{onClick:d,className:"p-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:u?t.jsx(z.BookmarkCheck,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}):t.jsx(z.Bookmark,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})};class Wp{HIVE_API_URL="https://api.hive.blog";async getListOfCommunities(a,i=20,s){const r={limit:i};s&&s.trim()!==""&&(r.last=s),a&&a.trim()!==""&&(r.query=a);const n={jsonrpc:"2.0",method:"bridge.list_communities",params:r,id:1};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return(await u.json()).result||[]}catch(u){throw console.error("Error fetching communities:",u),u}}async getCommunityDetails(a){const i={jsonrpc:"2.0",method:"bridge.get_community",params:{name:a},id:1};try{const s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(s){throw console.error("Error fetching community details:",s),s}}async getCommunitySubscribers(a,i=100,s){const r={community:a,limit:i};s&&s.trim()!==""&&(r.last=s);const n={jsonrpc:"2.0",method:"bridge.list_community_roles",params:r,id:1};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return((await u.json()).result||[]).map(d=>({username:d[0],role:d[1],extra:d[2],subscribedAt:d[3]}))}catch(u){throw console.error("Error fetching community subscribers:",u),u}}async getCommunitySubscribersList(a,i=100,s){const r={community:a,limit:i};s&&s.trim()!==""&&(r.last=s);const n={jsonrpc:"2.0",method:"bridge.list_subscribers",params:r,id:2};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return((await u.json()).result||[]).map(d=>({username:d[0],role:d[1],extra:d[2],subscribedAt:d[3]}))}catch(u){throw console.error("Error fetching community subscribers list:",u),u}}async getCommunityAccounts(a){const i={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[[a]],id:2};try{const s=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return(await s.json()).result||[]}catch(s){throw console.error("Error fetching community accounts:",s),s}}async getRankedPosts(a,i="created",s=20,r,n){const u={tag:a,sort:i,limit:s};r&&n&&(u.start_author=r,u.start_permlink=n);const c={jsonrpc:"2.0",method:"bridge.get_ranked_posts",params:u,id:3};try{const d=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return(await d.json()).result||[]}catch(d){throw console.error("Error fetching ranked posts:",d),d}}communityIcon(a){return`https://images.hive.blog/u/${a}/avatar?size=icon`}userOwnerThumb(a){return`https://images.hive.blog/u/${a}/avatar`}async getCommunityActivities(a,i=100,s){const r={account:a,limit:i};s&&(r.last_id=s);const n={jsonrpc:"2.0",method:"bridge.account_notifications",params:r,id:19};try{const u=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return(await u.json()).result||[]}catch(u){throw console.error("Error fetching community activities:",u),u}}}const ot=new Wp,Gp=({onSelectCommunity:e,theme:a="dark"})=>{const[i,s]=P.useState([]),[r,n]=P.useState(""),[u,c]=P.useState(!0),[d,f]=P.useState(!1),[o,h]=P.useState(!0),[l,p]=P.useState(null),[x,w]=P.useState(null),b=20,g=P.useRef(null),v=P.useCallback(async(y=!1)=>{if(!(!y&&(d||!o)))try{y?(c(!0),w(null),s([]),p(null),h(!0)):f(!0);const m=r.trim(),k=await ot.getListOfCommunities(m.length>=3?m:void 0,b,y?void 0:l||void 0);s(j=>y?k:[...j,...k]),k.length<b||k.length>0&&k[k.length-1].name===l?h(!1):k.length>0&&p(k[k.length-1].name||null)}catch(m){w(m instanceof Error?m.message:"Failed to load communities"),h(!1)}finally{c(!1),f(!1)}},[r,d,o,l]);P.useEffect(()=>{const y=setTimeout(()=>{v(!0)},r.length>=3||r.length===0?0:500);return()=>clearTimeout(y)},[r]),P.useEffect(()=>{g.current?.focus()},[r,u,x]),P.useEffect(()=>{const y=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!d&&!u&&o&&v()};return window.addEventListener("scroll",y),()=>window.removeEventListener("scroll",y)},[v,d,u,o]);const _=()=>{v(!0)},N=()=>t.jsx("div",{className:"space-y-4",children:Array.from({length:6}).map((y,m)=>t.jsx("div",{className:`${a==="dark"?"bg-slate-900 border-gray-800":"bg-white border-gray-200"} border rounded-xl p-4 animate-pulse`,children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:`w-12 h-12 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded-full`}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:`h-4 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-3/4`}),t.jsx("div",{className:`h-3 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-1/2`})]}),t.jsx("div",{className:`h-3 ${a==="dark"?"bg-slate-800":"bg-gray-200"} rounded w-16`})]})},m))});return u&&i.length===0?t.jsxs("div",{className:`space-y-6 ${a==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${a==="dark"?"text-gray-400":"text-gray-500"} w-5 h-5`}),t.jsx("input",{type:"text",placeholder:"Search communities...",value:r,onChange:y=>n(y.target.value),ref:g,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 ${a==="dark"?"bg-slate-900 border-gray-800 text-white placeholder-gray-400":"bg-white border-gray-200 text-gray-900 placeholder-gray-500"}
1097
1097
  rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),t.jsx(N,{})]}):x&&i.length===0?t.jsxs("div",{className:`space-y-6 ${a==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx(z.Search,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${a==="dark"?"text-gray-400":"text-gray-500"} w-5 h-5`}),t.jsx("input",{type:"text",placeholder:"Search communities...",value:r,onChange:y=>n(y.target.value),ref:g,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 ${a==="dark"?"bg-slate-900 border-gray-800 text-white placeholder-gray-400":"bg-white border-gray-200 text-gray-900 placeholder-gray-500"}
1098
1098
  rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:`text-lg font-semibold ${a==="dark"?"text-white":"text-gray-900"} mb-2`,children:"Failed to load communities"}),t.jsx("p",{className:`${a==="dark"?"text-gray-400":"text-gray-500"} mb-4`,children:x}),t.jsxs("button",{onClick:_,className:`m-2 inline-flex items-center justify-center rounded-md border ${a==="dark"?"border-gray-800 bg-slate-900 text-gray-400 hover:bg-gray-800 hover:text-white":"border-gray-200 bg-white text-gray-500 hover:bg-gray-100 hover:text-gray-900"} p-2 text-sm font-medium shadow-sm transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})})]}):t.jsxs("div",{className:`space-y-6 ${a==="dark"?"bg-slate-950":"bg-white"}`,children:[t.jsx("div",{className:"",children:t.jsx("h2",{className:`text-xl font-semibold ${a==="dark"?"text-white":"text-gray-900"}`,children:"Communities"})}),t.jsxs("div",{className:"relative flex justify-between items-center",children:[t.jsx(z.Search,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${a==="dark"?"text-gray-400":"text-gray-500"} w-5 h-5`}),t.jsx("input",{type:"text",placeholder:"Search communities...",value:r,onChange:y=>n(y.target.value),ref:g,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 ${a==="dark"?"bg-slate-900 border-gray-800 text-white placeholder-gray-400":"bg-white border-gray-200 text-gray-900 placeholder-gray-500"}
1099
1099
  rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500`}),t.jsx("button",{onClick:_,className:`m-2 inline-flex items-center justify-center rounded-md border ${a==="dark"?"border-gray-800 bg-slate-900 text-gray-400 hover:bg-gray-800 hover:text-white":"border-gray-200 bg-white text-gray-500 hover:bg-gray-100 hover:text-gray-900"} p-2 text-sm font-medium shadow-sm transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:t.jsx(z.RefreshCw,{className:"w-4 h-4"})})]}),i.length===0?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:`text-lg font-semibold ${a==="dark"?"text-white":"text-gray-900"} mb-2`,children:"No communities found"}),t.jsx("p",{className:`${a==="dark"?"text-gray-400":"text-gray-500"}`,children:r?"Try adjusting your search terms":"Check back later for new communities"})]})}):t.jsxs("div",{className:"space-y-4",children:[i.map(y=>t.jsx("div",{className:`${a==="dark"?"bg-slate-900 border-gray-800 hover:bg-slate-800":"bg-white border-gray-200 hover:bg-gray-100"} border rounded-xl p-4 transition-colors cursor-pointer`,onClick:()=>e(y.name||""),children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("img",{src:ot.communityIcon(y.name||""),alt:y.title,className:"w-12 h-12 rounded-full object-cover",onError:m=>{m.target.src=`https://ui-avatars.com/api/?name=${y.title}&background=random`}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:`font-semibold truncate ${a==="dark"?"text-white":"text-gray-900"}`,children:y.title}),t.jsx("p",{className:`text-sm line-clamp-2 ${a==="dark"?"text-gray-400":"text-gray-500"}`,children:y.about})]}),t.jsx("div",{className:"text-right",children:t.jsxs("p",{className:`text-sm ${a==="dark"?"text-gray-400":"text-gray-500"}`,children:[(y.subscribers||0).toLocaleString()," members"]})})]})},y.id)),o&&t.jsx("div",{className:"flex justify-center pt-4",children:d?t.jsxs("div",{className:`flex items-center gap-2 ${a==="dark"?"text-gray-400":"text-gray-500"}`,children:[t.jsx(z.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more communities..."]}):t.jsx("button",{onClick:()=>v(),className:`m-2 inline-flex items-center justify-center rounded-md border ${a==="dark"?"border-gray-800 bg-slate-900 text-gray-400 hover:bg-gray-800 hover:text-white":"border-gray-200 bg-white text-gray-500 hover:bg-gray-100 hover:text-gray-900"} p-2 text-sm font-medium shadow-sm transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:"Load More Communities"})})]})]})},Ad=({communityId:e})=>{const[a,i]=P.useState(null),[s,r]=P.useState(!0),[n,u]=P.useState(null),c=async()=>{try{r(!0),u(null);const h=await ot.getCommunityDetails(e);i(h)}catch(h){u(h instanceof Error?h.message:"Failed to load community details")}finally{r(!1)}};P.useEffect(()=>{c()},[e]);const d=h=>{try{return new Date(h).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return h}},f=h=>h.replace(/<[^>]*>/g,"");if(s)return t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading community details..."]})});if(n)return t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load community details"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:n}),t.jsxs("button",{onClick:c,className:"m-2 inline-flex items-center justify-center rounded-md border border-input bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4"}),"Try Again"]})]})});if(!a?.result)return t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No community details available"})});const o=a.result;return t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[o.about&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"About"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:f(o.about)})]}),o.description&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Information"}),t.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:f(o.description)})]}),o.flag_text&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Community Rules"}),t.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:f(o.flag_text)})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Total Authors"}),t.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:o.num_authors?.toLocaleString()||"0"})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Subscribers"}),t.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:o.subscribers?.toLocaleString()||"0"})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o.created_at?d(o.created_at):"Unknown"})]}),o.lang&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Language"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o.lang.toUpperCase()})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Pending Posts"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o.num_pending?.toLocaleString()||"0"})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Type"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o.is_nsfw?"NSFW":"Safe"})]})]})]})})},Sd=({communityId:e,onSelectTeamMember:a})=>{const[i,s]=P.useState(null),[r,n]=P.useState(!0),[u,c]=P.useState(null),d=async()=>{try{n(!0),c(null);const o=await ot.getCommunityDetails(e);s(o)}catch(o){c(o instanceof Error?o.message:"Failed to load team details")}finally{n(!1)}};P.useEffect(()=>{d()},[e]);const f=i?.result?.team||[];return r?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(z.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading team members..."]})}):u?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load team details"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:u}),t.jsxs("button",{onClick:d,className:"m-2 inline-flex items-center justify-center rounded-md border border-input text-gray-400 cursor-pointer bg-background p-2 text-sm font-medium text-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none",children:[t.jsx(z.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):f.length===0?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No team members found"})}):t.jsx("div",{className:"space-y-6",children:t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:f.map((o,h)=>{const l=o[0],p=o.length>1?o[1]:"";return t.jsx("div",{onClick:()=>a&&a(l),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700