hive-react-kit 1.12.10 → 1.12.11
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 +1 -1
- package/dist/index.esm.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1165,7 +1165,7 @@ ${Ce}
|
|
|
1165
1165
|
`),Fe=ar=>parseFloat((ar??"").replace(/[^\d.]/g,""))||0,Ye=Fe(ge.pending_payout_value),mt=Fe(ge.author_payout_value),Ht=Fe(ge.curator_payout_value),Mr=ge.payout&&ge.payout>0?ge.payout:Ye>0?Ye:mt+Ht,jt={pendingValue:Ye,authorValue:mt,curatorValue:Ht,totalValue:Mr,isPaidout:!!ge.is_paidout,payoutAt:ge.payout_at,percentHbd:ge.percent_hbd??1e4,beneficiaries:(ge.beneficiaries??[]).map(ar=>({account:ar.account,weight:ar.weight}))},Et=I?ar=>{ar.button!==0||ar.metaKey||ar.ctrlKey||ar.shiftKey||ar.altKey||I(ge.author,ge.permlink,ge.title)}:void 0,br=!!ie&&!!ye&&o?.toLowerCase()!==Og&&ge.author.toLowerCase()!==o?.toLowerCase()&&!hy(ge.active_votes)&&my(ge.json_metadata);return e.jsxs("div",{className:`group overflow-hidden rounded-[14px] border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)] transition-[background-color,border-color] duration-150 ease-out hover:border-[var(--hrk-border-default)] hover:bg-[var(--hrk-bg-surface-raised)] ${Et?"cursor-pointer":""}`,onClick:Et,children:[e.jsxs("div",{className:"flex items-stretch",children:[e.jsxs("div",{className:"min-w-0 flex-1 p-2.5 sm:p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 sm:mb-1.5 sm:gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${ge.author}/avatar`,alt:ge.author,loading:"lazy",decoding:"async",className:`h-7 w-7 flex-shrink-0 rounded-full bg-[var(--hrk-bg-surface-sunken)] object-cover sm:h-9 sm:w-9 ${Zc(Ie[ge.author],"ring-1 ring-[var(--hrk-border-subtle)]")}`,onError:ar=>{ar.target.src=`https://ui-avatars.com/api/?name=${ge.author}&background=random&size=40`}}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0 sm:gap-x-2 sm:gap-y-0.5",children:[e.jsx(ai,{href:Z?.(ge.author),onActivate:()=>F?.(ge.author),className:"text-[11px] font-medium text-white hover:text-[var(--hrk-brand)] sm:text-sm",children:Ie[ge.author]?e.jsxs("span",{className:`inline-block rounded px-1 py-0.5 text-[10px] font-medium sm:text-xs ${ef(Ie[ge.author])}`,children:["@",ge.author]}):e.jsxs(e.Fragment,{children:["@",ge.author]})}),e.jsx(ai,{href:Y?.(ge.author,ge.permlink),onActivate:()=>I?.(ge.author,ge.permlink,ge.title),className:"text-[10px] text-[var(--hrk-text-tertiary)] hover:text-[var(--hrk-brand)] hover:underline sm:text-xs",children:hP(ge.created)}),ge.community_title&&e.jsxs(ai,{href:ge.community?J?.(ge.community):void 0,onActivate:()=>{ge.community&&F?.(ge.community)},className:"text-[10px] font-medium text-[var(--hrk-brand)] hover:underline sm:text-xs",children:["#",ge.community_title]})]}),ge.stats?.is_pinned&&e.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1 rounded-full bg-[var(--hrk-brand)]/15 px-2 py-0.5 text-[9px] font-bold uppercase tracking-wide text-[var(--hrk-brand)] sm:text-[10px]",children:[e.jsx(X.Pin,{className:"h-3 w-3"}),"Pinned"]})]}),ge.title&&e.jsx(ai,{href:Y?.(ge.author,ge.permlink),onActivate:()=>I?.(ge.author,ge.permlink,ge.title),className:"mb-0.5 line-clamp-2 block text-left text-[13px] font-semibold leading-snug text-white hover:text-[var(--hrk-brand)] sm:mb-1 sm:text-base",children:e.jsx(Gc,{text:ge.title})}),Le&&e.jsx("p",{className:"line-clamp-2 text-[11px] leading-snug text-[var(--hrk-text-tertiary)] sm:line-clamp-3 sm:text-sm sm:leading-relaxed",children:e.jsx(Gc,{text:Le.substring(0,240)})})]}),e.jsx(gP,{media:rt}),q&&ge.json_metadata?.content_type==="poll"&&e.jsx("div",{className:"mt-2",onClick:ar=>ar.stopPropagation(),children:e.jsx(nC,{author:ge.author,permlink:ge.permlink,currentUser:o,onVotePoll:q,parsedMetadata:ge.json_metadata})})]}),e.jsx("div",{className:"border-t border-[var(--hrk-border-subtle)] px-2.5 py-2 sm:px-4",onClick:ar=>ar.stopPropagation(),children:e.jsx(Lg,{author:ge.author,permlink:ge.permlink,currentUser:o,onUserClick:F,getUserUrl:Z,hiveValue:ue,hiveIconUrl:"/images/hive_logo.png",payoutTooltip:We,payoutDetails:jt,initialVotes:ge.active_votes??[],initialVoteCount:ge.stats?.total_votes??Math.max(ge.active_votes?.length??0,ge.net_votes??0),initialFlagWeight:ge.stats?.flag_weight,initialCommentsCount:ge.children||0,postCreatedAt:ge.created,onUpvote:g?ar=>g(ge.author,ge.permlink,ar):void 0,curationEligible:br,curationType:"post",onCurationRequest:ye?(ar,hr)=>ye(ge.author,ge.permlink,ar,hr):void 0,onFetchCurationStatus:Ee,onSubmitComment:x?(ar,hr,je)=>x(ar,hr,je):void 0,onClickCommentUpvote:y,onReblog:b?()=>b(ge.author,ge.permlink):void 0,isReblogged:w?w(ge.author,ge.permlink):!1,onCheckReblogged:v,onShare:C?()=>C(ge.author,ge.permlink):void 0,onTip:ge.author!==o&&N?()=>N(ge.author,ge.permlink):void 0,onToggleBookmark:E?()=>E(ge.author,ge.permlink):void 0,isBookmarked:P?P(ge.author,ge.permlink):!1,onReport:ge.author!==o&&M?()=>M(ge.author,ge.permlink):void 0,onDelete:ge.author===o&&$?()=>$(ge.author,ge.permlink):void 0,onPin:H&&!ge.stats?.is_pinned&&z?()=>z(ge.author,ge.permlink):void 0,onUnpin:H&&ge.stats?.is_pinned&&A?()=>A(ge.author,ge.permlink):void 0,disableCommentsModal:!!R,onComments:R?()=>R(ge.author,ge.permlink):void 0,ecencyToken:te,threeSpeakApiKey:de,giphyApiKey:fe,templateToken:W,templateApiBaseUrl:Q,defaultReward:Se,defaultVotePercent:se,voteWeightStep:xe,allowLandscapeVideos:be,awaitingWalletApproval:Oe,actionsAsMenu:me})})]},`${ge.author}/${ge.permlink}`)}),d&&f&&e.jsx(bP,{onLoadMore:f,loadingMore:u})]})},bP=({onLoadMore:a,loadingMore:o})=>{const l=T.useRef(null),u=T.useRef(a),d=T.useRef(!!o);return T.useEffect(()=>{u.current=a},[a]),T.useEffect(()=>{d.current=!!o},[o]),T.useEffect(()=>{const f=l.current;if(!f)return;const h=new IntersectionObserver(g=>{g[0]?.isIntersecting&&!d.current&&u.current()},{root:null,rootMargin:"600px",threshold:0});return h.observe(f),()=>h.disconnect()},[]),e.jsx("div",{ref:l,className:"flex justify-center py-3 text-xs text-[var(--hrk-text-tertiary)]","aria-hidden":!o,children:o?e.jsxs("span",{className:"inline-flex items-center gap-2",role:"status","aria-live":"polite",children:[e.jsx(X.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Loading more…"]}):e.jsx("span",{className:"block h-px w-full"})})},lC="hrk-selection-translate-cache-v1",P8=200;let Wd=null;const B8=new Map,ek=new Map;function U8(){if(Wd)return Wd;try{const a=typeof sessionStorage<"u"?sessionStorage.getItem(lC):null;Wd=a?JSON.parse(a):{}}catch{Wd={}}return Wd}function xP(){if(Wd)try{const a=Object.keys(Wd);if(a.length>P8){const o=Math.max(1,Math.floor(a.length-P8*.8));for(let l=0;l<o;l++)delete Wd[a[l]]}typeof sessionStorage<"u"&&sessionStorage.setItem(lC,JSON.stringify(Wd))}catch{}}function vP(a){let o=5381;for(let l=0;l<a.length;l++)o=(o<<5)+o^a.charCodeAt(l);return(o>>>0).toString(36)}function yP(a,o){return`${o}:${vP(a)}`}async function uC(a,o){const l=(a??"").trim();if(!l)return"";if(!o)return l;const u=yP(l,o),d=U8()[u]??B8.get(u);if(d)return d;const f=ek.get(u);if(f)return f;const h=(async()=>{try{const g=`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${encodeURIComponent(o)}&dt=t&q=${encodeURIComponent(l)}`,x=await fetch(g);if(!x.ok)throw new Error(`google ${x.status}`);const y=await x.json(),b=[];if(Array.isArray(y)&&Array.isArray(y[0]))for(const v of y[0])Array.isArray(v)&&typeof v[0]=="string"&&b.push(v[0]);const w=b.join("").trim();if(!w)throw new Error("empty");return B8.set(u,w),U8()[u]=w,xP(),w}catch{return l}finally{ek.delete(u)}})();return ek.set(u,h),h}const ky=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"pt",label:"Portuguese"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"ru",label:"Russian"},{code:"ar",label:"Arabic"},{code:"hi",label:"Hindi"},{code:"zh-CN",label:"Chinese (Simplified)"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"tr",label:"Turkish"},{code:"id",label:"Indonesian"},{code:"vi",label:"Vietnamese"}],cC="hrk-selection-translate-lang";function Dk(){try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(cC);if(a)return a}}catch{}if(typeof navigator<"u"&&navigator.language){const a=navigator.language.split("-")[0],o=ky.find(l=>l.code===a);if(o)return o.code}return"en"}function dC(a){try{typeof sessionStorage<"u"&&sessionStorage.setItem(cC,a)}catch{}}const Mk=8;function Vv({children:a,languages:o=ky,minLength:l=2}){const u=T.useRef(null),[d,f]=T.useState(null),[h,g]=T.useState(null),[x,y]=T.useState(()=>Dk()),[b,w]=T.useState(!1),[v,N]=T.useState(!1),[C,R]=T.useState(null),[M,E]=T.useState(null);T.useEffect(()=>{const A=()=>{if(h)return;const Z=typeof window<"u"?window.getSelection():null;if(!Z||Z.isCollapsed||Z.rangeCount===0){f(null);return}const J=Z.toString().trim();if(J.length<l){f(null);return}const te=Z.getRangeAt(0),de=te.commonAncestorContainer.nodeType===Node.TEXT_NODE?te.commonAncestorContainer.parentElement:te.commonAncestorContainer;if(!u.current||!de||!u.current.contains(de)){f(null);return}const fe=te.getBoundingClientRect();f({text:J,anchor:{top:fe.bottom+Mk,left:fe.left+fe.width/2}})},q=()=>window.setTimeout(A,30),F=()=>q(),I=()=>q(),Y=Z=>{const J=Z.target;J&&J.closest("[data-hrk-translate-ui]")||f(null)};return document.addEventListener("pointerup",F),document.addEventListener("touchend",I),document.addEventListener("mousedown",Y),()=>{document.removeEventListener("pointerup",F),document.removeEventListener("touchend",I),document.removeEventListener("mousedown",Y)}},[l,h]),T.useEffect(()=>{if(!h)return;const A=q=>{q.key==="Escape"&&(g(null),R(null),E(null),w(!1))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[h]);const P=T.useCallback(async(A,q)=>{N(!0);try{const F=await uC(A,q);R(F)}finally{N(!1)}},[]),$=T.useCallback(()=>{if(!d)return;const A=Dk();y(A),E(d.text),g(d.anchor),f(null),R(null),P(d.text,A)},[d,P]),H=T.useCallback(A=>{y(A),dC(A),w(!1),M&&P(M,A)},[M,P]),z=T.useCallback(()=>{g(null),R(null),E(null),w(!1)},[]);return e.jsxs("div",{ref:u,children:[a,d&&e.jsx(wP,{anchor:d.anchor,onClick:$}),h&&M&&Mu.createPortal(e.jsx(_P,{anchor:h,sourceText:M,translated:C,loading:v,targetLang:x,picking:b,languages:o,onPickerToggle:()=>w(A=>!A),onPickLanguage:H,onClose:z}),document.body)]})}function wP({anchor:a,onClick:o}){return typeof document>"u"?null:Mu.createPortal(e.jsxs("button",{type:"button","data-hrk-translate-ui":"trigger",onMouseDown:l=>{l.preventDefault(),l.stopPropagation(),o()},style:{position:"fixed",top:a.top,left:a.left,transform:"translateX(-50%)",zIndex:2100},className:"inline-flex items-center gap-1 rounded-full border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-raised)] px-2.5 py-1 text-[11px] font-semibold text-[var(--hrk-text-primary)] shadow-lg hover:bg-[var(--hrk-bg-hover)]","aria-label":"Translate selection",children:[e.jsx(X.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),"Translate"]}),document.body)}const bw=320;function _P({anchor:a,sourceText:o,translated:l,loading:u,targetLang:d,picking:f,languages:h,onPickerToggle:g,onPickLanguage:x,onClose:y}){const b=T.useRef(null),[w,v]=T.useState(a),[N,C]=T.useState(0);T.useLayoutEffect(()=>{const A=typeof window<"u"?window.innerWidth:0,q=typeof window<"u"?window.innerHeight:0,F=Math.max(8,Math.min(A-bw-8,a.left-bw/2)),I=8,Y=b.current?.offsetHeight??240;let Z=a.top,J=q-Z-I;if(Y>J){const de=a.top-Y-16-2*Mk,fe=a.top-16-2*Mk-I;de>=I?(Z=de,J=fe):fe>J&&(Z=I,J=fe)}Z<I&&(Z=I);const te=Math.max(160,Math.min(J,q-I*2));v({top:Z,left:F}),C(te)},[a]),T.useEffect(()=>{const A=F=>{const I=F.target;I&&I.closest("[data-hrk-translate-ui]")||y()},q=window.setTimeout(()=>{document.addEventListener("mousedown",A)},0);return()=>{window.clearTimeout(q),document.removeEventListener("mousedown",A)}},[y]);const[R,M]=T.useState({dx:0,dy:0}),E=T.useRef(null),P=T.useCallback(A=>{const q=A.target;if(!(q&&q.closest("button"))){A.preventDefault(),A.stopPropagation(),E.current={startClientX:A.clientX,startClientY:A.clientY,startDx:R.dx,startDy:R.dy,pointerId:A.pointerId};try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}}},[R.dx,R.dy]),$=T.useCallback(A=>{const q=E.current;if(!q||q.pointerId!==A.pointerId)return;A.preventDefault();const F=window.innerWidth,I=window.innerHeight,Y=b.current?.offsetHeight??240,Z=8,J=-(w.left+bw-Z),te=F-w.left-Z,de=-(w.top-Z),fe=I-w.top-Math.min(40,Y),W=q.startDx+(A.clientX-q.startClientX),Q=q.startDy+(A.clientY-q.startClientY);M({dx:Math.max(J,Math.min(te,W)),dy:Math.max(de,Math.min(fe,Q))})},[w.left,w.top]),H=T.useCallback(A=>{if(E.current?.pointerId===A.pointerId){try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}E.current=null}},[]),z=h.find(A=>A.code===d)?.label??d;return e.jsxs("div",{ref:b,"data-hrk-translate-ui":"popover",style:{position:"fixed",top:w.top+R.dy,left:w.left+R.dx,width:bw,maxHeight:N?`${N}px`:"calc(100vh - 16px)",display:"flex",flexDirection:"column",zIndex:2200},className:"overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface)] shadow-2xl",role:"dialog","aria-label":"Translation",children:[e.jsxs("div",{className:"flex shrink-0 cursor-grab items-center justify-between gap-2 border-b border-[var(--hrk-border-subtle)] px-3 py-2 active:cursor-grabbing",style:{touchAction:"none"},onPointerDown:P,onPointerMove:$,onPointerUp:H,onPointerCancel:H,"aria-label":"Drag to move",children:[e.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold text-[var(--hrk-text-primary)] hover:bg-[var(--hrk-bg-hover)]",children:[e.jsx(X.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),z,e.jsx(X.ChevronDown,{className:"h-3 w-3 text-[var(--hrk-text-tertiary)]"})]}),e.jsx(X.GripHorizontal,{"aria-hidden":!0,className:"pointer-events-none h-3.5 w-3.5 text-[var(--hrk-text-tertiary)]"}),e.jsx("button",{type:"button",onClick:y,"aria-label":"Close",className:"flex h-6 w-6 items-center justify-center rounded-full text-[var(--hrk-text-tertiary)] hover:bg-[var(--hrk-bg-hover)] hover:text-[var(--hrk-text-primary)]",children:e.jsx(X.X,{className:"h-3.5 w-3.5"})})]}),f?e.jsx("ul",{role:"listbox",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:h.map(A=>{const q=A.code===d;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":q,onClick:()=>x(A.code),className:"flex w-full items-center justify-between px-3 py-1.5 text-left text-xs transition-colors "+(q?"bg-[var(--hrk-bg-hover)] text-[var(--hrk-text-primary)]":"text-[var(--hrk-text-secondary)] hover:bg-[var(--hrk-bg-hover)]"),children:[e.jsx("span",{children:A.label}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--hrk-text-tertiary)]",children:A.code})]})},A.code)})}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2.5",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:[e.jsx("p",{className:"mb-2 text-[11px] italic text-[var(--hrk-text-tertiary)]",children:o}),e.jsx("div",{className:"min-h-[36px] whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--hrk-text-primary)]",children:u?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[var(--hrk-text-tertiary)]",children:[e.jsx(X.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Translating…"]}):l||o})]})]})}const kP=new Set(["peakd.com","www.peakd.com","hive.blog","www.hive.blog","ecency.com","www.ecency.com","inleo.io","www.inleo.io","snapie.io","www.snapie.io","hivesuite.app","www.hivesuite.app"]);function xw(a,o){const l=a?.toLowerCase();return l?o?{kind:"post",author:l,permlink:o}:{kind:"user",author:l}:null}function zg(a){if(!a)return null;if(a.startsWith("#/@")){const[f,h]=a.slice(3).split("/").filter(Boolean);return xw(f,h)}if(a.startsWith("/@")){const[f,h]=a.slice(2).split("/").filter(Boolean);return xw(f,h)}let o;try{o=new URL(a)}catch{return null}const l=o.hostname.toLowerCase();if(!kP.has(l))return null;const u=o.pathname.split("/").filter(Boolean);if((l==="inleo.io"||l==="www.inleo.io")&&u[0]==="threads"&&u[1]==="view")return xw(u[2],u[3]);const d=u.findIndex(f=>f.startsWith("@"));return d===-1?null:xw(u[d].slice(1),u[d+1])}function u3(a,o){if(!a)return a;const l=o??(u=>`https://peakd.com/@${u}`);return a.replace(/(^|[^A-Za-z0-9_!#$%&*@/@])@([a-z][a-z0-9.-]{1,15}[a-z0-9])(?![a-z0-9.-])/gi,(u,d,f)=>{const h=f.toLowerCase();return`${d}[@${f}](${l(h)})`})}const jP=["youtube.com","youtu.be","3speak.tv","3speak.co","odysee.com","lbry.tv","spotify.com","vimeo.com","twitch.tv","soundcloud.com","twitter.com","x.com"],NP=/\.(?:jpe?g|png|gif|webp|avif|bmp|svg)(?:\?[^\s"'<>)]*)?$/i,SP=/\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?$/i;function EP(a){try{const o=new URL(a),l=o.hostname.toLowerCase(),u=o.pathname;return!!(jP.some(f=>l===f||l.endsWith("."+f))||u.includes("/ipfs/")||NP.test(a)||SP.test(a))}catch{return!1}}function c3(a){return a&&a.replace(/(^|[^<"'(])(https?:\/\/[^\s<>"']+?)(?=[.,!?]*(?:[\s>)"']|$))/gi,(o,l,u)=>EP(u)?o:`${l}<${u}>`)}function d3(a,o){if(!a)return a;const l=o??(u=>`https://peakd.com/created/${u}`);return a.replace(/(^|[^A-Za-z0-9_!#$%&*@/@])#([a-zA-Z0-9_]+)(?![a-zA-Z0-9_])/g,(u,d,f)=>/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(f)?u:`${d}[#${f}](${l(f)})`)}function AP(a){return a.trim().replace(/[)\],.;:>\s"'<]+$/,"")}function xm(a){const o=zg(AP(a));return o&&o.kind==="post"?{author:o.author,permlink:o.permlink}:null}function fC(a){const o=(a||"").trim();if(!o)return null;if(/^https?:\/\/\S+$/.test(o))return xm(o);const l=o.match(/^\[[^\]]*\]\((https?:\/\/[^)\s]+)\)$/);if(l)return xm(l[1]);const u=o.match(/^<a\s[^>]*href=["'](https?:\/\/[^"']+)["'][^>]*>[^<]*<\/a>$/i);if(u)return xm(u[1]);const d=o.match(/\[[^\]]*\]\((https?:\/\/[^)\s]+)\)/);if(d){const x=xm(d[1]);if(x)return x}const f=o.match(/<a\s[^>]*href=["'](https?:\/\/[^"']+)["'][^>]*>[^<]*<\/a>/i);if(f){const x=xm(f[1]);if(x)return x}const h=/https?:\/\/[^\s"'<>)\]]+/g;let g;for(;(g=h.exec(o))!==null;){const x=xm(g[0]);if(x)return x}return null}function TP(a,o){if(!o)return a;const l=d=>{const f=xm(d);return f?.author===o.author&&f.permlink===o.permlink};let u=a.replace(/\[[^\]]*\]\((https?:\/\/[^)\s]+)\)/g,(d,f)=>l(f)?"":d);return u=u.replace(/<a\s[^>]*href=["'](https?:\/\/[^"']+)["'][^>]*>[^<]*<\/a>/gi,(d,f)=>l(f)?"":d),u=u.replace(/https?:\/\/[^\s"'<>)\]]+/g,d=>l(d)?"":d),u.replace(/[ \t]+\n/g,`
|
|
1166
1166
|
`).replace(/\n{3,}/g,`
|
|
1167
1167
|
|
|
1168
|
-
`).trim()}function CP(a){const o=a.level??a.depth;if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const l=Number.parseInt(o,10);if(Number.isFinite(l))return l}return a.parent_author?1:0}const Eh=/https?:\/\/[^\s"'<>)]+\/ipfs\/[a-zA-Z0-9]+(?:\/[^\s"'<>)]*)?/gi,Fv=new Map,tk=new Map;function DP(a){const o=Fv.get(a);if(o)return Promise.resolve(o);const l=tk.get(a);if(l)return l;const u=fetch(a,{method:"HEAD"}).then(d=>{const f=(d.headers.get("content-type")??"").toLowerCase(),h=f.startsWith("image/")?"image":f.startsWith("video/")?"video":"unknown";return Fv.set(a,h),h}).catch(()=>{const d="unknown";return Fv.set(a,d),d}).finally(()=>{tk.delete(a)});return tk.set(a,u),u}function Pj(a){const[o,l]=T.useState(()=>Fv.get(a)??null);return T.useEffect(()=>{let u=!1;const d=Fv.get(a);if(d){l(d);return}return l(null),DP(a).then(f=>{u||l(f)}),()=>{u=!0}},[a]),o}const MP=({url:a,variant:o="full",onTileClick:l,className:u})=>{const d=Pj(a);return d===null?e.jsx("div",{className:`flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Resolving IPFS media",children:e.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):d==="image"?o==="tile"?e.jsx("button",{type:"button",onClick:l,className:`relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Open image preview",children:e.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})}):e.jsx("img",{src:a,alt:"",className:`max-h-full max-w-full object-contain ${u??""}`}):d==="video"?e.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",className:`max-h-full max-w-full ${u??""}`}):e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-[var(--hrk-brand)] underline ${u??""}`,children:a})},Ok=/https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi,Ah=/https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^\s"'<>)]+/gi,Rk=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi,vm=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)|https?:\/\/youtu\.be\/([^?\s]+)|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/gi,Lk=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,zk=/https?:\/\/[^\s"'<>)]+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,Pk=/https?:\/\/audio\.3speak\.tv\/play\?[^\s"'<>)]+/gi,Bk=/!\[[^\]]*\]\(([^\s)]+)\)/g,Uk=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,hC=/https?:\/\/[^\s"'<>)]+?\.(?:jpe?g|png|gif|webp|avif|bmp|svg|heic|heif)(?:\?[^\s"'<>)]*)?/gi,OP=/https?:\/\/[^\s)<>\]]+/g,RP=/@([a-z][a-z0-9.-]{1,15}[a-z0-9])/g,LP=/(?:^|\s)#([a-zA-Z][\w-]{0,31})/g;function kh(a){return Array.from(new Set(a))}function zP(a){return a.trim().replace(/[)\],.;:>\s"'<]+$/,"").replace(/^(https?):\/(?!\/)/,"$1://")}function PP(a){const o=new Set,l=[];for(const u of a){if(typeof u!="string")continue;const d=zP(u);if(!d||!/^https?:\/\//.test(d))continue;let f=d;try{f=decodeURIComponent(d)}catch{}o.has(f)||(o.add(f),l.push(d))}return l}function mC(a){if(!a)return a;const o=a.trim(),l=/\.(heic|heif)(?:\?[^\s"'<>)]*)?$/i.test(o),u=/^https:\/\/images\.ecency\.com\/(?:\d+x\d+|p|0x0)\//i.test(o);return l?u?o:`https://images.ecency.com/0x0/${o}`:o}function Bj(a){if(!a)return{};if(typeof a=="string")try{return JSON.parse(a)}catch{return{}}return typeof a=="object"?a:{}}const BP=new Set(["hsnaps","hreplier","hivesuite"]);function UP(a){const o=Bj(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).some(u=>typeof u=="string"&&BP.has(u.toLowerCase()))}function HP(a){const o=Bj(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).filter(u=>typeof u=="string"&&u.length>0)}function Hk(a){return a.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\][^<]*<\/sub>\s*$/,"").replace(/\s*(?:<br\s*\/?>)?\s*\[via Apps from\]\([^)]*\)\s*$/,"").replace(/\s*(?:<br\s*\/?>)?\s*via Apps from\s+https?:\/\/\S+\s*$/,"")}function pC(a){const o=Hk(a.body??""),l=[];let u;for(;u=Bk.exec(o);)l.push(u[1]);for(;u=Uk.exec(o);)l.push(u[1]);for(;u=hC.exec(o);)l.push(u[0]);const d=[],f=new RegExp(Eh.source,Eh.flags);for(;u=f.exec(o);)d.push(u[0]);const h=[];for(;u=vm.exec(o);)h.push(u[1]||u[2]||u[3]);const g=[];for(;u=Lk.exec(o);)g.push(u[0]);const x=[];for(;u=Pk.exec(o);)x.push(u[0]);const y=[];for(;u=zk.exec(o);)x.includes(u[0])||y.push(u[0]);const b=[];for(;u=Rk.exec(o);)b.push(u[1]);const w=[];for(;u=Ok.exec(o);)w.push(u[0]);const v=[],N=new Set,C=/<iframe\b[^>]*\bsrc=["'](https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^"']+)["'][^>]*>/gi;for(;u=C.exec(o);){const I=u[1];N.has(I)||(N.add(I),v.push(I))}const R=new RegExp(Ah.source,Ah.flags);for(;u=R.exec(o);){const I=u[0];N.has(I)||(N.add(I),v.push(I))}const M=[...PP(l).map(I=>({kind:"image",url:I})),...kh(d).map(I=>({kind:"ipfs",url:I})),...kh(h).map(I=>({kind:"youtube",id:I})),...kh(g).map(I=>({kind:"threespeak",url:I})),...kh(b).map(I=>({kind:"twitter",id:I})),...kh(x).map(I=>({kind:"3speak-audio",url:I})),...kh(y).map(I=>({kind:"audio",url:I})),...kh(w).map(I=>({kind:"spotify",url:I})),...kh(v).map(I=>({kind:"odysee",url:I}))];let E=o;E=E.replace(Bk,""),E=E.replace(Uk,""),E=E.replace(Eh,""),E=E.replace(vm,""),E=E.replace(Lk,""),E=E.replace(Pk,""),E=E.replace(zk,""),E=E.replace(Rk,""),E=E.replace(Ok,""),E=E.replace(/<iframe\b[^>]*\bsrc=["'][^"']*(?:odysee\.com|lbry\.tv)[^"']*["'][^>]*>(?:\s*<\/iframe>)?/gi,""),E=E.replace(new RegExp(Ah.source,Ah.flags),""),E=E.replace(/<[^>]+>/g,""),E=E.replace(/\[([^\]]+)\]\(([^\s)]+)\)/g,"$1 $2"),E=E.replace(/[*_~`>#-]+/g," "),E=E.replace(/\s+/g," ").trim();const P=[];let $=0;const H=[];let z;const A=new RegExp(OP.source,"g");for(;(z=A.exec(E))!==null;)H.push({start:z.index,end:z.index+z[0].length,node:{kind:"link",url:z[0]}});const q=new RegExp(RP.source,"g");for(;(z=q.exec(E))!==null;)H.some(I=>z.index>=I.start&&z.index<I.end)||H.push({start:z.index,end:z.index+z[0].length,node:{kind:"mention",username:z[1]}});const F=new RegExp(LP.source,"g");for(;(z=F.exec(E))!==null;){const I=z.index+(z[0].startsWith(" ")?1:0);H.some(Y=>I>=Y.start&&I<Y.end)||H.push({start:I,end:I+(z[0].length-(z[0].startsWith(" ")?1:0)),node:{kind:"hashtag",tag:z[1]}})}H.sort((I,Y)=>I.start-Y.start);for(const I of H)$<I.start&&P.push({kind:"text",text:E.slice($,I.start)}),P.push(I.node),$=I.end;return $<E.length&&P.push({kind:"text",text:E.slice($)}),P.length===0&&E&&P.push({kind:"text",text:E}),{segments:P,attachments:M}}function gC(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const $P=({author:a,permlink:o})=>e.jsx("div",{className:"three-speak-embed my-3 hive-post-body",style:{margin:"0.75rem auto"},children:e.jsx(_m,{author:a,permlink:o})}),H8=a=>a.kind==="image"?a.url.toLowerCase().includes(".gif")?"GIF":"Image":a.kind==="youtube"?"YouTube":a.kind==="threespeak"?"3Speak":a.kind==="twitter"?"Tweet":a.kind==="3speak-audio"?"3Speak audio":a.kind==="spotify"?"Spotify":a.kind==="odysee"?"Odysee":"Audio";function f3(a){try{const o=new URL(a),l=o.hostname.replace(/^www\./,"");if(l!=="odysee.com"&&l!=="lbry.tv")return null;const u=o.pathname.startsWith("/$/embed/")?o.pathname:`/$/embed${o.pathname}`,d=new URLSearchParams(o.search);return d.set("disable_comments","1"),`https://odysee.com${u}?${d.toString()}`}catch{return null}}const bC=({id:a})=>{const[o,l]=T.useState(null);T.useEffect(()=>{const d=f=>{try{const h=typeof f.data=="string"?JSON.parse(f.data):f.data;if(!h||typeof h!="object")return;let g;if(h.method==="resize"&&Array.isArray(h.params))for(const x of h.params)typeof x=="number"&&x>0&&(g=x),x&&typeof x=="object"&&typeof x.height=="number"&&(g=x.height);h["twttr.private.resize"]?.height&&(g=h["twttr.private.resize"].height),!g&&typeof h.height=="number"&&(g=h.height),!g&&h.msg_type==="resize"&&h.msg_data?.height&&(g=h.msg_data.height),g&&g>50&&l(Math.ceil(g))}catch{}};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const u=typeof window<"u"?window.location.origin:"";return e.jsx("div",{className:"twitter-embed-wrapper w-full overflow-hidden rounded-lg bg-black/60",style:o?{maxHeight:"80vh",overflowY:"auto"}:void 0,children:e.jsx("iframe",{src:`https://platform.twitter.com/embed/Tweet.html?id=${a}&theme=dark&dnt=true&origin=${encodeURIComponent(u)}`,title:`Tweet ${a}`,className:"twitter-embed-iframe w-full border-0 bg-black",scrolling:"yes",style:{height:o??"60vh"}})})},Ov=1,$8=.25,qP=.15,xC=({src:a})=>{const o=mC(a),[l,u]=T.useState(1),[d,f]=T.useState(3),[h,g]=T.useState({x:0,y:0}),x=T.useRef(null),y=T.useRef(null),b=T.useRef(null),w=T.useRef(null),v=T.useCallback(()=>{u(1),g({x:0,y:0})},[]);T.useEffect(()=>{v()},[a,v]);const N=T.useCallback(()=>{const I=y.current;if(!I)return;const Y=I.clientWidth||1,Z=I.clientHeight||1,J=Math.max(I.naturalWidth/Y,I.naturalHeight/Z);f(Math.max(1,Math.min(6,J||1)))},[]),C=l>1,R=Math.round(l*100),M=T.useCallback(I=>{I.preventDefault();const Y=x.current;if(!Y)return;const Z=Y.getBoundingClientRect(),J=I.clientX-(Z.left+Z.width/2),te=I.clientY-(Z.top+Z.height/2);u(de=>{const fe=I.deltaY<0?1:-1,W=Math.max(Ov,Math.min(d,de+fe*qP));return W===de?de:(g(Q=>{if(W===1)return{x:0,y:0};const se=W/de;return{x:J-(J-Q.x)*se,y:te-(te-Q.y)*se}}),W)})},[d]),E=T.useCallback(I=>{I.stopPropagation(),l===1?u(d):v()},[l,d,v]),P=T.useCallback(I=>{if(I.touches.length===2){const[Y,Z]=[I.touches[0],I.touches[1]];w.current={startDistance:Math.hypot(Y.clientX-Z.clientX,Y.clientY-Z.clientY),startZoom:l};return}if(C){const Y=I.touches[0];Y&&(b.current={startClientX:Y.clientX,startClientY:Y.clientY,startPanX:h.x,startPanY:h.y})}},[l,C,h.x,h.y]),$=T.useCallback(I=>{if(I.touches.length===2&&w.current){const[Y,Z]=[I.touches[0],I.touches[1]],te=Math.hypot(Y.clientX-Z.clientX,Y.clientY-Z.clientY)/w.current.startDistance;u(Math.max(Ov,Math.min(d,w.current.startZoom*te)));return}if(C&&b.current&&I.touches.length===1){const Y=I.touches[0],Z=Y.clientX-b.current.startClientX,J=Y.clientY-b.current.startClientY;g({x:b.current.startPanX+Z,y:b.current.startPanY+J})}},[d,C]),H=T.useCallback(()=>{w.current=null,b.current=null},[]),z=T.useCallback(I=>{C&&(b.current={startClientX:I.clientX,startClientY:I.clientY,startPanX:h.x,startPanY:h.y})},[C,h.x,h.y]),A=T.useCallback(I=>{if(!b.current||I.buttons!==1)return;const Y=I.clientX-b.current.startClientX,Z=I.clientY-b.current.startClientY;g({x:b.current.startPanX+Y,y:b.current.startPanY+Z})},[]),q=T.useCallback(()=>{b.current=null},[]),F=I=>I.stopPropagation();return e.jsxs("div",{className:"relative w-full",onClick:F,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-center gap-1",children:[e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(Y=>Math.max(Ov,Y-$8)),g(Y=>({x:Y.x*.85,y:Y.y*.85}))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom out",disabled:l<=Ov,children:e.jsx(X.ZoomOut,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-[3.25rem] text-center text-xs font-medium tabular-nums text-white",children:[R,"%"]}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(Y=>Math.min(d,Y+$8))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom in",disabled:l>=d,children:e.jsx(X.ZoomIn,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),v()},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Reset zoom",disabled:l===Ov,children:e.jsx(X.Maximize2,{className:"h-4 w-4"})})]}),e.jsx("div",{ref:x,className:"relative flex items-center justify-center overflow-hidden rounded-lg",style:{minHeight:240,touchAction:C?"none":"pan-y"},onWheel:M,onPointerDown:z,onPointerMove:A,onPointerUp:q,onPointerLeave:q,onPointerCancel:q,onTouchStart:P,onTouchMove:$,onTouchEnd:H,onTouchCancel:H,children:e.jsx("img",{ref:y,src:o,alt:"",draggable:!1,referrerPolicy:"no-referrer",className:"max-h-[80vh] max-w-full select-none object-contain",style:{transform:`translate3d(${h.x}px, ${h.y}px, 0) scale(${l})`,transformOrigin:"center center",transition:b.current||w.current?"none":"transform 120ms ease-out",cursor:C?b.current?"grabbing":"grab":"zoom-in"},onDoubleClick:E,onLoad:()=>requestAnimationFrame(N)})})]})},VP=({url:a,onOpen:o})=>{const l=Pj(a);return l===null?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)]",children:e.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):l==="video"?e.jsxs("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-black","aria-label":"Play video",children:[e.jsx("video",{src:a,preload:"metadata",muted:!0,playsInline:!0,className:"h-full w-full object-cover opacity-80"}),e.jsx("span",{className:"pointer-events-none absolute flex h-12 w-12 items-center justify-center rounded-full bg-black/70 text-white",children:e.jsx(X.Play,{className:"h-6 w-6"})})]}):e.jsx("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:e.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})})},FP=({url:a})=>{const o=Pj(a);return o==="video"?e.jsx("video",{src:a,controls:!0,autoPlay:!0,playsInline:!0,className:"max-h-[80vh] max-w-full"}):o==="image"||o===null?e.jsx(xC,{src:a}):e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open in new tab"})},IP=({attachment:a,onClose:o,index:l,total:u,onPrev:d,onNext:f})=>{const h=typeof u=="number"&&u>1&&!!d&&!!f;T.useEffect(()=>{const b=v=>{v.key==="Escape"&&o(),v.key==="ArrowLeft"&&d&&d(),v.key==="ArrowRight"&&f&&f()};window.addEventListener("keydown",b);const w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",b),document.body.style.overflow=w}},[o,d,f]);const g=b=>b.stopPropagation(),x=b=>{b.stopPropagation(),o()},y=a.kind==="audio"||a.kind==="3speak-audio"||a.kind==="spotify";return e.jsxs("div",{className:"fixed inset-0 z-[2000] flex flex-col bg-black/85 sm:items-center sm:justify-center sm:p-6",role:"dialog","aria-modal":"true",onClick:x,children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 bg-black/40 px-4 py-3 pt-[calc(env(safe-area-inset-top,0px)+1rem)] sm:hidden",onClick:g,children:[e.jsx("span",{className:"truncate text-sm font-medium text-white/80",children:H8(a)}),h&&e.jsxs("span",{className:"shrink-0 text-xs text-white/60 tabular-nums",children:[(l??0)+1," / ",u]})]}),e.jsx("button",{type:"button",onClick:x,className:"fixed right-3 top-[calc(env(safe-area-inset-top,0px)+1rem)] z-[2010] flex h-11 w-11 items-center justify-center rounded-full bg-black/80 text-white shadow-lg ring-1 ring-white/30 transition hover:bg-black sm:hidden","aria-label":"Close",children:e.jsx(X.X,{className:"h-5 w-5"})}),e.jsxs("div",{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-[var(--hrk-bg-surface-sunken)] shadow-2xl sm:flex-initial sm:overflow-visible sm:rounded-2xl sm:border sm:border-[var(--hrk-border-default)] ${y?"sm:max-w-md":"sm:max-w-3xl"} sm:w-full`,onClick:g,children:[e.jsxs("div",{className:"hidden shrink-0 items-center justify-between border-b border-[var(--hrk-border-default)]/60 px-4 py-2.5 sm:flex",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-white/70",children:[e.jsx("span",{children:H8(a)}),h&&e.jsxs("span",{className:"text-xs text-white/50 tabular-nums",children:[(l??0)+1," / ",u]})]}),e.jsx("button",{type:"button",onClick:x,className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20","aria-label":"Close",children:e.jsx(X.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center p-3 sm:p-4",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d?.()},className:"absolute left-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Previous media",children:e.jsx(X.ChevronLeft,{className:"h-5 w-5"})}),e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),f?.()},className:"absolute right-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Next media",children:e.jsx(X.ChevronRight,{className:"h-5 w-5"})})]}),a.kind==="image"&&e.jsx(xC,{src:a.url}),a.kind==="ipfs"&&e.jsx(FP,{url:a.url}),a.kind==="youtube"&&e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:e.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${a.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),e.jsxs("a",{href:`https://www.youtube.com/watch?v=${a.id}`,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-white/10 px-4 py-2.5 text-sm font-medium text-white/90 transition hover:bg-white/20",children:[e.jsx(X.Play,{className:"h-4 w-4 fill-current"}),"Watch on YouTube"]})]}),a.kind==="twitter"&&e.jsx("div",{className:"w-full",children:e.jsx(bC,{id:a.id})}),a.kind==="threespeak"&&(()=>{const b=gC(a.url);return b?e.jsx("div",{className:"w-full",children:e.jsx($P,{author:b.author,permlink:b.permlink})}):e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})(),a.kind==="audio"&&e.jsxs("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21] p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[var(--hrk-text-tertiary)]",children:[e.jsx(X.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),e.jsx("span",{className:"truncate",children:decodeURIComponent(a.url.split("/").pop()?.split("?")[0]??"Audio")})]}),e.jsx("audio",{src:a.url,controls:!0,preload:"metadata",autoPlay:!0,className:"h-10 w-full"})]}),a.kind==="3speak-audio"&&e.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:e.jsx("iframe",{src:a.url,title:"3Speak audio",className:"h-24 w-full border-0",allow:"autoplay"})}),a.kind==="spotify"&&(()=>{const b=a.url.replace("open.spotify.com/","open.spotify.com/embed/");return e.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:e.jsx("iframe",{src:b,title:"Spotify Player",className:"h-80 w-full border-0",allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy"})})})(),a.kind==="odysee"&&(()=>{const b=f3(a.url);return b?e.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:e.jsx("iframe",{src:b,title:"Odysee Video",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}):null})()]})]})]})},vC=({attachments:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null),[f,h]=T.useState(0),[g,x]=T.useState(new Set),[y,b]=T.useState(!1),w=T.useRef(null);if(T.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),a.length===0)return null;const v=Math.min(o,a.length-1),N=a[v],C=()=>{b(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>b(!1),1200)},R=()=>{w.current&&(clearTimeout(w.current),w.current=null),b(!1)},M=()=>{C(),l(q=>(q+1)%a.length)},E=()=>{C(),l(q=>(q-1+a.length)%a.length)},P=(q,F)=>{q.stopPropagation();const I=a.indexOf(F);h(I>=0?I:0),d(F)},$=a.filter(q=>q.kind==="image"||q.kind==="ipfs"),H=()=>{$.length!==0&&h(q=>{const I=(Math.max(0,$.indexOf(a[q]))-1+$.length)%$.length,Y=$[I];return d(Y),a.indexOf(Y)})},z=()=>{$.length!==0&&h(q=>{const I=(Math.max(0,$.indexOf(a[q]))+1)%$.length,Y=$[I];return d(Y),a.indexOf(Y)})},A=()=>{if(N.kind==="ipfs")return e.jsx(VP,{url:N.url,onOpen:q=>P(q,N)});if(N.kind==="image")return g.has(v)?e.jsx("button",{type:"button",onClick:F=>F.stopPropagation(),className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-app)] text-[var(--hrk-text-tertiary)]",children:e.jsx(X.ImageOff,{className:"h-6 w-6"})}):e.jsx("button",{type:"button",onClick:F=>P(F,N),className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:e.jsx("img",{ref:F=>{F&&F.complete&&R()},src:mC(N.url),alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain",onLoad:R,onError:()=>{R(),x(F=>new Set(F).add(v))}},v)});if(N.kind==="youtube")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:q=>q.stopPropagation(),children:e.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${N.id}?rel=0&playsinline=1`,title:"YouTube",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})});if(N.kind==="threespeak"){const q=gC(N.url);return e.jsx("div",{className:"three-speak-snap-strip flex h-full w-full items-center justify-center overflow-hidden bg-black",onClick:F=>F.stopPropagation(),children:q?e.jsx(_m,{author:q.author,permlink:q.permlink,hideThumbnail:!0}):e.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on 3Speak"})})}if(N.kind==="twitter")return e.jsx("div",{className:"flex h-full w-full items-center justify-center p-2",onClick:q=>q.stopPropagation(),children:e.jsx(bC,{id:N.id})});if(N.kind==="audio")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:q=>q.stopPropagation(),children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-[var(--hrk-text-tertiary)]",children:[e.jsx(X.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),e.jsx("span",{className:"truncate",children:decodeURIComponent(N.url.split("/").pop()?.split("?")[0]??"Audio")})]}),e.jsx("audio",{src:N.url,controls:!0,preload:"metadata",className:"h-9 w-full"})]})});if(N.kind==="3speak-audio")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:q=>q.stopPropagation(),children:e.jsx("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b]",children:e.jsx("iframe",{src:N.url,title:"3Speak audio player",className:"h-24 w-full border-0"})})});if(N.kind==="spotify"){const q=N.url.replace("open.spotify.com/","open.spotify.com/embed/");return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:F=>F.stopPropagation(),children:e.jsx("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b]",children:e.jsx("iframe",{src:q,title:"Spotify Player",className:"h-56 w-full border-0 rounded-lg",allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy"})})})}if(N.kind==="odysee"){const q=f3(N.url);return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:F=>F.stopPropagation(),children:q?e.jsx("iframe",{src:q,title:"Odysee Video",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):e.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on Odysee"})})}return null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-72 w-full items-center justify-center overflow-hidden rounded-xl bg-black my-2",children:[A(),y&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/40",children:e.jsx(X.Loader2,{className:"h-7 w-7 animate-spin text-white"})}),a.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),E()},className:"absolute left-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Previous",children:e.jsx(X.ChevronLeft,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),M()},className:"absolute right-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Next",children:e.jsx(X.ChevronRight,{className:"h-4 w-4"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 z-30 rounded-full bg-black/60 px-2 py-0.5 text-[10px] text-white",children:[v+1," / ",a.length]})]})]}),u&&e.jsx(IP,{attachment:u,index:Math.max(0,$.indexOf(u)),total:$.length,onPrev:H,onNext:z,onClose:()=>d(null)})]})};function q8(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}function GP(a,o){if(o){const h=(typeof o=="string"?(()=>{try{return JSON.parse(o)}catch{return{}}})():o).image;if(Array.isArray(h)&&typeof h[0]=="string")return h[0]}const l=a.match(/!\[[^\]]*\]\(([^)\s]+)\)/);if(l)return l[1];const u=a.match(/<img[^>]+src=["']([^"']+)["']/i);if(u)return u[1];const d=a.match(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/i);return d?d[0]:null}function ZP(a){return a.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/<img[^>]+>/gi,"").replace(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/gi,"").replace(/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/\d+/gi,"").replace(/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=[^&\s]+|https?:\/\/youtu\.be\/\S+|https?:\/\/(?:www\.)?youtube\.com\/shorts\/\S+/gi,"").replace(/https?:\/\/(?:play\.)?3speak\.tv\/\S+/gi,"").replace(/https?:\/\/audio\.3speak\.tv\/play\?\S+/gi,"").replace(/https?:\/\/\S+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,"").replace(/https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi,"").replace(/<[^>]+>/g,"").replace(/[*_~`>#-]+/g," ").replace(/\s+/g," ").trim()}const yC=({author:a,permlink:o,observer:l,onPostClick:u,onUserClick:d,onPreviewVisibilityChange:f,showTopLevelPostPreview:h=!1})=>{const[g,x]=T.useState(null),[y,b]=T.useState(!0),[w,v]=T.useState(!1),[N,C]=T.useState(!1),[R,M]=T.useState(null);T.useEffect(()=>{let A=!1;return b(!0),v(!1),x(null),C(!1),M(null),f?.(!1),Gn.getPostContent(a,o,l??"").then(q=>{if(A)return;if(!q||!q.author){v(!0),b(!1),f?.(!1);return}const F=q,I=CP(F)===0;if(I&&!h){C(!0),b(!1),f?.(!1);return}x(F),M(I?"post":"resnap"),b(!1),f?.(!0)}).catch(()=>{A||(v(!0),b(!1),f?.(!1))}),()=>{A=!0}},[a,o,l,f,h]);const P=T.useMemo(()=>g?pC(g):null,[g])?.attachments??[],$=T.useMemo(()=>g?GP(g.body??"",g.json_metadata):null,[g]),H=T.useMemo(()=>g?ZP(g.body??"").slice(0,280):"",[g]),z=A=>{A.stopPropagation(),g?u?.(g.author,g.permlink):u?.(a,o)};if(N)return null;if(!y&&!w&&g&&R==="post"){const A=g.title||`@${g.author}/${g.permlink}`;return e.jsx("div",{className:"w-full cursor-pointer overflow-hidden rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface)] transition hover:border-[var(--hrk-brand)]/50 p-2.5",onClick:z,children:e.jsxs("div",{className:"flex items-center gap-3",children:[$&&e.jsx("img",{src:$,alt:"",loading:"lazy",className:"h-16 w-16 shrink-0 rounded-md object-cover",onError:q=>{q.target.style.display="none"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"line-clamp-2 break-words text-sm font-semibold leading-snug text-[var(--hrk-text-primary)]",children:A}),e.jsx("div",{className:"mt-1 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--hrk-text-tertiary)]",children:[e.jsxs("button",{type:"button",onClick:q=>{q.stopPropagation(),d?.(g.author)},className:"flex items-center gap-1 hover:text-[var(--hrk-brand)] font-medium",children:[e.jsx("img",{src:`https://images.hive.blog/u/${g.author}/avatar`,alt:"",className:"h-4.5 w-4.5 shrink-0 rounded-full object-cover",onError:q=>{q.target.src=`https://ui-avatars.com/api/?name=${g.author}&background=random&size=18`}}),e.jsxs("span",{className:"truncate",children:["@",g.author]})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"shrink-0",children:q8(g.created)})]})})]})]})})}return e.jsx("div",{className:"@container w-full cursor-pointer overflow-hidden rounded-lg border border-emerald-500/30 bg-[var(--hrk-bg-surface-sunken)] transition hover:border-emerald-500/60",onClick:z,children:y?e.jsxs("div",{className:"space-y-2 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)]"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-[var(--hrk-bg-hover)]"}),e.jsx("div",{className:"h-2 w-16 rounded bg-[var(--hrk-bg-hover)]"})]})]}),e.jsx("div",{className:"h-32 w-full rounded-md bg-[var(--hrk-bg-hover)]"}),e.jsx("div",{className:"h-3 w-3/4 rounded bg-[var(--hrk-bg-hover)]"})]}):w||!g?e.jsx("div",{className:"p-3 text-xs text-[var(--hrk-text-tertiary)]",children:"Original snap unavailable."}):e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"mb-2 flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),d?.(g.author)},className:"shrink-0",children:e.jsx("img",{src:`https://images.hive.blog/u/${g.author}/avatar`,alt:g.author,className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)] object-cover",onError:A=>{A.target.src=`https://ui-avatars.com/api/?name=${g.author}&background=random&size=28`}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("button",{type:"button",onClick:A=>{A.stopPropagation(),d?.(g.author)},className:"block truncate text-sm font-semibold text-[var(--hrk-text-primary)] hover:text-[var(--hrk-brand)]",children:["@",g.author]}),e.jsx("span",{className:"text-[11px] text-[var(--hrk-brand)]",children:q8(g.created)})]})]}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-md bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300",children:[e.jsx(X.Repeat,{className:"h-3 w-3"}),"Re-snap"]})]}),P.length>0?e.jsx(vC,{attachments:P}):$?e.jsx("img",{src:$,alt:"",loading:"lazy",className:"mb-2 max-h-72 w-full rounded-md object-cover",onError:A=>{A.target.style.display="none"}}):null,H&&e.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:H})]})})};function YP(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}const XP=({segments:a,onUserClick:o,onTagClick:l,getUserUrl:u,getTagUrl:d})=>{const f=[];return a.forEach((h,g)=>{h.kind==="text"?f.push(e.jsx("span",{children:h.text},g)):h.kind==="mention"?f.push(e.jsxs(ai,{href:u?.(h.username),onActivate:()=>o?.(h.username),className:"text-[var(--hrk-brand)] hover:underline",children:["@",h.username]},g)):h.kind==="hashtag"?f.push(e.jsxs(ai,{href:d?.(h.tag),onActivate:()=>l?.(h.tag),className:"text-[var(--hrk-brand)] hover:underline",children:["#",h.tag]},g)):f.push(e.jsx("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"break-all text-[var(--hrk-brand)] underline hover:text-[var(--hrk-brand-active)]",children:h.url},g))}),e.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:f})},wC=({post:a,currentUser:o,onUpvote:l,onSubmitComment:u,onClickCommentUpvote:d,onReblog:f,isPostReblogged:h,onCheckReblogged:g,onReSnap:x,onTip:y,onSharePost:b,onCommentClick:w,onClickCommentIcon:v,onClickCommentCount:N,onReportPost:C,onToggleBookmark:R,isPostBookmarked:M,onDeletePost:E,onEditSnap:P,onVotePoll:$,onUserClick:H,onPostClick:z,onTagClick:A,getPostUrl:q,getUserUrl:F,getTagUrl:I,getCommunityUrl:Y,ecencyToken:Z,threeSpeakApiKey:J,giphyApiKey:te,templateToken:de,templateApiBaseUrl:fe,defaultVotePercent:W,voteWeightStep:Q,allowLandscapeVideos:se,awaitingWalletApproval:xe,defaultReward:be,renderHeaderActions:Oe,actionsAsMenu:Se,isCurator:me,onCurationRequest:ie,onFetchCurationStatus:ye})=>{const Ee=T.useMemo(()=>fC(Hk(a.body??"")),[a.body]),Ie=Ee?`${Ee.author}/${Ee.permlink}`:null,[ge,rt]=T.useState(null),Le=!!Ie&&ge===Ie,ue=T.useMemo(()=>Le?TP(a.body??"",Ee):a.body??"",[a.body,Ee,Le]),He=T.useMemo(()=>pC({...a,body:ue}),[a,ue]),ve=T.useCallback(je=>{rt(Ft=>je?Ie:Ft===Ie?null:Ft)},[Ie]),We=T.useMemo(()=>UP(a),[a.json_metadata]),Fe=T.useMemo(()=>HP(a),[a.json_metadata]);T.useEffect(()=>{},[a.author,a.permlink]);const Ye=T.useMemo(()=>{try{return Am({baseUrl:"https://peakd.com/",ipfsGateway:"https://ipfs.3speak.tv",assetsWidth:640,assetsHeight:480,usertagUrlFn:je=>`https://peakd.com/@${je}`,hashtagUrlFn:je=>`https://peakd.com/created/${je}`,convertHiveUrls:!0})}catch{return null}},[]),mt=T.useMemo(()=>{const je=ue;if(!je||!Ye)return"";let Ft=je;if(Ft=Hk(Ft),Ft=Ft.replace(/\r\n/g,`
|
|
1168
|
+
`).trim()}function CP(a){const o=a.level??a.depth;if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const l=Number.parseInt(o,10);if(Number.isFinite(l))return l}return a.parent_author?1:0}const Eh=/https?:\/\/[^\s"'<>)]+\/ipfs\/[a-zA-Z0-9]+(?:\/[^\s"'<>)]*)?/gi,Fv=new Map,tk=new Map;function DP(a){const o=Fv.get(a);if(o)return Promise.resolve(o);const l=tk.get(a);if(l)return l;const u=fetch(a,{method:"HEAD"}).then(d=>{const f=(d.headers.get("content-type")??"").toLowerCase(),h=f.startsWith("image/")?"image":f.startsWith("video/")?"video":"unknown";return Fv.set(a,h),h}).catch(()=>{const d="unknown";return Fv.set(a,d),d}).finally(()=>{tk.delete(a)});return tk.set(a,u),u}function Pj(a){const[o,l]=T.useState(()=>Fv.get(a)??null);return T.useEffect(()=>{let u=!1;const d=Fv.get(a);if(d){l(d);return}return l(null),DP(a).then(f=>{u||l(f)}),()=>{u=!0}},[a]),o}const MP=({url:a,variant:o="full",onTileClick:l,className:u})=>{const d=Pj(a);return d===null?e.jsx("div",{className:`flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Resolving IPFS media",children:e.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):d==="image"?o==="tile"?e.jsx("button",{type:"button",onClick:l,className:`relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Open image preview",children:e.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})}):e.jsx("img",{src:a,alt:"",className:`max-h-full max-w-full object-contain ${u??""}`}):d==="video"?e.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",className:`max-h-full max-w-full ${u??""}`}):e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-[var(--hrk-brand)] underline ${u??""}`,children:a})},Ok=/https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi,Ah=/https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^\s"'<>)]+/gi,Rk=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi,vm=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)(?:[&?][^\s"')\]]*)?|https?:\/\/youtu\.be\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?|https?:\/\/(?:www\.)?youtube\.com\/embed\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?/gi,Lk=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,zk=/https?:\/\/[^\s"'<>)]+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,Pk=/https?:\/\/audio\.3speak\.tv\/play\?[^\s"'<>)]+/gi,Bk=/!\[[^\]]*\]\(([^\s)]+)\)/g,Uk=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,hC=/https?:\/\/[^\s"'<>)]+?\.(?:jpe?g|png|gif|webp|avif|bmp|svg|heic|heif)(?:\?[^\s"'<>)]*)?/gi,OP=/https?:\/\/[^\s)<>\]]+/g,RP=/@([a-z][a-z0-9.-]{1,15}[a-z0-9])/g,LP=/(?:^|\s)#([a-zA-Z][\w-]{0,31})/g;function kh(a){return Array.from(new Set(a))}function zP(a){return a.trim().replace(/[)\],.;:>\s"'<]+$/,"").replace(/^(https?):\/(?!\/)/,"$1://")}function PP(a){const o=new Set,l=[];for(const u of a){if(typeof u!="string")continue;const d=zP(u);if(!d||!/^https?:\/\//.test(d))continue;let f=d;try{f=decodeURIComponent(d)}catch{}o.has(f)||(o.add(f),l.push(d))}return l}function mC(a){if(!a)return a;const o=a.trim(),l=/\.(heic|heif)(?:\?[^\s"'<>)]*)?$/i.test(o),u=/^https:\/\/images\.ecency\.com\/(?:\d+x\d+|p|0x0)\//i.test(o);return l?u?o:`https://images.ecency.com/0x0/${o}`:o}function Bj(a){if(!a)return{};if(typeof a=="string")try{return JSON.parse(a)}catch{return{}}return typeof a=="object"?a:{}}const BP=new Set(["hsnaps","hreplier","hivesuite"]);function UP(a){const o=Bj(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).some(u=>typeof u=="string"&&BP.has(u.toLowerCase()))}function HP(a){const o=Bj(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).filter(u=>typeof u=="string"&&u.length>0)}function Hk(a){return a.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\][^<]*<\/sub>\s*$/,"").replace(/\s*(?:<br\s*\/?>)?\s*\[via Apps from\]\([^)]*\)\s*$/,"").replace(/\s*(?:<br\s*\/?>)?\s*via Apps from\s+https?:\/\/\S+\s*$/,"")}function pC(a){const o=Hk(a.body??""),l=[];let u;for(;u=Bk.exec(o);)l.push(u[1]);for(;u=Uk.exec(o);)l.push(u[1]);for(;u=hC.exec(o);)l.push(u[0]);const d=[],f=new RegExp(Eh.source,Eh.flags);for(;u=f.exec(o);)d.push(u[0]);const h=[];for(;u=vm.exec(o);)h.push(u[1]||u[2]||u[3]||u[4]);const g=[];for(;u=Lk.exec(o);)g.push(u[0]);const x=[];for(;u=Pk.exec(o);)x.push(u[0]);const y=[];for(;u=zk.exec(o);)x.includes(u[0])||y.push(u[0]);const b=[];for(;u=Rk.exec(o);)b.push(u[1]);const w=[];for(;u=Ok.exec(o);)w.push(u[0]);const v=[],N=new Set,C=/<iframe\b[^>]*\bsrc=["'](https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^"']+)["'][^>]*>/gi;for(;u=C.exec(o);){const I=u[1];N.has(I)||(N.add(I),v.push(I))}const R=new RegExp(Ah.source,Ah.flags);for(;u=R.exec(o);){const I=u[0];N.has(I)||(N.add(I),v.push(I))}const M=[...PP(l).map(I=>({kind:"image",url:I})),...kh(d).map(I=>({kind:"ipfs",url:I})),...kh(h).map(I=>({kind:"youtube",id:I})),...kh(g).map(I=>({kind:"threespeak",url:I})),...kh(b).map(I=>({kind:"twitter",id:I})),...kh(x).map(I=>({kind:"3speak-audio",url:I})),...kh(y).map(I=>({kind:"audio",url:I})),...kh(w).map(I=>({kind:"spotify",url:I})),...kh(v).map(I=>({kind:"odysee",url:I}))];let E=o;E=E.replace(Bk,""),E=E.replace(Uk,""),E=E.replace(Eh,""),E=E.replace(vm,""),E=E.replace(Lk,""),E=E.replace(Pk,""),E=E.replace(zk,""),E=E.replace(Rk,""),E=E.replace(Ok,""),E=E.replace(/<iframe\b[^>]*\bsrc=["'][^"']*(?:odysee\.com|lbry\.tv)[^"']*["'][^>]*>(?:\s*<\/iframe>)?/gi,""),E=E.replace(new RegExp(Ah.source,Ah.flags),""),E=E.replace(/<[^>]+>/g,""),E=E.replace(/\[([^\]]+)\]\(([^\s)]+)\)/g,"$1 $2"),E=E.replace(/[*_~`>#-]+/g," "),E=E.replace(/\s+/g," ").trim();const P=[];let $=0;const H=[];let z;const A=new RegExp(OP.source,"g");for(;(z=A.exec(E))!==null;)H.push({start:z.index,end:z.index+z[0].length,node:{kind:"link",url:z[0]}});const q=new RegExp(RP.source,"g");for(;(z=q.exec(E))!==null;)H.some(I=>z.index>=I.start&&z.index<I.end)||H.push({start:z.index,end:z.index+z[0].length,node:{kind:"mention",username:z[1]}});const F=new RegExp(LP.source,"g");for(;(z=F.exec(E))!==null;){const I=z.index+(z[0].startsWith(" ")?1:0);H.some(Y=>I>=Y.start&&I<Y.end)||H.push({start:I,end:I+(z[0].length-(z[0].startsWith(" ")?1:0)),node:{kind:"hashtag",tag:z[1]}})}H.sort((I,Y)=>I.start-Y.start);for(const I of H)$<I.start&&P.push({kind:"text",text:E.slice($,I.start)}),P.push(I.node),$=I.end;return $<E.length&&P.push({kind:"text",text:E.slice($)}),P.length===0&&E&&P.push({kind:"text",text:E}),{segments:P,attachments:M}}function gC(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const $P=({author:a,permlink:o})=>e.jsx("div",{className:"three-speak-embed my-3 hive-post-body",style:{margin:"0.75rem auto"},children:e.jsx(_m,{author:a,permlink:o})}),H8=a=>a.kind==="image"?a.url.toLowerCase().includes(".gif")?"GIF":"Image":a.kind==="youtube"?"YouTube":a.kind==="threespeak"?"3Speak":a.kind==="twitter"?"Tweet":a.kind==="3speak-audio"?"3Speak audio":a.kind==="spotify"?"Spotify":a.kind==="odysee"?"Odysee":"Audio";function f3(a){try{const o=new URL(a),l=o.hostname.replace(/^www\./,"");if(l!=="odysee.com"&&l!=="lbry.tv")return null;const u=o.pathname.startsWith("/$/embed/")?o.pathname:`/$/embed${o.pathname}`,d=new URLSearchParams(o.search);return d.set("disable_comments","1"),`https://odysee.com${u}?${d.toString()}`}catch{return null}}const bC=({id:a})=>{const[o,l]=T.useState(null);T.useEffect(()=>{const d=f=>{try{const h=typeof f.data=="string"?JSON.parse(f.data):f.data;if(!h||typeof h!="object")return;let g;if(h.method==="resize"&&Array.isArray(h.params))for(const x of h.params)typeof x=="number"&&x>0&&(g=x),x&&typeof x=="object"&&typeof x.height=="number"&&(g=x.height);h["twttr.private.resize"]?.height&&(g=h["twttr.private.resize"].height),!g&&typeof h.height=="number"&&(g=h.height),!g&&h.msg_type==="resize"&&h.msg_data?.height&&(g=h.msg_data.height),g&&g>50&&l(Math.ceil(g))}catch{}};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const u=typeof window<"u"?window.location.origin:"";return e.jsx("div",{className:"twitter-embed-wrapper w-full overflow-hidden rounded-lg bg-black/60",style:o?{maxHeight:"80vh",overflowY:"auto"}:void 0,children:e.jsx("iframe",{src:`https://platform.twitter.com/embed/Tweet.html?id=${a}&theme=dark&dnt=true&origin=${encodeURIComponent(u)}`,title:`Tweet ${a}`,className:"twitter-embed-iframe w-full border-0 bg-black",scrolling:"yes",style:{height:o??"60vh"}})})},Ov=1,$8=.25,qP=.15,xC=({src:a})=>{const o=mC(a),[l,u]=T.useState(1),[d,f]=T.useState(3),[h,g]=T.useState({x:0,y:0}),x=T.useRef(null),y=T.useRef(null),b=T.useRef(null),w=T.useRef(null),v=T.useCallback(()=>{u(1),g({x:0,y:0})},[]);T.useEffect(()=>{v()},[a,v]);const N=T.useCallback(()=>{const I=y.current;if(!I)return;const Y=I.clientWidth||1,Z=I.clientHeight||1,J=Math.max(I.naturalWidth/Y,I.naturalHeight/Z);f(Math.max(1,Math.min(6,J||1)))},[]),C=l>1,R=Math.round(l*100),M=T.useCallback(I=>{I.preventDefault();const Y=x.current;if(!Y)return;const Z=Y.getBoundingClientRect(),J=I.clientX-(Z.left+Z.width/2),te=I.clientY-(Z.top+Z.height/2);u(de=>{const fe=I.deltaY<0?1:-1,W=Math.max(Ov,Math.min(d,de+fe*qP));return W===de?de:(g(Q=>{if(W===1)return{x:0,y:0};const se=W/de;return{x:J-(J-Q.x)*se,y:te-(te-Q.y)*se}}),W)})},[d]),E=T.useCallback(I=>{I.stopPropagation(),l===1?u(d):v()},[l,d,v]),P=T.useCallback(I=>{if(I.touches.length===2){const[Y,Z]=[I.touches[0],I.touches[1]];w.current={startDistance:Math.hypot(Y.clientX-Z.clientX,Y.clientY-Z.clientY),startZoom:l};return}if(C){const Y=I.touches[0];Y&&(b.current={startClientX:Y.clientX,startClientY:Y.clientY,startPanX:h.x,startPanY:h.y})}},[l,C,h.x,h.y]),$=T.useCallback(I=>{if(I.touches.length===2&&w.current){const[Y,Z]=[I.touches[0],I.touches[1]],te=Math.hypot(Y.clientX-Z.clientX,Y.clientY-Z.clientY)/w.current.startDistance;u(Math.max(Ov,Math.min(d,w.current.startZoom*te)));return}if(C&&b.current&&I.touches.length===1){const Y=I.touches[0],Z=Y.clientX-b.current.startClientX,J=Y.clientY-b.current.startClientY;g({x:b.current.startPanX+Z,y:b.current.startPanY+J})}},[d,C]),H=T.useCallback(()=>{w.current=null,b.current=null},[]),z=T.useCallback(I=>{C&&(b.current={startClientX:I.clientX,startClientY:I.clientY,startPanX:h.x,startPanY:h.y})},[C,h.x,h.y]),A=T.useCallback(I=>{if(!b.current||I.buttons!==1)return;const Y=I.clientX-b.current.startClientX,Z=I.clientY-b.current.startClientY;g({x:b.current.startPanX+Y,y:b.current.startPanY+Z})},[]),q=T.useCallback(()=>{b.current=null},[]),F=I=>I.stopPropagation();return e.jsxs("div",{className:"relative w-full",onClick:F,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-center gap-1",children:[e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(Y=>Math.max(Ov,Y-$8)),g(Y=>({x:Y.x*.85,y:Y.y*.85}))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom out",disabled:l<=Ov,children:e.jsx(X.ZoomOut,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-[3.25rem] text-center text-xs font-medium tabular-nums text-white",children:[R,"%"]}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(Y=>Math.min(d,Y+$8))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom in",disabled:l>=d,children:e.jsx(X.ZoomIn,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),v()},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Reset zoom",disabled:l===Ov,children:e.jsx(X.Maximize2,{className:"h-4 w-4"})})]}),e.jsx("div",{ref:x,className:"relative flex items-center justify-center overflow-hidden rounded-lg",style:{minHeight:240,touchAction:C?"none":"pan-y"},onWheel:M,onPointerDown:z,onPointerMove:A,onPointerUp:q,onPointerLeave:q,onPointerCancel:q,onTouchStart:P,onTouchMove:$,onTouchEnd:H,onTouchCancel:H,children:e.jsx("img",{ref:y,src:o,alt:"",draggable:!1,referrerPolicy:"no-referrer",className:"max-h-[80vh] max-w-full select-none object-contain",style:{transform:`translate3d(${h.x}px, ${h.y}px, 0) scale(${l})`,transformOrigin:"center center",transition:b.current||w.current?"none":"transform 120ms ease-out",cursor:C?b.current?"grabbing":"grab":"zoom-in"},onDoubleClick:E,onLoad:()=>requestAnimationFrame(N)})})]})},VP=({url:a,onOpen:o})=>{const l=Pj(a);return l===null?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)]",children:e.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):l==="video"?e.jsxs("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-black","aria-label":"Play video",children:[e.jsx("video",{src:a,preload:"metadata",muted:!0,playsInline:!0,className:"h-full w-full object-cover opacity-80"}),e.jsx("span",{className:"pointer-events-none absolute flex h-12 w-12 items-center justify-center rounded-full bg-black/70 text-white",children:e.jsx(X.Play,{className:"h-6 w-6"})})]}):e.jsx("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:e.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})})},FP=({url:a})=>{const o=Pj(a);return o==="video"?e.jsx("video",{src:a,controls:!0,autoPlay:!0,playsInline:!0,className:"max-h-[80vh] max-w-full"}):o==="image"||o===null?e.jsx(xC,{src:a}):e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open in new tab"})},IP=({attachment:a,onClose:o,index:l,total:u,onPrev:d,onNext:f})=>{const h=typeof u=="number"&&u>1&&!!d&&!!f;T.useEffect(()=>{const b=v=>{v.key==="Escape"&&o(),v.key==="ArrowLeft"&&d&&d(),v.key==="ArrowRight"&&f&&f()};window.addEventListener("keydown",b);const w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",b),document.body.style.overflow=w}},[o,d,f]);const g=b=>b.stopPropagation(),x=b=>{b.stopPropagation(),o()},y=a.kind==="audio"||a.kind==="3speak-audio"||a.kind==="spotify";return e.jsxs("div",{className:"fixed inset-0 z-[2000] flex flex-col bg-black/85 sm:items-center sm:justify-center sm:p-6",role:"dialog","aria-modal":"true",onClick:x,children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 bg-black/40 px-4 py-3 pt-[calc(env(safe-area-inset-top,0px)+1rem)] sm:hidden",onClick:g,children:[e.jsx("span",{className:"truncate text-sm font-medium text-white/80",children:H8(a)}),h&&e.jsxs("span",{className:"shrink-0 text-xs text-white/60 tabular-nums",children:[(l??0)+1," / ",u]})]}),e.jsx("button",{type:"button",onClick:x,className:"fixed right-3 top-[calc(env(safe-area-inset-top,0px)+1rem)] z-[2010] flex h-11 w-11 items-center justify-center rounded-full bg-black/80 text-white shadow-lg ring-1 ring-white/30 transition hover:bg-black sm:hidden","aria-label":"Close",children:e.jsx(X.X,{className:"h-5 w-5"})}),e.jsxs("div",{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-[var(--hrk-bg-surface-sunken)] shadow-2xl sm:flex-initial sm:overflow-visible sm:rounded-2xl sm:border sm:border-[var(--hrk-border-default)] ${y?"sm:max-w-md":"sm:max-w-3xl"} sm:w-full`,onClick:g,children:[e.jsxs("div",{className:"hidden shrink-0 items-center justify-between border-b border-[var(--hrk-border-default)]/60 px-4 py-2.5 sm:flex",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-white/70",children:[e.jsx("span",{children:H8(a)}),h&&e.jsxs("span",{className:"text-xs text-white/50 tabular-nums",children:[(l??0)+1," / ",u]})]}),e.jsx("button",{type:"button",onClick:x,className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20","aria-label":"Close",children:e.jsx(X.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center p-3 sm:p-4",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d?.()},className:"absolute left-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Previous media",children:e.jsx(X.ChevronLeft,{className:"h-5 w-5"})}),e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),f?.()},className:"absolute right-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Next media",children:e.jsx(X.ChevronRight,{className:"h-5 w-5"})})]}),a.kind==="image"&&e.jsx(xC,{src:a.url}),a.kind==="ipfs"&&e.jsx(FP,{url:a.url}),a.kind==="youtube"&&e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:e.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${a.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),e.jsxs("a",{href:`https://www.youtube.com/watch?v=${a.id}`,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-white/10 px-4 py-2.5 text-sm font-medium text-white/90 transition hover:bg-white/20",children:[e.jsx(X.Play,{className:"h-4 w-4 fill-current"}),"Watch on YouTube"]})]}),a.kind==="twitter"&&e.jsx("div",{className:"w-full",children:e.jsx(bC,{id:a.id})}),a.kind==="threespeak"&&(()=>{const b=gC(a.url);return b?e.jsx("div",{className:"w-full",children:e.jsx($P,{author:b.author,permlink:b.permlink})}):e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})(),a.kind==="audio"&&e.jsxs("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21] p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[var(--hrk-text-tertiary)]",children:[e.jsx(X.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),e.jsx("span",{className:"truncate",children:decodeURIComponent(a.url.split("/").pop()?.split("?")[0]??"Audio")})]}),e.jsx("audio",{src:a.url,controls:!0,preload:"metadata",autoPlay:!0,className:"h-10 w-full"})]}),a.kind==="3speak-audio"&&e.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:e.jsx("iframe",{src:a.url,title:"3Speak audio",className:"h-24 w-full border-0",allow:"autoplay"})}),a.kind==="spotify"&&(()=>{const b=a.url.replace("open.spotify.com/","open.spotify.com/embed/");return e.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:e.jsx("iframe",{src:b,title:"Spotify Player",className:"h-80 w-full border-0",allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy"})})})(),a.kind==="odysee"&&(()=>{const b=f3(a.url);return b?e.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:e.jsx("iframe",{src:b,title:"Odysee Video",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}):null})()]})]})]})},vC=({attachments:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null),[f,h]=T.useState(0),[g,x]=T.useState(new Set),[y,b]=T.useState(!1),w=T.useRef(null);if(T.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),a.length===0)return null;const v=Math.min(o,a.length-1),N=a[v],C=()=>{b(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>b(!1),1200)},R=()=>{w.current&&(clearTimeout(w.current),w.current=null),b(!1)},M=()=>{C(),l(q=>(q+1)%a.length)},E=()=>{C(),l(q=>(q-1+a.length)%a.length)},P=(q,F)=>{q.stopPropagation();const I=a.indexOf(F);h(I>=0?I:0),d(F)},$=a.filter(q=>q.kind==="image"||q.kind==="ipfs"),H=()=>{$.length!==0&&h(q=>{const I=(Math.max(0,$.indexOf(a[q]))-1+$.length)%$.length,Y=$[I];return d(Y),a.indexOf(Y)})},z=()=>{$.length!==0&&h(q=>{const I=(Math.max(0,$.indexOf(a[q]))+1)%$.length,Y=$[I];return d(Y),a.indexOf(Y)})},A=()=>{if(N.kind==="ipfs")return e.jsx(VP,{url:N.url,onOpen:q=>P(q,N)});if(N.kind==="image")return g.has(v)?e.jsx("button",{type:"button",onClick:F=>F.stopPropagation(),className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-app)] text-[var(--hrk-text-tertiary)]",children:e.jsx(X.ImageOff,{className:"h-6 w-6"})}):e.jsx("button",{type:"button",onClick:F=>P(F,N),className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:e.jsx("img",{ref:F=>{F&&F.complete&&R()},src:mC(N.url),alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain",onLoad:R,onError:()=>{R(),x(F=>new Set(F).add(v))}},v)});if(N.kind==="youtube")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:q=>q.stopPropagation(),children:e.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${N.id}?rel=0&playsinline=1`,title:"YouTube",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})});if(N.kind==="threespeak"){const q=gC(N.url);return e.jsx("div",{className:"three-speak-snap-strip flex h-full w-full items-center justify-center overflow-hidden bg-black",onClick:F=>F.stopPropagation(),children:q?e.jsx(_m,{author:q.author,permlink:q.permlink,hideThumbnail:!0}):e.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on 3Speak"})})}if(N.kind==="twitter")return e.jsx("div",{className:"flex h-full w-full items-center justify-center p-2",onClick:q=>q.stopPropagation(),children:e.jsx(bC,{id:N.id})});if(N.kind==="audio")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:q=>q.stopPropagation(),children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-[var(--hrk-text-tertiary)]",children:[e.jsx(X.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),e.jsx("span",{className:"truncate",children:decodeURIComponent(N.url.split("/").pop()?.split("?")[0]??"Audio")})]}),e.jsx("audio",{src:N.url,controls:!0,preload:"metadata",className:"h-9 w-full"})]})});if(N.kind==="3speak-audio")return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:q=>q.stopPropagation(),children:e.jsx("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b]",children:e.jsx("iframe",{src:N.url,title:"3Speak audio player",className:"h-24 w-full border-0"})})});if(N.kind==="spotify"){const q=N.url.replace("open.spotify.com/","open.spotify.com/embed/");return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#1a1d21] p-4",onClick:F=>F.stopPropagation(),children:e.jsx("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#15181b]",children:e.jsx("iframe",{src:q,title:"Spotify Player",className:"h-56 w-full border-0 rounded-lg",allow:"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture",loading:"lazy"})})})}if(N.kind==="odysee"){const q=f3(N.url);return e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:F=>F.stopPropagation(),children:q?e.jsx("iframe",{src:q,title:"Odysee Video",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):e.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on Odysee"})})}return null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-72 w-full items-center justify-center overflow-hidden rounded-xl bg-black my-2",children:[A(),y&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/40",children:e.jsx(X.Loader2,{className:"h-7 w-7 animate-spin text-white"})}),a.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),E()},className:"absolute left-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Previous",children:e.jsx(X.ChevronLeft,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),M()},className:"absolute right-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Next",children:e.jsx(X.ChevronRight,{className:"h-4 w-4"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 z-30 rounded-full bg-black/60 px-2 py-0.5 text-[10px] text-white",children:[v+1," / ",a.length]})]})]}),u&&e.jsx(IP,{attachment:u,index:Math.max(0,$.indexOf(u)),total:$.length,onPrev:H,onNext:z,onClose:()=>d(null)})]})};function q8(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}function GP(a,o){if(o){const h=(typeof o=="string"?(()=>{try{return JSON.parse(o)}catch{return{}}})():o).image;if(Array.isArray(h)&&typeof h[0]=="string")return h[0]}const l=a.match(/!\[[^\]]*\]\(([^)\s]+)\)/);if(l)return l[1];const u=a.match(/<img[^>]+src=["']([^"']+)["']/i);if(u)return u[1];const d=a.match(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/i);return d?d[0]:null}function ZP(a){return a.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/<img[^>]+>/gi,"").replace(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/gi,"").replace(/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/\d+/gi,"").replace(/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=[^&\s]+|https?:\/\/youtu\.be\/\S+|https?:\/\/(?:www\.)?youtube\.com\/shorts\/\S+/gi,"").replace(/https?:\/\/(?:play\.)?3speak\.tv\/\S+/gi,"").replace(/https?:\/\/audio\.3speak\.tv\/play\?\S+/gi,"").replace(/https?:\/\/\S+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,"").replace(/https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi,"").replace(/<[^>]+>/g,"").replace(/[*_~`>#-]+/g," ").replace(/\s+/g," ").trim()}const yC=({author:a,permlink:o,observer:l,onPostClick:u,onUserClick:d,onPreviewVisibilityChange:f,showTopLevelPostPreview:h=!1})=>{const[g,x]=T.useState(null),[y,b]=T.useState(!0),[w,v]=T.useState(!1),[N,C]=T.useState(!1),[R,M]=T.useState(null);T.useEffect(()=>{let A=!1;return b(!0),v(!1),x(null),C(!1),M(null),f?.(!1),Gn.getPostContent(a,o,l??"").then(q=>{if(A)return;if(!q||!q.author){v(!0),b(!1),f?.(!1);return}const F=q,I=CP(F)===0;if(I&&!h){C(!0),b(!1),f?.(!1);return}x(F),M(I?"post":"resnap"),b(!1),f?.(!0)}).catch(()=>{A||(v(!0),b(!1),f?.(!1))}),()=>{A=!0}},[a,o,l,f,h]);const P=T.useMemo(()=>g?pC(g):null,[g])?.attachments??[],$=T.useMemo(()=>g?GP(g.body??"",g.json_metadata):null,[g]),H=T.useMemo(()=>g?ZP(g.body??"").slice(0,280):"",[g]),z=A=>{A.stopPropagation(),g?u?.(g.author,g.permlink):u?.(a,o)};if(N)return null;if(!y&&!w&&g&&R==="post"){const A=g.title||`@${g.author}/${g.permlink}`;return e.jsx("div",{className:"w-full cursor-pointer overflow-hidden rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface)] transition hover:border-[var(--hrk-brand)]/50 p-2.5",onClick:z,children:e.jsxs("div",{className:"flex items-center gap-3",children:[$&&e.jsx("img",{src:$,alt:"",loading:"lazy",className:"h-16 w-16 shrink-0 rounded-md object-cover",onError:q=>{q.target.style.display="none"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"line-clamp-2 break-words text-sm font-semibold leading-snug text-[var(--hrk-text-primary)]",children:A}),e.jsx("div",{className:"mt-1 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--hrk-text-tertiary)]",children:[e.jsxs("button",{type:"button",onClick:q=>{q.stopPropagation(),d?.(g.author)},className:"flex items-center gap-1 hover:text-[var(--hrk-brand)] font-medium",children:[e.jsx("img",{src:`https://images.hive.blog/u/${g.author}/avatar`,alt:"",className:"h-4.5 w-4.5 shrink-0 rounded-full object-cover",onError:q=>{q.target.src=`https://ui-avatars.com/api/?name=${g.author}&background=random&size=18`}}),e.jsxs("span",{className:"truncate",children:["@",g.author]})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"shrink-0",children:q8(g.created)})]})})]})]})})}return e.jsx("div",{className:"@container w-full cursor-pointer overflow-hidden rounded-lg border border-emerald-500/30 bg-[var(--hrk-bg-surface-sunken)] transition hover:border-emerald-500/60",onClick:z,children:y?e.jsxs("div",{className:"space-y-2 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)]"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-[var(--hrk-bg-hover)]"}),e.jsx("div",{className:"h-2 w-16 rounded bg-[var(--hrk-bg-hover)]"})]})]}),e.jsx("div",{className:"h-32 w-full rounded-md bg-[var(--hrk-bg-hover)]"}),e.jsx("div",{className:"h-3 w-3/4 rounded bg-[var(--hrk-bg-hover)]"})]}):w||!g?e.jsx("div",{className:"p-3 text-xs text-[var(--hrk-text-tertiary)]",children:"Original snap unavailable."}):e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"mb-2 flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),d?.(g.author)},className:"shrink-0",children:e.jsx("img",{src:`https://images.hive.blog/u/${g.author}/avatar`,alt:g.author,className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)] object-cover",onError:A=>{A.target.src=`https://ui-avatars.com/api/?name=${g.author}&background=random&size=28`}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("button",{type:"button",onClick:A=>{A.stopPropagation(),d?.(g.author)},className:"block truncate text-sm font-semibold text-[var(--hrk-text-primary)] hover:text-[var(--hrk-brand)]",children:["@",g.author]}),e.jsx("span",{className:"text-[11px] text-[var(--hrk-brand)]",children:q8(g.created)})]})]}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-md bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300",children:[e.jsx(X.Repeat,{className:"h-3 w-3"}),"Re-snap"]})]}),P.length>0?e.jsx(vC,{attachments:P}):$?e.jsx("img",{src:$,alt:"",loading:"lazy",className:"mb-2 max-h-72 w-full rounded-md object-cover",onError:A=>{A.target.style.display="none"}}):null,H&&e.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:H})]})})};function YP(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}const XP=({segments:a,onUserClick:o,onTagClick:l,getUserUrl:u,getTagUrl:d})=>{const f=[];return a.forEach((h,g)=>{h.kind==="text"?f.push(e.jsx("span",{children:h.text},g)):h.kind==="mention"?f.push(e.jsxs(ai,{href:u?.(h.username),onActivate:()=>o?.(h.username),className:"text-[var(--hrk-brand)] hover:underline",children:["@",h.username]},g)):h.kind==="hashtag"?f.push(e.jsxs(ai,{href:d?.(h.tag),onActivate:()=>l?.(h.tag),className:"text-[var(--hrk-brand)] hover:underline",children:["#",h.tag]},g)):f.push(e.jsx("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"break-all text-[var(--hrk-brand)] underline hover:text-[var(--hrk-brand-active)]",children:h.url},g))}),e.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:f})},wC=({post:a,currentUser:o,onUpvote:l,onSubmitComment:u,onClickCommentUpvote:d,onReblog:f,isPostReblogged:h,onCheckReblogged:g,onReSnap:x,onTip:y,onSharePost:b,onCommentClick:w,onClickCommentIcon:v,onClickCommentCount:N,onReportPost:C,onToggleBookmark:R,isPostBookmarked:M,onDeletePost:E,onEditSnap:P,onVotePoll:$,onUserClick:H,onPostClick:z,onTagClick:A,getPostUrl:q,getUserUrl:F,getTagUrl:I,getCommunityUrl:Y,ecencyToken:Z,threeSpeakApiKey:J,giphyApiKey:te,templateToken:de,templateApiBaseUrl:fe,defaultVotePercent:W,voteWeightStep:Q,allowLandscapeVideos:se,awaitingWalletApproval:xe,defaultReward:be,renderHeaderActions:Oe,actionsAsMenu:Se,isCurator:me,onCurationRequest:ie,onFetchCurationStatus:ye})=>{const Ee=T.useMemo(()=>fC(Hk(a.body??"")),[a.body]),Ie=Ee?`${Ee.author}/${Ee.permlink}`:null,[ge,rt]=T.useState(null),Le=!!Ie&&ge===Ie,ue=T.useMemo(()=>Le?TP(a.body??"",Ee):a.body??"",[a.body,Ee,Le]),He=T.useMemo(()=>pC({...a,body:ue}),[a,ue]),ve=T.useCallback(je=>{rt(Ft=>je?Ie:Ft===Ie?null:Ft)},[Ie]),We=T.useMemo(()=>UP(a),[a.json_metadata]),Fe=T.useMemo(()=>HP(a),[a.json_metadata]);T.useEffect(()=>{},[a.author,a.permlink]);const Ye=T.useMemo(()=>{try{return Am({baseUrl:"https://peakd.com/",ipfsGateway:"https://ipfs.3speak.tv",assetsWidth:640,assetsHeight:480,usertagUrlFn:je=>`https://peakd.com/@${je}`,hashtagUrlFn:je=>`https://peakd.com/created/${je}`,convertHiveUrls:!0})}catch{return null}},[]),mt=T.useMemo(()=>{const je=ue;if(!je||!Ye)return"";let Ft=je;if(Ft=Hk(Ft),Ft=Ft.replace(/\r\n/g,`
|
|
1169
1169
|
`),Ft=Ft.replace(/<br\s*\/?>\s*\n?/gi,`
|
|
1170
1170
|
`),Ft=Ft.replace(/(?:^|\n)\s*(?:#[\p{L}\p{N}_-]+(?:\s*,?\s*)){1,}$/u,""),Ft=Ft.replace(/([^\n|])\n(\|)/g,`$1
|
|
1171
1171
|
|
package/dist/index.esm.js
CHANGED
|
@@ -41698,7 +41698,7 @@ const w$ = ({
|
|
|
41698
41698
|
children: r
|
|
41699
41699
|
}
|
|
41700
41700
|
);
|
|
41701
|
-
}, qN = /https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi, Jh = /https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^\s"'<>)]+/gi, VN = /https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi, Gm = /https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([
|
|
41701
|
+
}, qN = /https?:\/\/(?:open|play)\.spotify\.com\/(?:track|playlist|album|artist|episode|show)\/[a-zA-Z0-9]+(?:\?[^\s"'<>)]*)?/gi, Jh = /https?:\/\/(?:www\.)?(?:odysee\.com|lbry\.tv)\/[^\s"'<>)]+/gi, VN = /https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi, Gm = /https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)(?:[&?][^\s"')\]]*)?|https?:\/\/youtu\.be\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?|https?:\/\/(?:www\.)?youtube\.com\/embed\/([a-zA-Z0-9_-]+)(?:\?[^\s"')\]]*)?/gi, IN = /https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi, FN = /https?:\/\/[^\s"'<>)]+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi, GN = /https?:\/\/audio\.3speak\.tv\/play\?[^\s"'<>)]+/gi, ZN = /!\[[^\]]*\]\(([^\s)]+)\)/g, YN = /<img[^>]+src=["']([^"']+)["'][^>]*>/gi, C9 = /https?:\/\/[^\s"'<>)]+?\.(?:jpe?g|png|gif|webp|avif|bmp|svg|heic|heif)(?:\?[^\s"'<>)]*)?/gi, _$ = /https?:\/\/[^\s)<>\]]+/g, k$ = /@([a-z][a-z0-9.-]{1,15}[a-z0-9])/g, N$ = /(?:^|\s)#([a-zA-Z][\w-]{0,31})/g;
|
|
41702
41702
|
function Ih(r) {
|
|
41703
41703
|
return Array.from(new Set(r));
|
|
41704
41704
|
}
|
|
@@ -41767,7 +41767,7 @@ function M9(r) {
|
|
|
41767
41767
|
const d = [], f = new RegExp(Wh.source, Wh.flags);
|
|
41768
41768
|
for (; u = f.exec(o); ) d.push(u[0]);
|
|
41769
41769
|
const h = [];
|
|
41770
|
-
for (; u = Gm.exec(o); ) h.push(u[1] || u[2] || u[3]);
|
|
41770
|
+
for (; u = Gm.exec(o); ) h.push(u[1] || u[2] || u[3] || u[4]);
|
|
41771
41771
|
const g = [];
|
|
41772
41772
|
for (; u = IN.exec(o); ) g.push(u[0]);
|
|
41773
41773
|
const y = [];
|