hive-react-kit 0.0.6 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +20 -0
  2. package/dist/components/ActivityHistory.d.ts +7 -0
  3. package/dist/components/ActivityList.d.ts +15 -0
  4. package/dist/components/FollowersList.d.ts +8 -0
  5. package/dist/components/FollowingList.d.ts +8 -0
  6. package/dist/components/ListOfWitnesses.d.ts +4 -0
  7. package/dist/components/PostFeedList.d.ts +17 -0
  8. package/dist/components/ProposalsList.d.ts +4 -0
  9. package/dist/components/TransactionHistory.d.ts +6 -0
  10. package/dist/components/UpvoteListModal.d.ts +11 -0
  11. package/dist/components/VoteSlider.d.ts +7 -0
  12. package/dist/components/WitnessFilters.d.ts +8 -0
  13. package/dist/components/comments/AddCommentInput.d.ts +10 -0
  14. package/dist/components/comments/CommentSearchBar.d.ts +8 -0
  15. package/dist/components/comments/CommentTile.d.ts +16 -0
  16. package/dist/components/comments/CommentsModal.d.ts +13 -0
  17. package/dist/components/comments/ReplyModal.d.ts +9 -0
  18. package/dist/components/community/CommunityDetails.d.ts +13 -0
  19. package/dist/components/index.d.ts +5 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.es.js +2554 -1694
  22. package/dist/index.umd.js +23 -23
  23. package/dist/services/activityListService.d.ts +79 -0
  24. package/dist/services/activityService.d.ts +104 -0
  25. package/dist/services/apiService.d.ts +2 -0
  26. package/dist/services/communityService.d.ts +5 -1
  27. package/dist/services/proposalService.d.ts +9 -0
  28. package/dist/services/transactionService.d.ts +69 -0
  29. package/dist/services/userService.d.ts +6 -1
  30. package/dist/services/witnessService.d.ts +61 -0
  31. package/dist/store/index.d.ts +2 -0
  32. package/dist/store/witnessStore.d.ts +31 -0
  33. package/dist/types/activity.d.ts +108 -0
  34. package/dist/types/activityList.d.ts +46 -0
  35. package/dist/types/comment.d.ts +7 -1
  36. package/dist/types/community.d.ts +79 -0
  37. package/dist/types/index.d.ts +3 -0
  38. package/dist/types/post.d.ts +53 -0
  39. package/dist/types/proposal.d.ts +35 -0
  40. package/dist/types/transaction.d.ts +90 -0
  41. package/dist/types/user.d.ts +91 -0
  42. package/dist/types/witness.d.ts +57 -0
  43. package/package.json +14 -6
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(_,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("lucide-react"),require("date-fns"),require("@hiveio/dhive"),require("hls.js"),require("zustand"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","date-fns","@hiveio/dhive","hls.js","zustand","react-router-dom"],i):(_=typeof globalThis<"u"?globalThis:_||self,i(_.HiveReactKit={},_.React,_.LucideReact,_.dateFns,_.Dhive,_.Hls,_.Zustand,_.ReactRouterDOM))})(this,function(_,i,b,ze,ar,ve,Wr,nr){"use strict";var Ht=Object.defineProperty;var Bt=(_,i,b)=>i in _?Ht(_,i,{enumerable:!0,configurable:!0,writable:!0,value:b}):_[i]=b;var Be=(_,i,b)=>Bt(_,typeof i!="symbol"?i+"":i,b);function or(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return s.default=r,Object.freeze(s)}const Oe=or(i),Hr=or(ar);var qe={exports:{}},Ee={};/**
1
+ (function(O,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("lucide-react"),require("date-fns"),require("@hiveio/dhive"),require("hls.js"),require("zustand"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","date-fns","@hiveio/dhive","hls.js","zustand","react-router-dom"],d):(O=typeof globalThis<"u"?globalThis:O||self,d(O.HiveReactKit={},O.React,O.LucideReact,O.dateFns,O.Dhive,O.Hls,O.Zustand,O.ReactRouterDOM))})(this,function(O,d,j,Ge,Ke,ke,lt,ct){"use strict";var Kr=Object.defineProperty;var Qr=(O,d,j)=>d in O?Kr(O,d,{enumerable:!0,configurable:!0,writable:!0,value:j}):O[d]=j;var Ye=(O,d,j)=>Qr(O,typeof d!="symbol"?d+"":d,j);function dt(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(s,t,a.get?a:{enumerable:!0,get:()=>r[t]})}}return s.default=r,Object.freeze(s)}const Le=dt(d),qt=dt(Ke);var Qe={exports:{}},Ce={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ir;function Br(){if(ir)return Ee;ir=1;var r=i,s=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function l(g,d,m){var c,p={},v=null,y=null;m!==void 0&&(v=""+m),d.key!==void 0&&(v=""+d.key),d.ref!==void 0&&(y=d.ref);for(c in d)n.call(d,c)&&!u.hasOwnProperty(c)&&(p[c]=d[c]);if(g&&g.defaultProps)for(c in d=g.defaultProps,d)p[c]===void 0&&(p[c]=d[c]);return{$$typeof:s,type:g,key:v,ref:y,props:p,_owner:o.current}}return Ee.Fragment=t,Ee.jsx=l,Ee.jsxs=l,Ee}var _e={};/**
9
+ */var ut;function Jt(){if(ut)return Ce;ut=1;var r=d,s=Symbol.for("react.element"),t=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(u,c,h){var m,x={},v=null,y=null;h!==void 0&&(v=""+h),c.key!==void 0&&(v=""+c.key),c.ref!==void 0&&(y=c.ref);for(m in c)a.call(c,m)&&!i.hasOwnProperty(m)&&(x[m]=c[m]);if(u&&u.defaultProps)for(m in c=u.defaultProps,c)x[m]===void 0&&(x[m]=c[m]);return{$$typeof:s,type:u,key:v,ref:y,props:x,_owner:o.current}}return Ce.Fragment=t,Ce.jsx=l,Ce.jsxs=l,Ce}var Te={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,20 +14,20 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var lr;function zr(){return lr||(lr=1,process.env.NODE_ENV!=="production"&&function(){var r=i,s=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),g=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),f=Symbol.iterator,L="@@iterator";function N(a){if(a===null||typeof a!="object")return null;var x=f&&a[f]||a[L];return typeof x=="function"?x:null}var S=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(a){{for(var x=arguments.length,w=new Array(x>1?x-1:0),C=1;C<x;C++)w[C-1]=arguments[C];I("error",a,w)}}function I(a,x,w){{var C=S.ReactDebugCurrentFrame,M=C.getStackAddendum();M!==""&&(x+="%s",w=w.concat([M]));var W=w.map(function(A){return String(A)});W.unshift("Warning: "+x),Function.prototype.apply.call(console[a],console,W)}}var k=!1,D=!1,U=!1,F=!1,h=!1,T;T=Symbol.for("react.module.reference");function O(a){return!!(typeof a=="string"||typeof a=="function"||a===n||a===u||h||a===o||a===m||a===c||F||a===y||k||D||U||typeof a=="object"&&a!==null&&(a.$$typeof===v||a.$$typeof===p||a.$$typeof===l||a.$$typeof===g||a.$$typeof===d||a.$$typeof===T||a.getModuleId!==void 0))}function P(a,x,w){var C=a.displayName;if(C)return C;var M=x.displayName||x.name||"";return M!==""?w+"("+M+")":w}function $(a){return a.displayName||"Context"}function E(a){if(a==null)return null;if(typeof a.tag=="number"&&j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case n:return"Fragment";case t:return"Portal";case u:return"Profiler";case o:return"StrictMode";case m:return"Suspense";case c:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case g:var x=a;return $(x)+".Consumer";case l:var w=a;return $(w._context)+".Provider";case d:return P(a,a.render,"ForwardRef");case p:var C=a.displayName||null;return C!==null?C:E(a.type)||"Memo";case v:{var M=a,W=M._payload,A=M._init;try{return E(A(W))}catch{return null}}}return null}var G=Object.assign,R=0,B,z,se,ee,he,re,we;function Ne(){}Ne.__reactDisabledLog=!0;function H(){{if(R===0){B=console.log,z=console.info,se=console.warn,ee=console.error,he=console.group,re=console.groupCollapsed,we=console.groupEnd;var a={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}R++}}function Q(){{if(R--,R===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:G({},a,{value:B}),info:G({},a,{value:z}),warn:G({},a,{value:se}),error:G({},a,{value:ee}),group:G({},a,{value:he}),groupCollapsed:G({},a,{value:re}),groupEnd:G({},a,{value:we})})}R<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=S.ReactCurrentDispatcher,de;function ae(a,x,w){{if(de===void 0)try{throw Error()}catch(M){var C=M.stack.trim().match(/\n( *(at )?)/);de=C&&C[1]||""}return`
18
- `+de+a}}var ie=!1,fe;{var Ue=typeof WeakMap=="function"?WeakMap:Map;fe=new Ue}function Te(a,x){if(!a||ie)return"";{var w=fe.get(a);if(w!==void 0)return w}var C;ie=!0;var M=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var W;W=q.current,q.current=null,H();try{if(x){var A=function(){throw Error()};if(Object.defineProperty(A.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(A,[])}catch(ne){C=ne}Reflect.construct(a,[],A)}else{try{A.call()}catch(ne){C=ne}a.call(A.prototype)}}else{try{throw Error()}catch(ne){C=ne}a()}}catch(ne){if(ne&&C&&typeof ne.stack=="string"){for(var V=ne.stack.split(`
19
- `),te=C.stack.split(`
20
- `),J=V.length-1,K=te.length-1;J>=1&&K>=0&&V[J]!==te[K];)K--;for(;J>=1&&K>=0;J--,K--)if(V[J]!==te[K]){if(J!==1||K!==1)do if(J--,K--,K<0||V[J]!==te[K]){var ce=`
21
- `+V[J].replace(" at new "," at ");return a.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",a.displayName)),typeof a=="function"&&fe.set(a,ce),ce}while(J>=1&&K>=0);break}}}finally{ie=!1,q.current=W,Q(),Error.prepareStackTrace=M}var Se=a?a.displayName||a.name:"",ye=Se?ae(Se):"";return typeof a=="function"&&fe.set(a,ye),ye}function Ie(a,x,w){return Te(a,!1)}function We(a){var x=a.prototype;return!!(x&&x.isReactComponent)}function Y(a,x,w){if(a==null)return"";if(typeof a=="function")return Te(a,We(a));if(typeof a=="string")return ae(a);switch(a){case m:return ae("Suspense");case c:return ae("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case d:return Ie(a.render);case p:return Y(a.type,x,w);case v:{var C=a,M=C._payload,W=C._init;try{return Y(W(M),x,w)}catch{}}}return""}var oe=Object.prototype.hasOwnProperty,le={},pe=S.ReactDebugCurrentFrame;function be(a){if(a){var x=a._owner,w=Y(a.type,a._source,x?x.type:null);pe.setExtraStackFrame(w)}else pe.setExtraStackFrame(null)}function He(a,x,w,C,M){{var W=Function.call.bind(oe);for(var A in a)if(W(a,A)){var V=void 0;try{if(typeof a[A]!="function"){var te=Error((C||"React class")+": "+w+" type `"+A+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[A]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw te.name="Invariant Violation",te}V=a[A](x,A,C,w,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){V=J}V&&!(V instanceof Error)&&(be(M),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",w,A,typeof V),be(null)),V instanceof Error&&!(V.message in le)&&(le[V.message]=!0,be(M),j("Failed %s type: %s",w,V.message),be(null))}}}var jt=Array.isArray;function Re(a){return jt(a)}function wt(a){{var x=typeof Symbol=="function"&&Symbol.toStringTag,w=x&&a[Symbol.toStringTag]||a.constructor.name||"Object";return w}}function Nt(a){try{return Tr(a),!1}catch{return!0}}function Tr(a){return""+a}function Or(a){if(Nt(a))return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wt(a)),Tr(a)}var Lr=S.ReactCurrentOwner,kt={key:!0,ref:!0,__self:!0,__source:!0},$r,Fr;function St(a){if(oe.call(a,"ref")){var x=Object.getOwnPropertyDescriptor(a,"ref").get;if(x&&x.isReactWarning)return!1}return a.ref!==void 0}function Et(a){if(oe.call(a,"key")){var x=Object.getOwnPropertyDescriptor(a,"key").get;if(x&&x.isReactWarning)return!1}return a.key!==void 0}function _t(a,x){typeof a.ref=="string"&&Lr.current}function Ct(a,x){{var w=function(){$r||($r=!0,j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};w.isReactWarning=!0,Object.defineProperty(a,"key",{get:w,configurable:!0})}}function Tt(a,x){{var w=function(){Fr||(Fr=!0,j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};w.isReactWarning=!0,Object.defineProperty(a,"ref",{get:w,configurable:!0})}}var Ot=function(a,x,w,C,M,W,A){var V={$$typeof:s,type:a,key:x,ref:w,props:A,_owner:W};return V._store={},Object.defineProperty(V._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(V,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(V,"_source",{configurable:!1,enumerable:!1,writable:!1,value:M}),Object.freeze&&(Object.freeze(V.props),Object.freeze(V)),V};function Lt(a,x,w,C,M){{var W,A={},V=null,te=null;w!==void 0&&(Or(w),V=""+w),Et(x)&&(Or(x.key),V=""+x.key),St(x)&&(te=x.ref,_t(x,M));for(W in x)oe.call(x,W)&&!kt.hasOwnProperty(W)&&(A[W]=x[W]);if(a&&a.defaultProps){var J=a.defaultProps;for(W in J)A[W]===void 0&&(A[W]=J[W])}if(V||te){var K=typeof a=="function"?a.displayName||a.name||"Unknown":a;V&&Ct(A,K),te&&Tt(A,K)}return Ot(a,V,te,M,C,Lr.current,A)}}var er=S.ReactCurrentOwner,Pr=S.ReactDebugCurrentFrame;function ke(a){if(a){var x=a._owner,w=Y(a.type,a._source,x?x.type:null);Pr.setExtraStackFrame(w)}else Pr.setExtraStackFrame(null)}var rr;rr=!1;function tr(a){return typeof a=="object"&&a!==null&&a.$$typeof===s}function Vr(){{if(er.current){var a=E(er.current.type);if(a)return`
17
+ */var mt;function Yt(){return mt||(mt=1,process.env.NODE_ENV!=="production"&&function(){var r=d,s=Symbol.for("react.element"),t=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),g=Symbol.iterator,C="@@iterator";function k(n){if(n===null||typeof n!="object")return null;var b=g&&n[g]||n[C];return typeof b=="function"?b:null}var S=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(n){{for(var b=arguments.length,N=new Array(b>1?b-1:0),F=1;F<b;F++)N[F-1]=arguments[F];I("error",n,N)}}function I(n,b,N){{var F=S.ReactDebugCurrentFrame,U=F.getStackAddendum();U!==""&&(b+="%s",N=N.concat([U]));var H=N.map(function(W){return String(W)});H.unshift("Warning: "+b),Function.prototype.apply.call(console[n],console,H)}}var _=!1,M=!1,D=!1,$=!1,f=!1,V;V=Symbol.for("react.module.reference");function L(n){return!!(typeof n=="string"||typeof n=="function"||n===a||n===i||f||n===o||n===h||n===m||$||n===y||_||M||D||typeof n=="object"&&n!==null&&(n.$$typeof===v||n.$$typeof===x||n.$$typeof===l||n.$$typeof===u||n.$$typeof===c||n.$$typeof===V||n.getModuleId!==void 0))}function P(n,b,N){var F=n.displayName;if(F)return F;var U=b.displayName||b.name||"";return U!==""?N+"("+U+")":N}function T(n){return n.displayName||"Context"}function E(n){if(n==null)return null;if(typeof n.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case a:return"Fragment";case t:return"Portal";case i:return"Profiler";case o:return"StrictMode";case h:return"Suspense";case m:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case u:var b=n;return T(b)+".Consumer";case l:var N=n;return T(N._context)+".Provider";case c:return P(n,n.render,"ForwardRef");case x:var F=n.displayName||null;return F!==null?F:E(n.type)||"Memo";case v:{var U=n,H=U._payload,W=U._init;try{return E(W(H))}catch{return null}}}return null}var J=Object.assign,re=0,B,z,ae,p,te,R,ye;function he(){}he.__reactDisabledLog=!0;function q(){{if(re===0){B=console.log,z=console.info,ae=console.warn,p=console.error,te=console.group,R=console.groupCollapsed,ye=console.groupEnd;var n={configurable:!0,enumerable:!0,value:he,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}re++}}function Z(){{if(re--,re===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},n,{value:B}),info:J({},n,{value:z}),warn:J({},n,{value:ae}),error:J({},n,{value:p}),group:J({},n,{value:te}),groupCollapsed:J({},n,{value:R}),groupEnd:J({},n,{value:ye})})}re<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Y=S.ReactCurrentDispatcher,ge;function oe(n,b,N){{if(ge===void 0)try{throw Error()}catch(U){var F=U.stack.trim().match(/\n( *(at )?)/);ge=F&&F[1]||""}return`
18
+ `+ge+n}}var ce=!1,be;{var Be=typeof WeakMap=="function"?WeakMap:Map;be=new Be}function Oe(n,b){if(!n||ce)return"";{var N=be.get(n);if(N!==void 0)return N}var F;ce=!0;var U=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var H;H=Y.current,Y.current=null,q();try{if(b){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(ie){F=ie}Reflect.construct(n,[],W)}else{try{W.call()}catch(ie){F=ie}n.call(W.prototype)}}else{try{throw Error()}catch(ie){F=ie}n()}}catch(ie){if(ie&&F&&typeof ie.stack=="string"){for(var A=ie.stack.split(`
19
+ `),ne=F.stack.split(`
20
+ `),K=A.length-1,X=ne.length-1;K>=1&&X>=0&&A[K]!==ne[X];)X--;for(;K>=1&&X>=0;K--,X--)if(A[K]!==ne[X]){if(K!==1||X!==1)do if(K--,X--,X<0||A[K]!==ne[X]){var ue=`
21
+ `+A[K].replace(" at new "," at ");return n.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",n.displayName)),typeof n=="function"&&be.set(n,ue),ue}while(K>=1&&X>=0);break}}}finally{ce=!1,Y.current=H,Z(),Error.prepareStackTrace=U}var Ee=n?n.displayName||n.name:"",Ne=Ee?oe(Ee):"";return typeof n=="function"&&be.set(n,Ne),Ne}function ze(n,b,N){return Oe(n,!1)}function qe(n){var b=n.prototype;return!!(b&&b.isReactComponent)}function G(n,b,N){if(n==null)return"";if(typeof n=="function")return Oe(n,qe(n));if(typeof n=="string")return oe(n);switch(n){case h:return oe("Suspense");case m:return oe("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case c:return ze(n.render);case x:return G(n.type,b,N);case v:{var F=n,U=F._payload,H=F._init;try{return G(H(U),b,N)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,de={},je=S.ReactDebugCurrentFrame;function we(n){if(n){var b=n._owner,N=G(n.type,n._source,b?b.type:null);je.setExtraStackFrame(N)}else je.setExtraStackFrame(null)}function Je(n,b,N,F,U){{var H=Function.call.bind(le);for(var W in n)if(H(n,W)){var A=void 0;try{if(typeof n[W]!="function"){var ne=Error((F||"React class")+": "+N+" type `"+W+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[W]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ne.name="Invariant Violation",ne}A=n[W](b,W,F,N,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(K){A=K}A&&!(A instanceof Error)&&(we(U),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",F||"React class",N,W,typeof A),we(null)),A instanceof Error&&!(A.message in de)&&(de[A.message]=!0,we(U),w("Failed %s type: %s",N,A.message),we(null))}}}var Cr=Array.isArray;function st(n){return Cr(n)}function Tr(n){{var b=typeof Symbol=="function"&&Symbol.toStringTag,N=b&&n[Symbol.toStringTag]||n.constructor.name||"Object";return N}}function Vr(n){try{return Ft(n),!1}catch{return!0}}function Ft(n){return""+n}function $t(n){if(Vr(n))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Tr(n)),Ft(n)}var Pt=S.ReactCurrentOwner,Or={key:!0,ref:!0,__self:!0,__source:!0},Mt,At;function Lr(n){if(le.call(n,"ref")){var b=Object.getOwnPropertyDescriptor(n,"ref").get;if(b&&b.isReactWarning)return!1}return n.ref!==void 0}function Fr(n){if(le.call(n,"key")){var b=Object.getOwnPropertyDescriptor(n,"key").get;if(b&&b.isReactWarning)return!1}return n.key!==void 0}function $r(n,b){typeof n.ref=="string"&&Pt.current}function Pr(n,b){{var N=function(){Mt||(Mt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};N.isReactWarning=!0,Object.defineProperty(n,"key",{get:N,configurable:!0})}}function Mr(n,b){{var N=function(){At||(At=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};N.isReactWarning=!0,Object.defineProperty(n,"ref",{get:N,configurable:!0})}}var Ar=function(n,b,N,F,U,H,W){var A={$$typeof:s,type:n,key:b,ref:N,props:W,_owner:H};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:F}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:U}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function Dr(n,b,N,F,U){{var H,W={},A=null,ne=null;N!==void 0&&($t(N),A=""+N),Fr(b)&&($t(b.key),A=""+b.key),Lr(b)&&(ne=b.ref,$r(b,U));for(H in b)le.call(b,H)&&!Or.hasOwnProperty(H)&&(W[H]=b[H]);if(n&&n.defaultProps){var K=n.defaultProps;for(H in K)W[H]===void 0&&(W[H]=K[H])}if(A||ne){var X=typeof n=="function"?n.displayName||n.name||"Unknown":n;A&&Pr(W,X),ne&&Mr(W,X)}return Ar(n,A,ne,U,F,Pt.current,W)}}var at=S.ReactCurrentOwner,Dt=S.ReactDebugCurrentFrame;function Se(n){if(n){var b=n._owner,N=G(n.type,n._source,b?b.type:null);Dt.setExtraStackFrame(N)}else Dt.setExtraStackFrame(null)}var nt;nt=!1;function ot(n){return typeof n=="object"&&n!==null&&n.$$typeof===s}function Wt(){{if(at.current){var n=E(at.current.type);if(n)return`
22
22
 
23
- Check the render method of \``+a+"`."}return""}}function $t(a){return""}var Dr={};function Ft(a){{var x=Vr();if(!x){var w=typeof a=="string"?a:a.displayName||a.name;w&&(x=`
23
+ Check the render method of \``+n+"`."}return""}}function Wr(n){return""}var It={};function Ir(n){{var b=Wt();if(!b){var N=typeof n=="string"?n:n.displayName||n.name;N&&(b=`
24
24
 
25
- Check the top-level render call using <`+w+">.")}return x}}function Ar(a,x){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var w=Ft(x);if(Dr[w])return;Dr[w]=!0;var C="";a&&a._owner&&a._owner!==er.current&&(C=" It was passed a child from "+E(a._owner.type)+"."),ke(a),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',w,C),ke(null)}}function Mr(a,x){{if(typeof a!="object")return;if(Re(a))for(var w=0;w<a.length;w++){var C=a[w];tr(C)&&Ar(C,x)}else if(tr(a))a._store&&(a._store.validated=!0);else if(a){var M=N(a);if(typeof M=="function"&&M!==a.entries)for(var W=M.call(a),A;!(A=W.next()).done;)tr(A.value)&&Ar(A.value,x)}}}function Pt(a){{var x=a.type;if(x==null||typeof x=="string")return;var w;if(typeof x=="function")w=x.propTypes;else if(typeof x=="object"&&(x.$$typeof===d||x.$$typeof===p))w=x.propTypes;else return;if(w){var C=E(x);He(w,a.props,"prop",C,a)}else if(x.PropTypes!==void 0&&!rr){rr=!0;var M=E(x);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",M||"Unknown")}typeof x.getDefaultProps=="function"&&!x.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(a){{for(var x=Object.keys(a.props),w=0;w<x.length;w++){var C=x[w];if(C!=="children"&&C!=="key"){ke(a),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),ke(null);break}}a.ref!==null&&(ke(a),j("Invalid attribute `ref` supplied to `React.Fragment`."),ke(null))}}var Ur={};function Ir(a,x,w,C,M,W){{var A=O(a);if(!A){var V="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(V+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var te=$t();te?V+=te:V+=Vr();var J;a===null?J="null":Re(a)?J="array":a!==void 0&&a.$$typeof===s?(J="<"+(E(a.type)||"Unknown")+" />",V=" Did you accidentally export a JSX literal instead of a component?"):J=typeof a,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,V)}var K=Lt(a,x,w,M,W);if(K==null)return K;if(A){var ce=x.children;if(ce!==void 0)if(C)if(Re(ce)){for(var Se=0;Se<ce.length;Se++)Mr(ce[Se],a);Object.freeze&&Object.freeze(ce)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Mr(ce,a)}if(oe.call(x,"key")){var ye=E(a),ne=Object.keys(x).filter(function(Wt){return Wt!=="key"}),sr=ne.length>0?"{key: someKey, "+ne.join(": ..., ")+": ...}":"{key: someKey}";if(!Ur[ye+sr]){var It=ne.length>0?"{"+ne.join(": ..., ")+": ...}":"{}";j(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+N+">.")}return b}}function Ut(n,b){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var N=Ir(b);if(It[N])return;It[N]=!0;var F="";n&&n._owner&&n._owner!==at.current&&(F=" It was passed a child from "+E(n._owner.type)+"."),Se(n),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',N,F),Se(null)}}function Ht(n,b){{if(typeof n!="object")return;if(st(n))for(var N=0;N<n.length;N++){var F=n[N];ot(F)&&Ut(F,b)}else if(ot(n))n._store&&(n._store.validated=!0);else if(n){var U=k(n);if(typeof U=="function"&&U!==n.entries)for(var H=U.call(n),W;!(W=H.next()).done;)ot(W.value)&&Ut(W.value,b)}}}function Ur(n){{var b=n.type;if(b==null||typeof b=="string")return;var N;if(typeof b=="function")N=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===c||b.$$typeof===x))N=b.propTypes;else return;if(N){var F=E(b);Je(N,n.props,"prop",F,n)}else if(b.PropTypes!==void 0&&!nt){nt=!0;var U=E(b);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",U||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Hr(n){{for(var b=Object.keys(n.props),N=0;N<b.length;N++){var F=b[N];if(F!=="children"&&F!=="key"){Se(n),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",F),Se(null);break}}n.ref!==null&&(Se(n),w("Invalid attribute `ref` supplied to `React.Fragment`."),Se(null))}}var Bt={};function zt(n,b,N,F,U,H){{var W=L(n);if(!W){var A="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(A+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ne=Wr();ne?A+=ne:A+=Wt();var K;n===null?K="null":st(n)?K="array":n!==void 0&&n.$$typeof===s?(K="<"+(E(n.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):K=typeof n,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",K,A)}var X=Dr(n,b,N,U,H);if(X==null)return X;if(W){var ue=b.children;if(ue!==void 0)if(F)if(st(ue)){for(var Ee=0;Ee<ue.length;Ee++)Ht(ue[Ee],n);Object.freeze&&Object.freeze(ue)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ht(ue,n)}if(le.call(b,"key")){var Ne=E(n),ie=Object.keys(b).filter(function(Gr){return Gr!=="key"}),it=ie.length>0?"{key: someKey, "+ie.join(": ..., ")+": ...}":"{key: someKey}";if(!Bt[Ne+it]){var Yr=ie.length>0?"{"+ie.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,sr,ye,It,ye),Ur[ye+sr]=!0}}return a===n?Vt(K):Pt(K),K}}function Dt(a,x,w){return Ir(a,x,w,!0)}function At(a,x,w){return Ir(a,x,w,!1)}var Mt=At,Ut=Dt;_e.Fragment=n,_e.jsx=Mt,_e.jsxs=Ut}()),_e}process.env.NODE_ENV==="production"?qe.exports=Br():qe.exports=zr();var e=qe.exports;const ue={domain:"https://studio.3speak.tv",kThreeSpeakApiUrl:"https://studio.3speak.tv/mobile/api",userOwnerThumb:r=>`https://images.hive.blog/u/${r}/avatar`,graphQLServerUrl:"https://union.us-02.infra.3speak.tv"},Ye=new ar.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class qr{constructor(){Be(this,"commonFields",`
30
+ <%s key={someKey} {...props} />`,it,Ne,Yr,Ne),Bt[Ne+it]=!0}}return n===a?Hr(X):Ur(X),X}}function Br(n,b,N){return zt(n,b,N,!0)}function zr(n,b,N){return zt(n,b,N,!1)}var qr=zr,Jr=Br;Te.Fragment=a,Te.jsx=qr,Te.jsxs=Jr}()),Te}process.env.NODE_ENV==="production"?Qe.exports=Jt():Qe.exports=Yt();var e=Qe.exports;const xe={domain:"https://studio.3speak.tv",kThreeSpeakApiUrl:"https://studio.3speak.tv/mobile/api",userOwnerThumb:r=>`https://images.hive.blog/u/${r}/avatar`,graphQLServerUrl:"https://union.us-02.infra.3speak.tv"},Fe=new Ke.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Gt{constructor(){Ye(this,"commonFields",`
31
31
  items {
32
32
  created_at
33
33
  title
@@ -55,17 +55,17 @@ React keys must be passed directly to JSX without using spread:
55
55
  spkvideo
56
56
  }
57
57
  }
58
- `)}async getGQLFeed(s,t){var o,u,l;const n=`${ue.graphQLServerUrl}/api/v2/graphql`;try{const g=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,operationName:s})});if(!g.ok)throw new Error(`GraphQL request failed: ${g.statusText}`);const d=await g.json();if(d.errors)throw new Error(`GraphQL error: ${d.errors.map(c=>c.message).join(", ")}`);const m=d.data;return(o=m.socialFeed)!=null&&o.items?m.socialFeed.items:(u=m.trendingFeed)!=null&&u.items?m.trendingFeed.items:(l=m.searchFeed)!=null&&l.items?m.searchFeed.items:[]}catch(g){throw console.error(`Failed to fetch ${s}:`,g),g}}async handleLogin(s){const t=`${ue.domain}/mobile/login`,n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s.challenge,proof:s.proof,publicKey:s.publicKey,username:s.username})});if(n.ok)return await n.json();throw new Error(`Login API error: ${await n.text()}`)}async handleUpvote({author:s,permlink:t,weight:n,authToken:o}){const u=`${ue.domain}/mobile/vote`,l=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",authorization:o},body:JSON.stringify({author:s,permlink:t,weight:n})});if(l.ok)return await l.json();{const g=await l.json();throw new Error(g.error||"Unknown API error")}}async handleComment({author:s,permlink:t,body:n,authToken:o}){const u=`${ue.domain}/mobile/comment`,l=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",authorization:o},body:JSON.stringify({author:s,permlink:t,comment:n})});if(l.ok)return await l.json();{const g=await l.json();throw new Error(g.error||"Unknown API error")}}async getVideoDetails(s,t){const n=`${ue.kThreeSpeakApiUrl}/video/@${s}/${t}`,o=await fetch(n);if(o.ok)return await o.json();console.error("Failed to fetch video details:",o.statusText)}async fetchFeed(s,t,n,o,u={limit:50,skip:0}){const{limit:l=50,skip:g=0}=u,d=`
58
+ `)}async getGQLFeed(s,t){var o,i,l;const a=`${xe.graphQLServerUrl}/api/v2/graphql`;try{const u=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,operationName:s})});if(!u.ok)throw new Error(`GraphQL request failed: ${u.statusText}`);const c=await u.json();if(c.errors)throw new Error(`GraphQL error: ${c.errors.map(m=>m.message).join(", ")}`);const h=c.data;return(o=h.socialFeed)!=null&&o.items?h.socialFeed.items:(i=h.trendingFeed)!=null&&i.items?h.trendingFeed.items:(l=h.searchFeed)!=null&&l.items?h.searchFeed.items:[]}catch(u){throw console.error(`Failed to fetch ${s}:`,u),u}}async handleLogin(s){const t=`${xe.domain}/mobile/login`,a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s.challenge,proof:s.proof,publicKey:s.publicKey,username:s.username})});if(a.ok)return await a.json();throw new Error(`Login API error: ${await a.text()}`)}async handleUpvote({author:s,permlink:t,weight:a,authToken:o}){const i=`${xe.domain}/mobile/vote`,l=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",authorization:o},body:JSON.stringify({author:s,permlink:t,weight:a})});if(l.ok)return await l.json();{const u=await l.json();throw new Error(u.error||"Unknown API error")}}async handleComment({author:s,permlink:t,body:a,authToken:o}){const i=`${xe.domain}/mobile/comment`,l=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",authorization:o},body:JSON.stringify({author:s,permlink:t,comment:a})});if(l.ok)return await l.json();{const u=await l.json();throw new Error(u.error||"Unknown API error")}}async getVideoDetails(s,t){const a=`${xe.kThreeSpeakApiUrl}/video/@${s}/${t}`,o=await fetch(a);if(o.ok)return await o.json();console.error("Failed to fetch video details:",o.statusText)}async fetchFeed(s,t,a,o,i={limit:50,skip:0}){const{limit:l=50,skip:u=0}=i,c=`
59
59
  query ${s} {
60
60
  ${t}(
61
- spkvideo: { ${n} }
61
+ spkvideo: { ${a} }
62
62
  feedOptions: ${o}
63
- pagination: { limit: ${l}, skip: ${g} }
63
+ pagination: { limit: ${l}, skip: ${u} }
64
64
  ) {
65
65
  ${this.commonFields}
66
66
  }
67
67
  }
68
- `,m=await this.getGQLFeed(s,d);return this.convertGQLItemsToThreeSpeakVideos(m)}async getUserVideos(s,t=0){return await this.fetchFeed("UserChannelFeed","socialFeed","only: true",`{ byCreator: { _in: ["${s}"] } }`,{skip:t})}async getHomeVideos(s=0){const t=`${ue.kThreeSpeakApiUrl}/feed/home?skip=${s}`,n=await fetch(t);if(n.ok){const o=await n.json();return Array.isArray(o)?o:[]}else return console.error("Failed to fetch home videos:",n.statusText),[]}async getTrendingVideos(s=0){return await this.fetchFeed("TrendingFeed","trendingFeed","only: true","{}",{skip:s})}async getNewVideos(s=0){return await this.fetchFeed("NewUploadsFeed","socialFeed","only: true","{}",{skip:s})}async getFirstUploadsVideos(s=0){return await this.fetchFeed("FirstUploadsFeed","trendingFeed","only: true, firstUpload: true","{}",{skip:s})}async getCommunityVideos(s,t=0){return await this.fetchFeed("CommunityFeed","socialFeed","only: true",`{ byCommunity: { _eq: "${s}" } }`,{skip:t})}async getRelatedVideos(s,t=0){return await this.fetchFeed("RelatedFeed","socialFeed","only: true",`{ byCreator: { _in: ["${s}"] } }`,{skip:t})}async getTaggedVideos(s,t=0){return await this.fetchFeed("TrendingTagFeed","trendingFeed","only: true",`{ byTag: { _eq: "${s}" } }`,{skip:t})}async getSearchFeed(s,t=0,n){const o=n?`{ byLang: { _eq: "${n}" } }`:"{}",u=`
68
+ `,h=await this.getGQLFeed(s,c);return this.convertGQLItemsToThreeSpeakVideos(h)}async getUserVideos(s,t=0){return await this.fetchFeed("UserChannelFeed","socialFeed","only: true",`{ byCreator: { _in: ["${s}"] } }`,{skip:t})}async getHomeVideos(s=0){const t=`${xe.kThreeSpeakApiUrl}/feed/home?skip=${s}`,a=await fetch(t);if(a.ok){const o=await a.json();return Array.isArray(o)?o:[]}else return console.error("Failed to fetch home videos:",a.statusText),[]}async getTrendingVideos(s=0){return await this.fetchFeed("TrendingFeed","trendingFeed","only: true","{}",{skip:s})}async getNewVideos(s=0){return await this.fetchFeed("NewUploadsFeed","socialFeed","only: true","{}",{skip:s})}async getFirstUploadsVideos(s=0){return await this.fetchFeed("FirstUploadsFeed","trendingFeed","only: true, firstUpload: true","{}",{skip:s})}async getCommunityVideos(s,t=0){return await this.fetchFeed("CommunityFeed","socialFeed","only: true",`{ byCommunity: { _eq: "${s}" } }`,{skip:t})}async getRelatedVideos(s,t=0){return await this.fetchFeed("RelatedFeed","socialFeed","only: true",`{ byCreator: { _in: ["${s}"] } }`,{skip:t})}async getTaggedVideos(s,t=0){return await this.fetchFeed("TrendingTagFeed","trendingFeed","only: true",`{ byTag: { _eq: "${s}" } }`,{skip:t})}async getSearchFeed(s,t=0,a){const o=a?`{ byLang: { _eq: "${a}" } }`:"{}",i=`
69
69
  query SearchFeed {
70
70
  searchFeed(
71
71
  searchTerm: "${s}"
@@ -76,7 +76,7 @@ React keys must be passed directly to JSX without using spread:
76
76
  ${this.commonFields}
77
77
  }
78
78
  }
79
- `,l=await this.getGQLFeed("SearchFeed",u);return this.convertGQLItemsToThreeSpeakVideos(l)}async getTrendingTags(){var n,o;const s=`${ue.graphQLServerUrl}/api/v2/graphql`,t=`
79
+ `,l=await this.getGQLFeed("SearchFeed",i);return this.convertGQLItemsToThreeSpeakVideos(l)}async getTrendingTags(){var a,o;const s=`${xe.graphQLServerUrl}/api/v2/graphql`,t=`
80
80
  query TrendingTags {
81
81
  trendingTags(limit: 50) {
82
82
  tags {
@@ -85,18 +85,18 @@ React keys must be passed directly to JSX without using spread:
85
85
  }
86
86
  }
87
87
  }
88
- `;try{const u=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,operationName:"TrendingTags"})});if(!u.ok)throw new Error(`GraphQL request failed: ${u.statusText}`);const l=await u.json();if(l.errors)throw new Error(`GraphQL error: ${l.errors.map(g=>g.message).join(", ")}`);return((o=(n=l.data)==null?void 0:n.trendingTags)==null?void 0:o.tags)||[]}catch(u){throw console.error("Failed to fetch trending tags:",u),u}}convertGQLItemsToThreeSpeakVideos(s){return s.map(t=>{var o,u,l,g,d,m,c,p,v,y,f,L,N,S;let n=null;try{typeof t.spkvideo=="string"?n=JSON.parse(t.spkvideo):n=t.spkvideo}catch(j){console.error("Error parsing spkvideo JSON",j)}return{title:t.title||"Untitled",owner:((o=t.author)==null?void 0:o.username)||"",permlink:t.permlink||"",created:new Date(t.created_at),category:t.tags&&t.tags.length>0?t.tags[0]:"general",duration:(n==null?void 0:n.duration)||((d=(g=(l=(u=t.json_metadata)==null?void 0:u.raw)==null?void 0:l.video)==null?void 0:g.info)==null?void 0:d.duration)||0,thumbnail:(n==null?void 0:n.thumbnail_url)||((v=(p=(c=(m=t.json_metadata)==null?void 0:m.raw)==null?void 0:c.video)==null?void 0:p.info)==null?void 0:v.thumbnail),numOfUpvotes:(y=t.stats)==null?void 0:y.num_votes,numOfComments:(f=t.stats)==null?void 0:f.num_comments,hiveValue:(L=t.stats)==null?void 0:L.total_hive_reward,active_votes:((S=(N=t.stats)==null?void 0:N.active_voters)==null?void 0:S.map(j=>({voter:j.voter,percent:j.percent,rshares:j.rshares,weight:j.weight})))||[]}})}async getContentStats(s,t){try{const n=await Ye.call("condenser_api","get_content",[s,t]);return{numOfUpvotes:(n==null?void 0:n.net_votes)??0,numOfComments:(n==null?void 0:n.children)??0,hiveValue:n!=null&&n.pending_payout_value?parseFloat(n.pending_payout_value):0}}catch{return{numOfUpvotes:0,numOfComments:0,hiveValue:0}}}async getActiveVotes(s,t){try{return await Ye.call("condenser_api","get_active_votes",[s,t])}catch(n){return console.error("Error calling get_active_votes:",n),[]}}async getCommentsList(s,t){try{const n=await Ye.call("bridge","get_discussion",[s,t]);return(Array.isArray(n)?n:n&&typeof n=="object"?Object.values(n):[]).map(u=>{const l=u.depth;if(typeof l=="string"){const d=parseInt(l,10);u.depth=Number.isFinite(d)?d:0}else(typeof l!="number"||!Number.isFinite(l))&&(u.depth=u.depth??0);const g=u.json_metadata;try{if(g&&typeof g=="string"){const d=g.trim();(d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]"))&&(u.json_metadata_parsed=JSON.parse(d))}else g&&typeof g=="object"&&(u.json_metadata_parsed=g)}catch{console.warn(`Skipped invalid json_metadata for ${u.author}/${u.permlink}`)}return u})}catch(n){return console.error("Error fetching comments list:",n),[]}}async getMyVideos(s){const t=`${ue.domain}/mobile/api/my-videos`,n=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:s}});if(n.ok){const o=await n.json();return Array.isArray(o)?o:[]}else throw console.error("Failed to fetch my videos:",n.statusText),new Error(`Failed to fetch my videos: ${n.status}`)}}const Z=new qr,xe=r=>r?r.startsWith("Qm")||r.startsWith("baf")?`https://ipfs-3speak.b-cdn.net/ipfs/${r}`:r.startsWith("http")?r:r.startsWith("/")?`https://3speak.tv${r}`:r:"/placeholder.svg",cr=({video:r,onVideoClick:s,onAuthorClick:t,isGrid:n=!1})=>{const[o,u]=i.useState({numOfUpvotes:r.numOfUpvotes,numOfComments:r.numOfComments,hiveValue:r.hiveValue});i.useEffect(()=>{if(o.numOfUpvotes===void 0&&r.numOfUpvotes===void 0){let d=!0;return(async()=>{try{const m=await Z.getContentStats(r.author||"",r.permlink||"");d&&u(m)}catch(m){console.error("Error fetching content stats for VideoCard:",m)}})(),()=>{d=!1}}else r.numOfUpvotes!==void 0&&u({numOfUpvotes:r.numOfUpvotes,numOfComments:r.numOfComments||0,hiveValue:r.hiveValue||0})},[r.author,r.permlink,o.numOfUpvotes,r.numOfUpvotes,r.numOfComments,r.hiveValue]);const l=d=>{if(!d)return"00:00";const m=Math.floor(d),c=Math.floor(m/3600),p=Math.floor(m%3600/60),v=m%60,y=f=>f.toString().padStart(2,"0");return m<60?`00:${y(v)}`:c===0?`${y(p)}:${y(v)}`:`${y(c)}:${y(p)}:${y(v)}`},g=d=>d==null?"":d>=1e6?`${(d/1e6).toFixed(1)}M`:d>=1e3?`${(d/1e3).toFixed(1)}K`:d.toString();return e.jsxs("div",{className:"group bg-card border border-border rounded-xl overflow-hidden shadow-card hover:shadow-card-hover transition-all duration-200 hover:-translate-y-1 cursor-pointer",children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",onClick:()=>s(r),children:[e.jsx("img",{src:xe(r.thumbnail),alt:r.title,onError:d=>{d.target.src=`https://images.hive.blog/u/${r.author}/avatar`},className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}),r.duration&&e.jsxs("div",{className:"absolute bottom-3 right-3 bg-black/80 text-white text-xs px-2 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[e.jsx(b.Clock,{className:"w-3 h-3"}),l(r.duration)]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-300 bg-black/20",children:e.jsx("div",{className:"bg-primary hover:bg-primary-hover rounded-full p-4 transform scale-75 group-hover:scale-100 transition-all duration-300 shadow-lg",children:e.jsx(b.Play,{className:"w-6 h-6 text-primary-foreground ml-0.5",fill:"currentColor"})})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-0 group-hover:opacity-30 transition-opacity duration-300"})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold text-card-foreground line-clamp-2 group-hover:text-primary transition-colors cursor-pointer leading-tight",onClick:()=>s(r),children:r.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer hover:text-primary transition-colors group/author",onClick:()=>t(r.author),children:[e.jsx("img",{src:`https://images.hive.blog/u/${r.author}/avatar`,alt:r.author,className:"w-8 h-8 rounded-full object-cover border-2 border-border group-hover/author:border-primary transition-colors",onError:d=>{d.target.src="https://images.hive.blog/u/null/avatar"}}),e.jsxs("span",{className:"font-medium text-sm text-muted-foreground group-hover/author:text-primary transition-colors",children:["@",r.author]})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ze.formatDistanceToNow(r.created,{addSuffix:!0})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[o.numOfUpvotes!=null&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground hover:text-primary transition-colors cursor-pointer",children:[e.jsx(b.ThumbsUp,{className:"w-4 h-4"}),e.jsx("span",{children:g(o.numOfUpvotes)})]}),o.numOfComments!=null&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground hover:text-primary transition-colors cursor-pointer",children:[e.jsx(b.MessageCircle,{className:"w-4 h-4"}),e.jsx("span",{children:g(o.numOfComments)})]})]}),o.hiveValue!=null&&o.hiveValue>0&&e.jsxs("div",{className:"text-primary font-semibold",children:["$",o.hiveValue.toFixed(2)]})]}),r.category&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"inline-block bg-primary/10 text-primary text-xs px-2 py-1 rounded-full font-medium",children:r.category})})]})]})};var X=(r=>(r.HOME="home",r.TRENDING="trending",r.NEW_VIDEOS="newVideos",r.FIRST_UPLOADS="firstUploads",r.USER="user",r.COMMUNITY="community",r.RELATED="related",r.TAG_FEED="tag_feed",r.SEARCH="search",r))(X||{});const dr=new Map,ur=({title:r,author:s,permlink:t,createdAt:n,video:o,currentUser:u,isContentVoted:l=!1,description:g,onTapComment:d,onTapUpvote:m,onTapShare:c,onTapBookmark:p,onTapAuthor:v,onTapInfo:y})=>{const[f,L]=i.useState(o.numOfComments||0),[N,S]=i.useState(o.numOfUpvotes||0),[j,I]=i.useState(!1),[k,D]=i.useState(!1),[U,F]=i.useState(""),h=B=>{F(B),D(!0),setTimeout(()=>D(!1),3e3)},T=(B,z)=>`${B}:${z}`;i.useEffect(()=>{const B=T(s,t),z=dr.get(B);z?(L(z.comments),S(z.upvotes)):(async()=>{const ee=await Z.getContentStats(s,t);S(ee.numOfUpvotes),L(ee.numOfComments),dr.set(T(s,t),{comments:ee.numOfComments,upvotes:ee.numOfUpvotes})})()},[s,t]);const O=()=>{d?d(s,t):h("Comments feature coming soon!")},P=()=>{m?m(s,t):h("Upvote feature requires authentication!")},$=()=>{if(c)c(s,t);else{const B=`https://3speak.tv/user/${s}/${t}`;navigator.share?navigator.share({title:r,url:B}):(navigator.clipboard.writeText(B),h("Link copied to clipboard!"))}},E=()=>{p?p(s,t):(I(!j),h(j?"Removed from bookmarks":"Added to bookmarks"))},G=()=>v==null?void 0:v(s,t),R=()=>{y?y(s,t):h("Video details coming soon!")};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 bg-card border-b border-border",children:[e.jsx("h1",{className:"text-xl font-bold text-card-foreground mb-4 line-clamp-2",children:r}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("button",{onClick:G,className:"flex-shrink-0 group",children:e.jsx("img",{src:`https://images.hive.blog/u/${s}/avatar`,alt:s,className:"w-12 h-12 rounded-full object-cover border-2 border-border group-hover:border-primary transition-all duration-200",onError:B=>{B.target.src=`https://ui-avatars.com/api/?name=${s}&background=random`}})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{children:[e.jsxs("button",{onClick:G,className:"font-semibold text-card-foreground hover:text-primary transition-colors text-base",children:["@",s]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[o.views&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(b.Eye,{className:"w-4 h-4"}),e.jsxs("span",{children:[o.views.toLocaleString()," views"]})]}),n&&e.jsx("span",{children:ze.formatDistanceToNow(n,{addSuffix:!0})})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:R,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary transition-all duration-200","aria-label":"Show description",children:[e.jsx(b.Info,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Info"})]}),e.jsxs("button",{type:"button",onClick:O,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary transition-all duration-200","aria-label":"Show comments",children:[e.jsx(b.MessageCircle,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:f})]}),e.jsxs("button",{type:"button",onClick:P,className:`inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200 ${l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary"}`,"aria-label":"Show upvotes",children:[e.jsx(b.ThumbsUp,{className:`w-4 h-4 ${l?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:N})]}),e.jsxs("button",{type:"button",onClick:$,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-secondary/10 hover:text-secondary transition-all duration-200","aria-label":"Share video",children:[e.jsx(b.Share2,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Share"})]}),e.jsxs("button",{type:"button",onClick:E,className:`inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200 ${j?"bg-error/10 text-error":"bg-muted text-muted-foreground hover:bg-error/10 hover:text-error"}`,"aria-label":"Bookmark video",children:[e.jsx(b.Heart,{className:`w-4 h-4 ${j?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:j?"Saved":"Save"})]})]}),(o.hiveValue||o.category)&&e.jsxs("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t border-border",children:[o.hiveValue&&o.hiveValue>0&&e.jsx("div",{className:"flex items-center gap-1 text-success font-semibold",children:e.jsxs("span",{children:["$",o.hiveValue.toFixed(2)," earned"]})}),o.category&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(b.Users,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground capitalize",children:o.category})]})]})]})]})]}),k&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-slide-up",children:e.jsx("div",{className:"bg-card border border-border text-card-foreground rounded-lg px-4 py-3 shadow-lg max-w-sm",children:e.jsx("div",{className:"font-medium",children:U})})})]})},Le=new Map,$e=({feedType:r,username:s,communityId:t,tag:n,onVideoClick:o,onAuthorClick:u})=>{const[l,g]=i.useState([]),[d,m]=i.useState(!0),[c,p]=i.useState(!1),[v,y]=i.useState(null),[f,L]=i.useState(!0),[N,S]=i.useState(0),j=i.useMemo(()=>{switch(r){case X.USER:return`user:${s||""}`;case X.COMMUNITY:return`community:${t||""}`;case X.TAG_FEED:return`tag:${n||""}`;case X.SEARCH:return`search:${n||""}`;default:return r}},[r,s,t,n]),I=i.useCallback(async h=>{var T,O,P,$,E,G,R,B,z,se,ee,he;if((T=h.author)!=null&&T.username){if(!h.permlink)return null;let re=null;try{typeof h.spkvideo=="string"?re=JSON.parse(h.spkvideo):re=h.spkvideo}catch(H){console.error("Error parsing spkvideo JSON",H)}const we=xe(re==null?void 0:re.thumbnail_url)||xe((E=($=(P=(O=h.json_metadata)==null?void 0:O.raw)==null?void 0:P.video)==null?void 0:$.info)==null?void 0:E.thumbnail),Ne=(re==null?void 0:re.duration)||((z=(B=(R=(G=h.json_metadata)==null?void 0:G.raw)==null?void 0:R.video)==null?void 0:B.info)==null?void 0:z.duration)||0;return{title:h.title||"Untitled",author:h.author.username,permlink:h.permlink,created:new Date(h.created_at),category:h.tags&&h.tags.length>0?h.tags[0]:"general",duration:Ne,thumbnail:we,numOfUpvotes:((se=h.stats)==null?void 0:se.num_votes)||h.numOfUpvotes,numOfComments:((ee=h.stats)==null?void 0:ee.num_comments)||h.numOfComments,hiveValue:((he=h.stats)==null?void 0:he.total_hive_reward)||h.hiveValue}}return h.owner?{title:h.title||"Untitled",author:h.owner,permlink:h.permlink||"",created:new Date(h.created||Date.now()),category:h.category||"general",duration:h.duration,thumbnail:xe(h.thumbnail),numOfUpvotes:h.numOfUpvotes,numOfComments:h.numOfComments,hiveValue:h.hiveValue}:null},[]),k=i.useCallback(async(h,T=!1)=>{try{let O=[];switch(r){case X.SEARCH:n&&(O=await Z.getSearchFeed(n,h));break;case X.TAG_FEED:n&&(O=await Z.getTaggedVideos(n,h));break;case X.HOME:O=await Z.getHomeVideos(h);break;case X.TRENDING:O=await Z.getTrendingVideos(h);break;case X.NEW_VIDEOS:O=await Z.getNewVideos(h);break;case X.FIRST_UPLOADS:O=await Z.getFirstUploadsVideos(h);break;case X.USER:s&&(O=await Z.getUserVideos(s,h));break;case X.COMMUNITY:t&&(O=await Z.getCommunityVideos(t,h));break;case X.RELATED:s&&(O=await Z.getRelatedVideos(s,h));break}const $=(await Promise.all(O.map(I))).filter(E=>E!==null);T?(g($),Le.set(j,$)):g(E=>{const G=[...E,...$];return Le.set(j,G),G}),L(O.length>=20),S(h+O.length),y(null)}catch(O){y(O instanceof Error?O.message:"Failed to load videos")}},[r,s,t,n,j,I]);i.useEffect(()=>{(async()=>{m(!0),g([]),S(0);const T=Le.get(j);T!=null&&T.length&&(g(T),m(!1)),await k(0,!0),m(!1)})()},[j,k]);const D=i.useCallback(async()=>{c||!f||(p(!0),await k(N),p(!1))},[c,f,N,k]),U=i.useCallback(async()=>{Le.delete(j),m(!0),S(0),await k(0,!0),m(!1)},[j,k]);i.useEffect(()=>{const h=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-1e3&&D()};return window.addEventListener("scroll",h),()=>window.removeEventListener("scroll",h)},[D]);const F=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Array.from({length:8}).map((h,T)=>e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden animate-pulse",children:[e.jsx("div",{className:"aspect-video bg-muted"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-muted rounded-full"}),e.jsx("div",{className:"h-3 bg-muted rounded w-20"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-3 bg-muted rounded w-16"}),e.jsx("div",{className:"h-3 bg-muted rounded w-12"})]})]})]},T))});return d&&l.length===0?e.jsx(F,{}):v&&l.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-card-foreground mb-2",children:"Failed to load videos"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:v}),e.jsxs("button",{onClick:U,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):l.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-card-foreground mb-2",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Check back later for new content"}),e.jsxs("button",{onClick:U,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Refresh"]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("h2",{className:"text-2xl font-bold text-card-foreground capitalize",children:[r.replace(/([A-Z])/g," $1").toLowerCase()," Videos"]}),e.jsxs("button",{onClick:U,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:l.map((h,T)=>e.jsx(cr,{video:h,onVideoClick:o,onAuthorClick:u,isGrid:!0},`${h.author}-${h.permlink}-${T}`))}),f&&e.jsx("div",{className:"flex justify-center pt-8",children:c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(b.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more videos..."]}):e.jsx("button",{onClick:D,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:"Load More Videos"})})]})},Fe=({isOpen:r,onClose:s,title:t,children:n,maxWidth:o="max-w-2xl"})=>r?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:`relative bg-card border border-border rounded-xl shadow-xl w-full mx-4 ${o} max-h-[90vh] overflow-hidden animate-scale-in`,children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[e.jsx("h2",{className:"text-xl font-bold text-card-foreground",children:t}),e.jsx("button",{onClick:s,className:"p-2 rounded-lg hover:bg-muted transition-colors",children:e.jsx(b.X,{className:"w-5 h-5 text-muted-foreground"})})]}),e.jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-80px)] custom-scrollbar",children:n})]})]}):null,mr=({author:r,permlink:s,currentUser:t,onClose:n})=>{const[o,u]=i.useState([]),[l,g]=i.useState(!0),[d,m]=i.useState(null),[c,p]=i.useState(""),[v,y]=i.useState(!1);i.useEffect(()=>{(async()=>{try{g(!0);const j=(await Z.getCommentsList(r,s)).filter(I=>I.depth&&I.depth>0).sort((I,k)=>new Date(k.created||0).getTime()-new Date(I.created||0).getTime());u(j)}catch(S){m(S instanceof Error?S.message:"Failed to load comments")}finally{g(!1)}})()},[r,s]);const f=async()=>{if(!(!c.trim()||!t))try{y(!0),console.log("Would submit comment:",c),p("")}catch(N){console.error("Failed to submit comment:",N)}finally{y(!1)}},L=N=>{const S=Math.min(N.depth||0,5);return e.jsx("div",{className:`border-l-2 border-border ${S>0?`ml-${S*4}`:""}`,children:e.jsxs("div",{className:"p-4 bg-muted/30 rounded-r-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("img",{src:`https://images.hive.blog/u/${N.author}/avatar`,alt:N.author,className:"w-6 h-6 rounded-full object-cover border border-border",onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.author}&background=random`}}),e.jsxs("span",{className:"font-medium text-card-foreground text-sm",children:["@",N.author]}),N.created&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ze.formatDistanceToNow(new Date(N.created),{addSuffix:!0})})]}),e.jsx("div",{className:"text-sm text-card-foreground leading-relaxed",children:N.body||"No content"}),N.net_votes&&N.net_votes>0&&e.jsx("div",{className:"flex items-center gap-1 mt-2",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.net_votes," votes"]})})]})},`${N.author}-${N.permlink}`)};return e.jsx(Fe,{isOpen:!0,onClose:n,title:`Comments (${o.length})`,maxWidth:"max-w-2xl",children:e.jsxs("div",{className:"p-6",children:[t&&e.jsx("div",{className:"mb-6 p-4 bg-muted/50 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${t}/avatar`,alt:t,className:"w-8 h-8 rounded-full object-cover border border-border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("textarea",{value:c,onChange:N=>p(N.target.value),placeholder:"Write a comment...",className:"w-full p-3 bg-background border border-border rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-primary",rows:3}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsxs("button",{onClick:f,disabled:!c.trim()||v,className:"inline-flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[v?e.jsx(b.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(b.Send,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:v?"Posting...":"Post Comment"})]})})]})]})}),l?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(b.Loader2,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading comments..."})]}):d?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-error",children:d})}):o.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(b.MessageCircle,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No comments yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Be the first to share your thoughts!"})]}):e.jsx("div",{className:"space-y-4",children:o.map(L)})]})})},gr=({author:r,permlink:s,onClose:t})=>{const[n,o]=i.useState([]),[u,l]=i.useState(!0),[g,d]=i.useState(null);i.useEffect(()=>{(async()=>{try{l(!0);const v=(await Z.getActiveVotes(r,s)).sort((y,f)=>f.rshares-y.rshares);o(v)}catch(p){d(p instanceof Error?p.message:"Failed to load votes")}finally{l(!1)}})()},[r,s]);const m=c=>c>=1e9?`${(c/1e9).toFixed(1)}B`:c>=1e6?`${(c/1e6).toFixed(1)}M`:c>=1e3?`${(c/1e3).toFixed(1)}K`:c.toString();return e.jsx(Fe,{isOpen:!0,onClose:t,title:`Votes (${n.length})`,maxWidth:"max-w-md",children:e.jsx("div",{className:"p-6",children:u?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(b.Loader2,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading votes..."})]}):g?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-error",children:g})}):n.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(b.ThumbsUp,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No votes yet"})]}):e.jsx("div",{className:"space-y-3",children:n.map((c,p)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${c.voter}/avatar`,alt:c.voter,className:"w-8 h-8 rounded-full object-cover border border-border",onError:v=>{v.target.src=`https://ui-avatars.com/api/?name=${c.voter}&background=random`}}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-card-foreground",children:["@",c.voter]}),c.time&&e.jsx("div",{className:"text-sm text-muted-foreground",children:new Date(c.time).toLocaleDateString()})]})]}),e.jsxs("div",{className:"text-right",children:[c.percent&&e.jsxs("div",{className:"text-sm font-medium text-primary",children:[(c.percent/100).toFixed(1),"%"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m(c.rshares)," rshares"]})]})]},`${c.voter}-${p}`))})})})},hr=({author:r,permlink:s,content:t,onClose:n})=>e.jsx(Fe,{isOpen:!0,onClose:n,title:"Video Description",maxWidth:"max-w-2xl",children:e.jsxs("div",{className:"p-6",children:[t?e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-card-foreground font-sans leading-relaxed",children:t})})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(b.FileText,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No description available"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video doesn't have a description yet."})]}),e.jsx("div",{className:"mt-6 pt-4 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["By @",r]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["/",s]})]})})]})}),Yr=({username:r,permlink:s,onAuthorClick:t,onVideoClick:n,onTagClick:o,onBack:u,onCommentsModal:l,onUpvotesModal:g,onDescriptionModal:d,onVideoInfo:m,onShare:c,onBookmark:p}={})=>{const v=r,y=s,[f,L]=i.useState(null),[N,S]=i.useState(!0),[j,I]=i.useState(null),[k,D]=i.useState(!1),[U,F]=i.useState(null),[h,T]=i.useState(!1),[O,P]=i.useState(!1),[$,E]=i.useState(!1),[G,R]=i.useState(!1),B=i.useRef(null),z=i.useRef(null),se=i.useRef(null);i.useEffect(()=>{(async()=>{if(!(!v||!y))try{S(!0),I(null);const Q=await Z.getVideoDetails(v,y);L(Q),D(!1),F(null)}catch(Q){I(Q instanceof Error?Q.message:"Failed to load video")}finally{S(!1)}})()},[v,y]);const ee=H=>H?H.startsWith("ipfs://")?`https://ipfs-3speak.b-cdn.net/ipfs/${H.replace("ipfs://","").split("/")[0]}/manifest.m3u8`:H:"";i.useEffect(()=>((async()=>{const Q=f==null?void 0:f.video_v2;if(!k||!Q||!B.current)return;const q=B.current,de=ee(Q);z.current&&(z.current.destroy(),z.current=null),q.src="",q.load();try{let ae=!1;const ie=()=>{ae||(ae=!0,q.play().then(()=>F(null)).catch(Y=>F(`Playback failed: ${Y.message}`)))};if(ve.isSupported()){const Y=new ve({debug:!1,enableWorker:!1,lowLatencyMode:!1,backBufferLength:90,maxLoadingDelay:4,maxBufferLength:30,maxMaxBufferLength:600,startLevel:-1});z.current=Y,Y.on(ve.Events.MANIFEST_PARSED,()=>{}),Y.on(ve.Events.ERROR,(oe,le)=>{if(le.fatal)switch(le.type){case ve.ErrorTypes.NETWORK_ERROR:F("Network error, retrying..."),setTimeout(()=>Y.startLoad(),1e3);break;case ve.ErrorTypes.MEDIA_ERROR:F("Media error, retrying..."),setTimeout(()=>Y.recoverMediaError(),1e3);break;default:F(`Fatal error: ${le.details}`),Y.destroy(),z.current=null;break}}),Y.attachMedia(q),Y.loadSource(de)}else if(q.canPlayType("application/vnd.apple.mpegurl"))q.src=de;else{const Y=de.replace("/manifest.m3u8","/480p/index.m3u8");q.src=Y}const fe=()=>T(!0),Ue=()=>{T(!1),ie()},Te=Y=>{var le;const oe=Y.target;F(`Video error: ${((le=oe.error)==null?void 0:le.message)||"Unknown error"}`),T(!1)},Ie=()=>T(!1);q.addEventListener("loadstart",fe),q.addEventListener("canplay",Ue),q.addEventListener("error",Te),q.addEventListener("loadeddata",Ie);const We=async()=>{var oe,le,pe,be;const Y=!!document.fullscreenElement;try{Y?"orientation"in screen&&await(((le=(oe=screen.orientation)==null?void 0:oe.lock)==null?void 0:le.call(oe,"landscape"))??Promise.resolve()):"orientation"in screen&&((be=(pe=screen.orientation)==null?void 0:pe.unlock)==null||be.call(pe))}catch{}};return document.addEventListener("fullscreenchange",We),se.current=()=>{document.removeEventListener("fullscreenchange",We)},()=>{q.removeEventListener("loadstart",fe),q.removeEventListener("canplay",Ue),q.removeEventListener("error",Te),q.removeEventListener("loadeddata",Ie),se.current&&se.current()}}catch(ae){F(`Setup error: ${ae instanceof Error?ae.message:"Unknown"}`)}})(),()=>{z.current&&(z.current.destroy(),z.current=null)}),[k,f==null?void 0:f.video_v2]);const he=()=>{if(!(f==null?void 0:f.video_v2)){F("No video source available");return}D(!0),F(null),T(!0)},re=H=>{n&&n(H)},we=H=>{t&&t(H)},Ne=H=>{if(!H)return"00:00";const Q=Math.floor(H),q=Math.floor(Q/3600),de=Math.floor(Q%3600/60),ae=Q%60,ie=fe=>fe.toString().padStart(2,"0");return Q<60?`00:${ie(ae)}`:q===0?`${ie(de)}:${ie(ae)}`:`${ie(q)}:${ie(de)}:${ie(ae)}`};return N?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"sticky top-0 z-50 w-full bg-background border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsx("div",{className:"h-8 w-24 bg-muted rounded-full animate-pulse"})})}),e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:e.jsxs("div",{className:"animate-pulse space-y-6",children:[e.jsx("div",{className:"aspect-video bg-muted rounded-xl"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})]})})]}):j||!f?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-card-foreground mb-2",children:"Failed to Load Video"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:j||"Video not found"}),e.jsxs("button",{onClick:()=>{u&&u()},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:[e.jsx(b.ArrowLeft,{className:"w-4 h-4"}),"Go Back"]})]})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"sticky top-0 z-50 w-full bg-background/95 backdrop-blur-sm border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsxs("button",{onClick:()=>{u&&u()},className:"inline-flex items-center gap-2 text-muted-foreground hover:text-card-foreground transition-colors",children:[e.jsx(b.ArrowLeft,{className:"w-4 h-4"}),"Back"]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx("div",{className:"w-full aspect-video bg-black rounded-xl overflow-hidden relative shadow-card",children:k?e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("video",{ref:B,controls:!0,poster:xe(f.thumbnail),className:"w-full h-full object-contain bg-black",onDoubleClick:async H=>{const Q=H.currentTarget;try{document.fullscreenElement?await document.exitFullscreen():await Q.requestFullscreen()}catch{}}}),h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),U&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("p",{className:"mb-4",children:U}),e.jsx("button",{onClick:()=>{D(!1),F(null)},className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover transition-colors",children:"Try Again"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:xe(f.thumbnail)||`https://images.hive.blog/u/${f.owner}/avatar`,alt:f.title,className:"w-full h-full object-cover",onError:H=>{H.target.src=`https://images.hive.blog/u/${f.owner}/avatar`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-30"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("button",{onClick:he,className:"bg-primary hover:bg-primary-hover rounded-full p-6 transform hover:scale-110 transition-all duration-300 shadow-lg",children:e.jsx(b.Play,{className:"w-8 h-8 text-primary-foreground ml-1",fill:"currentColor"})})}),f.duration&&e.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:[e.jsx(b.Clock,{className:"w-3 h-3"}),Ne(f.duration)]}),f.views&&e.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:[e.jsx(b.Eye,{className:"w-3 h-3"}),f.views.toLocaleString()," views"]})]})}),e.jsx(ur,{title:f.title||"",author:f.owner||"",permlink:f.permlink||"",createdAt:f.created,description:f.description||"",video:{title:f.title||"",author:f.owner||"",permlink:f.permlink||"",created:f.created||new Date,category:f.category||"",numOfUpvotes:void 0,numOfComments:void 0,hiveValue:void 0,duration:f.duration,thumbnail:f.thumbnail,views:f.views},onTapComment:()=>{l?l(v,y):P(!0)},onTapUpvote:()=>{g?g(v,y):E(!0)},onTapInfo:()=>{d?d(v,y,f.description||""):R(!0)},onTapAuthor:()=>{t&&t(f.owner)},onTapShare:()=>{c&&c(v,y)},onTapBookmark:()=>{p&&p(v,y)}}),f.tags&&e.jsx("div",{className:"flex flex-wrap gap-2",children:f.tags.split(",").map((H,Q)=>e.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:()=>{o&&o(H.trim())},children:["#",H.trim()]},Q))})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 sticky top-24",children:[e.jsx("h3",{className:"font-semibold text-card-foreground mb-4 text-lg",children:"Related Videos"}),e.jsx("div",{className:"space-y-4",children:e.jsx($e,{feedType:X.RELATED,username:f.owner,onVideoClick:re,onAuthorClick:we})})]})]})}),O&&v&&y&&e.jsx(mr,{author:v,permlink:y,onClose:()=>P(!1)}),$&&v&&y&&e.jsx(gr,{author:v,permlink:y,onClose:()=>E(!1)}),G&&v&&y&&e.jsx(hr,{author:v,permlink:y,content:f.description||"",onClose:()=>R(!1)})]})};var fr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xr=i.createContext&&i.createContext(fr),Jr=["attr","size","title"];function Gr(r,s){if(r==null)return{};var t=Kr(r,s),n,o;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(r);for(o=0;o<u.length;o++)n=u[o],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function Kr(r,s){if(r==null)return{};var t={};for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){if(s.indexOf(n)>=0)continue;t[n]=r[n]}return t}function Pe(){return Pe=Object.assign?Object.assign.bind():function(r){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Pe.apply(this,arguments)}function pr(r,s){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);s&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function Ve(r){for(var s=1;s<arguments.length;s++){var t=arguments[s]!=null?arguments[s]:{};s%2?pr(Object(t),!0).forEach(function(n){Qr(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pr(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Qr(r,s,t){return s=Xr(s),s in r?Object.defineProperty(r,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[s]=t,r}function Xr(r){var s=Zr(r,"string");return typeof s=="symbol"?s:s+""}function Zr(r,s){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(r)}function br(r){return r&&r.map((s,t)=>i.createElement(s.tag,Ve({key:t},s.attr),br(s.child)))}function je(r){return s=>i.createElement(Rr,Pe({attr:Ve({},r.attr)},s),br(r.child))}function Rr(r){var s=t=>{var{attr:n,size:o,title:u}=r,l=Gr(r,Jr),g=o||t.size||"1em",d;return t.className&&(d=t.className),r.className&&(d=(d?d+" ":"")+r.className),i.createElement("svg",Pe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,l,{className:d,style:Ve(Ve({color:r.color||t.color},t.style),r.style),height:g,width:g,xmlns:"http://www.w3.org/2000/svg"}),u&&i.createElement("title",null,u),r.children)};return xr!==void 0?i.createElement(xr.Consumer,null,t=>s(t)):s(fr)}function et(r){return je({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:[]}]})(r)}function rt(r){return je({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:[]}]})(r)}function tt(r){return je({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:[]}]})(r)}function st(r){return je({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:[]}]})(r)}function at(r){return je({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:[]}]})(r)}function nt(r){return je({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:[]}]})(r)}const Je=new Hr.Client(["https://api.hive.blog"]),ot=async r=>{try{const s=await Je.database.getAccounts([r]);if(!s||s.length===0)throw new Error("Account not found");return s[0]}catch(s){return console.error("Error in getWalletDataDetail:",s),{error:s instanceof Error?s.message:"Unknown error"}}},it=async r=>{try{const s=await Je.database.getDynamicGlobalProperties(),t=parseFloat(r.split(" ")[0]),n=parseFloat(String(s.total_vesting_shares).split(" ")[0]),o=parseFloat(String(s.total_vesting_fund_hive).split(" ")[0]);return(t*o/n).toFixed(3)}catch(s){return console.error("Error in convertVestingSharesToHiveData:",s),"0"}},lt=async r=>{try{const t=(await Je.database.call("get_feed_history",[])).current_median_history,n=parseFloat(t.base.split(" ")[0]),o=typeof r=="string"?parseFloat(r):r;return(n*o).toFixed(2)}catch(s){return console.error("Error in convertHivetoUSDData:",s),"0"}},yr=Wr.create(r=>({walletData:null,isLoading:!1,error:null,setWalletData:s=>r({walletData:s}),clearWalletData:()=>r({walletData:null,error:null}),fetchWalletData:async s=>{r({isLoading:!0,error:null});try{const t=await ot(s),n=L=>"error"in L;if(!t||n(t))throw new Error(n(t)?t.error:"Account not found");const o=typeof t.vesting_shares=="string"?t.vesting_shares:"0.000000 VESTS",u=typeof t.balance=="string"?t.balance:t.balance.toString(),l=typeof t.hbd_balance=="string"?t.hbd_balance:t.hbd_balance.toString(),g=typeof t.savings_balance=="string"?t.savings_balance:t.savings_balance.toString(),d=typeof t.savings_hbd_balance=="string"?t.savings_hbd_balance:t.savings_hbd_balance.toString(),m=await it(o),c=parseFloat(u.split(" ")[0]||"0"),p=parseFloat(m),v=(c+p).toFixed(3),y=await lt(v),f={balance:u,hbd_balance:l,savings_balance:g,savings_hbd_balance:d,hive_power:`${m} HP`,estimated_value:`$${y}`};return r({walletData:f}),f}catch(t){const n=t instanceof Error?t.message:"Failed to fetch wallet data";console.error("Wallet fetch error:",n);const o={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:n};return r({walletData:o,error:n}),o}finally{r({isLoading:!1})}}})),ct=({username:r,className:s=""})=>{const{walletData:t,fetchWalletData:n,isLoading:o,error:u}=yr();i.useEffect(()=>{r&&n(r)},[r,n]);const l=({label:g,value:d,icon:m,colorClass:c="bg-primary/10"})=>e.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:[e.jsxs("div",{className:"flex items-center gap-3",children:[m&&e.jsx("div",{className:`p-2 rounded-full flex items-center justify-center ${c} text-primary`,children:m}),e.jsx("span",{className:"font-semibold text-card-foreground",children:g})]}),e.jsx("span",{className:"font-medium text-muted-foreground",children:d??"-"})]});return e.jsx("div",{className:`min-h-screen bg-gradient-elegant p-4 transition-all duration-300 ${s}`,children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"flex flex-col items-center p-6 mb-6 rounded-xl bg-card border border-border shadow-elegant",children:[r&&e.jsx("img",{src:`https://images.hive.blog/u/${r}/avatar`,alt:`${r} avatar`,className:"w-20 h-20 rounded-full border-4 border-primary/20 mb-3 transition-transform hover:scale-105",onError:g=>{g.target.src=`https://ui-avatars.com/api/?name=${r}&background=random`}}),e.jsx("div",{className:"text-lg font-bold text-card-foreground",children:r}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Hive Wallet Overview"})]}),e.jsxs("div",{className:"text-center rounded-xl bg-gradient-primary shadow-glow p-6 mb-6 transition-all duration-300 hover:shadow-elegant",children:[e.jsx("div",{className:"text-sm font-semibold text-primary-foreground/80",children:"Estimated Value"}),e.jsx("div",{className:"text-3xl font-bold mt-2 text-primary-foreground",children:o?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"}),"Loading..."]}):(t==null?void 0:t.estimated_value)??"-"})]}),u&&e.jsxs("div",{className:"flex items-center p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive mb-4",children:[e.jsx(tt,{className:"mr-2"}),e.jsx("span",{children:u})]}),e.jsx(l,{label:"Balance",value:t==null?void 0:t.balance,icon:e.jsx(nt,{}),colorClass:"bg-blue-500/10"}),e.jsx(l,{label:"HBD Balance",value:t==null?void 0:t.hbd_balance,icon:e.jsx(st,{}),colorClass:"bg-green-500/10"}),e.jsx(l,{label:"Savings Balance",value:t==null?void 0:t.savings_balance,icon:e.jsx(at,{}),colorClass:"bg-yellow-500/10"}),e.jsx(l,{label:"Savings HBD Balance",value:t==null?void 0:t.savings_hbd_balance,icon:e.jsx(rt,{}),colorClass:"bg-purple-500/10"}),e.jsx(l,{label:"Hive Power",value:t==null?void 0:t.hive_power,icon:e.jsx(et,{}),colorClass:"bg-orange-500/10"})]})})},Ge="_communityLocalKey",De={getBookmarkedCommunities:()=>{const r=localStorage.getItem(Ge);return r?JSON.parse(r):[]},isUserPresentLocally:r=>{const s=localStorage.getItem(Ge);return s?JSON.parse(s).includes(r):!1},storeLikedCommunityLocally:(r,s=!1)=>{let t=De.getBookmarkedCommunities();return t.includes(r)?t=t.filter(n=>n!==r):s||t.push(r),localStorage.setItem(Ge,JSON.stringify(t)),t}},Ke=({id:r,toastType:s,isLiked:t,onAdd:n,onRemove:o,onFavourite:u})=>{const[l,g]=i.useState(t??De.isUserPresentLocally(r));i.useEffect(()=>{t!==void 0&&g(t)},[t]);const d=()=>{u&&u(),l?(o?o(r,"remove_bookmark"):De.storeLikedCommunityLocally(r,!0),m(!1)):(n?n(r,"add_bookmark"):De.storeLikedCommunityLocally(r),m(!0)),g(!l)},m=c=>{alert(`The ${s} is ${c?"added to":"removed from"} your bookmarks`)};return e.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:l?e.jsx(b.BookmarkCheck,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}):e.jsx(b.Bookmark,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})};class dt{constructor(){Be(this,"HIVE_API_URL","https://api.hive.blog")}async getListOfCommunities(s,t=20,n){const o={limit:t};n&&n.trim()!==""&&(o.last=n),s&&s.trim()!==""&&(o.query=s);const u={jsonrpc:"2.0",method:"bridge.list_communities",params:o,id:1};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).result||[]}catch(l){throw console.error("Error fetching communities:",l),l}}async getCommunityDetails(s){const t={jsonrpc:"2.0",method:"bridge.get_community",params:{name:s},id:1};try{const n=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){throw console.error("Error fetching community details:",n),n}}async getCommunitySubscribers(s,t=100,n){const o={community:s,limit:t};n&&n.trim()!==""&&(o.last=n);const u={jsonrpc:"2.0",method:"bridge.list_community_roles",params:o,id:1};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return((await l.json()).result||[]).map(d=>({username:d[0],role:d[1],extra:d[2],subscribedAt:d[3]}))}catch(l){throw console.error("Error fetching community subscribers:",l),l}}communityIcon(s){return`https://images.hive.blog/u/${s}/avatar?size=icon`}userOwnerThumb(s){return`https://images.hive.blog/u/${s}/avatar`}}const me=new dt,ut=({onSelectCommunity:r})=>{const[s,t]=i.useState([]),[n,o]=i.useState(""),[u,l]=i.useState(!0),[g,d]=i.useState(!1),[m,c]=i.useState(!0),[p,v]=i.useState(null),[y,f]=i.useState(null),L=20,N=i.useRef(null),S=i.useCallback(async(k=!1)=>{if(!(!k&&(g||!m)))try{k?(l(!0),f(null),t([]),v(null),c(!0)):d(!0);const D=n.trim(),U=await me.getListOfCommunities(D.length>=3?D:void 0,L,k?void 0:p||void 0);t(F=>k?U:[...F,...U]),U.length<L||U.length>0&&U[U.length-1].name===p?c(!1):U.length>0&&v(U[U.length-1].name||null)}catch(D){f(D instanceof Error?D.message:"Failed to load communities"),c(!1)}finally{l(!1),d(!1)}},[n,g,m,p]);i.useEffect(()=>{const k=setTimeout(()=>{S(!0)},n.length>=3||n.length===0?0:500);return()=>clearTimeout(k)},[n]),i.useEffect(()=>{var k;(k=N.current)==null||k.focus()},[n,u,y]),i.useEffect(()=>{const k=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!g&&!u&&m&&S()};return window.addEventListener("scroll",k),()=>window.removeEventListener("scroll",k)},[S,g,u,m]);const j=()=>{S(!0)},I=()=>e.jsx("div",{className:"space-y-4",children:Array.from({length:6}).map((k,D)=>e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 animate-pulse",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-1/2"})]}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-16"})]})},D))});return u&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(b.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:n,onChange:k=>o(k.target.value),ref:N,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
88
+ `;try{const i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,operationName:"TrendingTags"})});if(!i.ok)throw new Error(`GraphQL request failed: ${i.statusText}`);const l=await i.json();if(l.errors)throw new Error(`GraphQL error: ${l.errors.map(u=>u.message).join(", ")}`);return((o=(a=l.data)==null?void 0:a.trendingTags)==null?void 0:o.tags)||[]}catch(i){throw console.error("Failed to fetch trending tags:",i),i}}convertGQLItemsToThreeSpeakVideos(s){return s.map(t=>{var o,i,l,u,c,h,m,x,v,y,g,C,k,S;let a=null;try{typeof t.spkvideo=="string"?a=JSON.parse(t.spkvideo):a=t.spkvideo}catch(w){console.error("Error parsing spkvideo JSON",w)}return{title:t.title||"Untitled",owner:((o=t.author)==null?void 0:o.username)||"",permlink:t.permlink||"",created:new Date(t.created_at),category:t.tags&&t.tags.length>0?t.tags[0]:"general",duration:(a==null?void 0:a.duration)||((c=(u=(l=(i=t.json_metadata)==null?void 0:i.raw)==null?void 0:l.video)==null?void 0:u.info)==null?void 0:c.duration)||0,thumbnail:(a==null?void 0:a.thumbnail_url)||((v=(x=(m=(h=t.json_metadata)==null?void 0:h.raw)==null?void 0:m.video)==null?void 0:x.info)==null?void 0:v.thumbnail),numOfUpvotes:(y=t.stats)==null?void 0:y.num_votes,numOfComments:(g=t.stats)==null?void 0:g.num_comments,hiveValue:(C=t.stats)==null?void 0:C.total_hive_reward,active_votes:((S=(k=t.stats)==null?void 0:k.active_voters)==null?void 0:S.map(w=>({voter:w.voter,percent:w.percent,rshares:w.rshares,weight:w.weight})))||[]}})}async getContentStats(s,t){try{const a=await Fe.call("condenser_api","get_content",[s,t]);return{numOfUpvotes:(a==null?void 0:a.net_votes)??0,numOfComments:(a==null?void 0:a.children)??0,hiveValue:a!=null&&a.pending_payout_value?parseFloat(a.pending_payout_value):0}}catch{return{numOfUpvotes:0,numOfComments:0,hiveValue:0}}}async getActiveVotes(s,t){try{return await Fe.call("condenser_api","get_active_votes",[s,t])}catch(a){return console.error("Error calling get_active_votes:",a),[]}}async getCommentsList(s,t){try{const a=await Fe.call("bridge","get_discussion",[s,t]);return(Array.isArray(a)?a:a&&typeof a=="object"?Object.values(a):[]).map(i=>{const l=i.depth;if(typeof l=="string"){const c=parseInt(l,10);i.depth=Number.isFinite(c)?c:0}else(typeof l!="number"||!Number.isFinite(l))&&(i.depth=i.depth??0);const u=i.json_metadata;try{if(u&&typeof u=="string"){const c=u.trim();(c.startsWith("{")&&c.endsWith("}")||c.startsWith("[")&&c.endsWith("]"))&&(i.json_metadata_parsed=JSON.parse(c))}else u&&typeof u=="object"&&(i.json_metadata_parsed=u)}catch{console.warn(`Skipped invalid json_metadata for ${i.author}/${i.permlink}`)}return i})}catch(a){return console.error("Error fetching comments list:",a),[]}}async getMyVideos(s){const t=`${xe.domain}/mobile/api/my-videos`,a=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:s}});if(a.ok){const o=await a.json();return Array.isArray(o)?o:[]}else throw console.error("Failed to fetch my videos:",a.statusText),new Error(`Failed to fetch my videos: ${a.status}`)}async getRankedPosts(s="trending",t="",a="hive.blog",o=20,i,l){try{const u={sort:s,tag:t,observer:a,limit:o};return i&&l&&(u.start_author=i,u.start_permlink=l),await Fe.call("bridge","get_ranked_posts",u)}catch(u){return console.error("Error fetching ranked posts:",u),[]}}}const se=new Gt,ve=r=>r?r.startsWith("Qm")||r.startsWith("baf")?`https://ipfs-3speak.b-cdn.net/ipfs/${r}`:r.startsWith("http")?r:r.startsWith("/")?`https://3speak.tv${r}`:r:"/placeholder.svg",ht=({video:r,onVideoClick:s,onAuthorClick:t,isGrid:a=!1})=>{const[o,i]=d.useState({numOfUpvotes:r.numOfUpvotes,numOfComments:r.numOfComments,hiveValue:r.hiveValue});d.useEffect(()=>{if(o.numOfUpvotes===void 0&&r.numOfUpvotes===void 0){let c=!0;return(async()=>{try{const h=await se.getContentStats(r.author||"",r.permlink||"");c&&i(h)}catch(h){console.error("Error fetching content stats for VideoCard:",h)}})(),()=>{c=!1}}else r.numOfUpvotes!==void 0&&i({numOfUpvotes:r.numOfUpvotes,numOfComments:r.numOfComments||0,hiveValue:r.hiveValue||0})},[r.author,r.permlink,o.numOfUpvotes,r.numOfUpvotes,r.numOfComments,r.hiveValue]);const l=c=>{if(!c)return"00:00";const h=Math.floor(c),m=Math.floor(h/3600),x=Math.floor(h%3600/60),v=h%60,y=g=>g.toString().padStart(2,"0");return h<60?`00:${y(v)}`:m===0?`${y(x)}:${y(v)}`:`${y(m)}:${y(x)}:${y(v)}`},u=c=>c==null?"":c>=1e6?`${(c/1e6).toFixed(1)}M`:c>=1e3?`${(c/1e3).toFixed(1)}K`:c.toString();return e.jsxs("div",{className:"group bg-card border border-border rounded-xl overflow-hidden shadow-card hover:shadow-card-hover transition-all duration-200 hover:-translate-y-1 cursor-pointer",children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",onClick:()=>s(r),children:[e.jsx("img",{src:ve(r.thumbnail),alt:r.title,onError:c=>{c.target.src=`https://images.hive.blog/u/${r.author}/avatar`},className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}),r.duration&&e.jsxs("div",{className:"absolute bottom-3 right-3 bg-black/80 text-white text-xs px-2 py-1 rounded-md flex items-center gap-1 backdrop-blur-sm",children:[e.jsx(j.Clock,{className:"w-3 h-3"}),l(r.duration)]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-300 bg-black/20",children:e.jsx("div",{className:"bg-primary hover:bg-primary-hover rounded-full p-4 transform scale-75 group-hover:scale-100 transition-all duration-300 shadow-lg",children:e.jsx(j.Play,{className:"w-6 h-6 text-primary-foreground ml-0.5",fill:"currentColor"})})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-0 group-hover:opacity-30 transition-opacity duration-300"})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold text-card-foreground line-clamp-2 group-hover:text-primary transition-colors cursor-pointer leading-tight",onClick:()=>s(r),children:r.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer hover:text-primary transition-colors group/author",onClick:()=>t(r.author),children:[e.jsx("img",{src:`https://images.hive.blog/u/${r.author}/avatar`,alt:r.author,className:"w-8 h-8 rounded-full object-cover border-2 border-border group-hover/author:border-primary transition-colors",onError:c=>{c.target.src="https://images.hive.blog/u/null/avatar"}}),e.jsxs("span",{className:"font-medium text-sm text-muted-foreground group-hover/author:text-primary transition-colors",children:["@",r.author]})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ge.formatDistanceToNow(r.created,{addSuffix:!0})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[o.numOfUpvotes!=null&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground hover:text-primary transition-colors cursor-pointer",children:[e.jsx(j.ThumbsUp,{className:"w-4 h-4"}),e.jsx("span",{children:u(o.numOfUpvotes)})]}),o.numOfComments!=null&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground hover:text-primary transition-colors cursor-pointer",children:[e.jsx(j.MessageCircle,{className:"w-4 h-4"}),e.jsx("span",{children:u(o.numOfComments)})]})]}),o.hiveValue!=null&&o.hiveValue>0&&e.jsxs("div",{className:"text-primary font-semibold",children:["$",o.hiveValue.toFixed(2)]})]}),r.category&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"inline-block bg-primary/10 text-primary text-xs px-2 py-1 rounded-full font-medium",children:r.category})})]})]})};var ee=(r=>(r.HOME="home",r.TRENDING="trending",r.NEW_VIDEOS="newVideos",r.FIRST_UPLOADS="firstUploads",r.USER="user",r.COMMUNITY="community",r.RELATED="related",r.TAG_FEED="tag_feed",r.SEARCH="search",r))(ee||{});const gt=new Map,xt=({title:r,author:s,permlink:t,createdAt:a,video:o,currentUser:i,isContentVoted:l=!1,description:u,onTapComment:c,onTapUpvote:h,onTapShare:m,onTapBookmark:x,onTapAuthor:v,onTapInfo:y})=>{const[g,C]=d.useState(o.numOfComments||0),[k,S]=d.useState(o.numOfUpvotes||0),[w,I]=d.useState(!1),[_,M]=d.useState(!1),[D,$]=d.useState(""),f=B=>{$(B),M(!0),setTimeout(()=>M(!1),3e3)},V=(B,z)=>`${B}:${z}`;d.useEffect(()=>{const B=V(s,t),z=gt.get(B);z?(C(z.comments),S(z.upvotes)):(async()=>{const p=await se.getContentStats(s,t);S(p.numOfUpvotes),C(p.numOfComments),gt.set(V(s,t),{comments:p.numOfComments,upvotes:p.numOfUpvotes})})()},[s,t]);const L=()=>{c?c(s,t):f("Comments feature coming soon!")},P=()=>{h?h(s,t):f("Upvote feature requires authentication!")},T=()=>{if(m)m(s,t);else{const B=`https://3speak.tv/user/${s}/${t}`;navigator.share?navigator.share({title:r,url:B}):(navigator.clipboard.writeText(B),f("Link copied to clipboard!"))}},E=()=>{x?x(s,t):(I(!w),f(w?"Removed from bookmarks":"Added to bookmarks"))},J=()=>v==null?void 0:v(s,t),re=()=>{y?y(s,t):f("Video details coming soon!")};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 bg-card border-b border-border",children:[e.jsx("h1",{className:"text-xl font-bold text-card-foreground mb-4 line-clamp-2",children:r}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("button",{onClick:J,className:"flex-shrink-0 group",children:e.jsx("img",{src:`https://images.hive.blog/u/${s}/avatar`,alt:s,className:"w-12 h-12 rounded-full object-cover border-2 border-border group-hover:border-primary transition-all duration-200",onError:B=>{B.target.src=`https://ui-avatars.com/api/?name=${s}&background=random`}})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{children:[e.jsxs("button",{onClick:J,className:"font-semibold text-card-foreground hover:text-primary transition-colors text-base",children:["@",s]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[o.views&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j.Eye,{className:"w-4 h-4"}),e.jsxs("span",{children:[o.views.toLocaleString()," views"]})]}),a&&e.jsx("span",{children:Ge.formatDistanceToNow(a,{addSuffix:!0})})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:re,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary transition-all duration-200","aria-label":"Show description",children:[e.jsx(j.Info,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Info"})]}),e.jsxs("button",{type:"button",onClick:L,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary transition-all duration-200","aria-label":"Show comments",children:[e.jsx(j.MessageCircle,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:g})]}),e.jsxs("button",{type:"button",onClick:P,className:`inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200 ${l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary"}`,"aria-label":"Show upvotes",children:[e.jsx(j.ThumbsUp,{className:`w-4 h-4 ${l?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:k})]}),e.jsxs("button",{type:"button",onClick:T,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-muted text-muted-foreground hover:bg-secondary/10 hover:text-secondary transition-all duration-200","aria-label":"Share video",children:[e.jsx(j.Share2,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Share"})]}),e.jsxs("button",{type:"button",onClick:E,className:`inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200 ${w?"bg-error/10 text-error":"bg-muted text-muted-foreground hover:bg-error/10 hover:text-error"}`,"aria-label":"Bookmark video",children:[e.jsx(j.Heart,{className:`w-4 h-4 ${w?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:w?"Saved":"Save"})]})]}),(o.hiveValue||o.category)&&e.jsxs("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t border-border",children:[o.hiveValue&&o.hiveValue>0&&e.jsx("div",{className:"flex items-center gap-1 text-success font-semibold",children:e.jsxs("span",{children:["$",o.hiveValue.toFixed(2)," earned"]})}),o.category&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j.Users,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground capitalize",children:o.category})]})]})]})]})]}),_&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-slide-up",children:e.jsx("div",{className:"bg-card border border-border text-card-foreground rounded-lg px-4 py-3 shadow-lg max-w-sm",children:e.jsx("div",{className:"font-medium",children:D})})})]})},$e=new Map,Pe=({feedType:r,username:s,communityId:t,tag:a,onVideoClick:o,onAuthorClick:i})=>{const[l,u]=d.useState([]),[c,h]=d.useState(!0),[m,x]=d.useState(!1),[v,y]=d.useState(null),[g,C]=d.useState(!0),[k,S]=d.useState(0),w=d.useMemo(()=>{switch(r){case ee.USER:return`user:${s||""}`;case ee.COMMUNITY:return`community:${t||""}`;case ee.TAG_FEED:return`tag:${a||""}`;case ee.SEARCH:return`search:${a||""}`;default:return r}},[r,s,t,a]),I=d.useCallback(async f=>{var V,L,P,T,E,J,re,B,z,ae,p,te;if((V=f.author)!=null&&V.username){if(!f.permlink)return null;let R=null;try{typeof f.spkvideo=="string"?R=JSON.parse(f.spkvideo):R=f.spkvideo}catch(q){console.error("Error parsing spkvideo JSON",q)}const ye=ve(R==null?void 0:R.thumbnail_url)||ve((E=(T=(P=(L=f.json_metadata)==null?void 0:L.raw)==null?void 0:P.video)==null?void 0:T.info)==null?void 0:E.thumbnail),he=(R==null?void 0:R.duration)||((z=(B=(re=(J=f.json_metadata)==null?void 0:J.raw)==null?void 0:re.video)==null?void 0:B.info)==null?void 0:z.duration)||0;return{title:f.title||"Untitled",author:f.author.username,permlink:f.permlink,created:new Date(f.created_at),category:f.tags&&f.tags.length>0?f.tags[0]:"general",duration:he,thumbnail:ye,numOfUpvotes:((ae=f.stats)==null?void 0:ae.num_votes)||f.numOfUpvotes,numOfComments:((p=f.stats)==null?void 0:p.num_comments)||f.numOfComments,hiveValue:((te=f.stats)==null?void 0:te.total_hive_reward)||f.hiveValue}}return f.owner?{title:f.title||"Untitled",author:f.owner,permlink:f.permlink||"",created:new Date(f.created||Date.now()),category:f.category||"general",duration:f.duration,thumbnail:ve(f.thumbnail),numOfUpvotes:f.numOfUpvotes,numOfComments:f.numOfComments,hiveValue:f.hiveValue}:null},[]),_=d.useCallback(async(f,V=!1)=>{try{let L=[];switch(r){case ee.SEARCH:a&&(L=await se.getSearchFeed(a,f));break;case ee.TAG_FEED:a&&(L=await se.getTaggedVideos(a,f));break;case ee.HOME:L=await se.getHomeVideos(f);break;case ee.TRENDING:L=await se.getTrendingVideos(f);break;case ee.NEW_VIDEOS:L=await se.getNewVideos(f);break;case ee.FIRST_UPLOADS:L=await se.getFirstUploadsVideos(f);break;case ee.USER:s&&(L=await se.getUserVideos(s,f));break;case ee.COMMUNITY:t&&(L=await se.getCommunityVideos(t,f));break;case ee.RELATED:s&&(L=await se.getRelatedVideos(s,f));break}const T=(await Promise.all(L.map(I))).filter(E=>E!==null);V?(u(T),$e.set(w,T)):u(E=>{const J=[...E,...T];return $e.set(w,J),J}),C(L.length>=20),S(f+L.length),y(null)}catch(L){y(L instanceof Error?L.message:"Failed to load videos")}},[r,s,t,a,w,I]);d.useEffect(()=>{(async()=>{h(!0),u([]),S(0);const V=$e.get(w);V!=null&&V.length&&(u(V),h(!1)),await _(0,!0),h(!1)})()},[w,_]);const M=d.useCallback(async()=>{m||!g||(x(!0),await _(k),x(!1))},[m,g,k,_]),D=d.useCallback(async()=>{$e.delete(w),h(!0),S(0),await _(0,!0),h(!1)},[w,_]);d.useEffect(()=>{const f=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-1e3&&M()};return window.addEventListener("scroll",f),()=>window.removeEventListener("scroll",f)},[M]);const $=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Array.from({length:8}).map((f,V)=>e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden animate-pulse",children:[e.jsx("div",{className:"aspect-video bg-muted"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-muted rounded-full"}),e.jsx("div",{className:"h-3 bg-muted rounded w-20"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-3 bg-muted rounded w-16"}),e.jsx("div",{className:"h-3 bg-muted rounded w-12"})]})]})]},V))});return c&&l.length===0?e.jsx($,{}):v&&l.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-card-foreground mb-2",children:"Failed to load videos"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:v}),e.jsxs("button",{onClick:D,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):l.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-card-foreground mb-2",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Check back later for new content"}),e.jsxs("button",{onClick:D,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Refresh"]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("h2",{className:"text-2xl font-bold text-card-foreground capitalize",children:[r.replace(/([A-Z])/g," $1").toLowerCase()," Videos"]}),e.jsxs("button",{onClick:D,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:l.map((f,V)=>e.jsx(ht,{video:f,onVideoClick:o,onAuthorClick:i,isGrid:!0},`${f.author}-${f.permlink}-${V}`))}),g&&e.jsx("div",{className:"flex justify-center pt-8",children:m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(j.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more videos..."]}):e.jsx("button",{onClick:M,className:"inline-flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-card-foreground shadow-sm transition-colors hover:bg-card-hover focus:outline-none focus:ring-2 focus:ring-primary",children:"Load More Videos"})})]})},Me=({isOpen:r,onClose:s,title:t,children:a,maxWidth:o="max-w-2xl"})=>r?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:`relative bg-card border border-border rounded-xl shadow-xl w-full mx-4 ${o} max-h-[90vh] overflow-hidden animate-scale-in`,children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[e.jsx("h2",{className:"text-xl font-bold text-card-foreground",children:t}),e.jsx("button",{onClick:s,className:"p-2 rounded-lg hover:bg-muted transition-colors",children:e.jsx(j.X,{className:"w-5 h-5 text-muted-foreground"})})]}),e.jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-80px)] custom-scrollbar",children:a})]})]}):null,ft=({author:r,permlink:s,currentUser:t,onClose:a})=>{const[o,i]=d.useState([]),[l,u]=d.useState(!0),[c,h]=d.useState(null),[m,x]=d.useState(""),[v,y]=d.useState(!1);d.useEffect(()=>{(async()=>{try{u(!0);const w=(await se.getCommentsList(r,s)).filter(I=>I.depth&&I.depth>0).sort((I,_)=>new Date(_.created||0).getTime()-new Date(I.created||0).getTime());i(w)}catch(S){h(S instanceof Error?S.message:"Failed to load comments")}finally{u(!1)}})()},[r,s]);const g=async()=>{if(!(!m.trim()||!t))try{y(!0),console.log("Would submit comment:",m),x("")}catch(k){console.error("Failed to submit comment:",k)}finally{y(!1)}},C=k=>{const S=Math.min(k.depth||0,5);return e.jsx("div",{className:`border-l-2 border-border ${S>0?`ml-${S*4}`:""}`,children:e.jsxs("div",{className:"p-4 bg-muted/30 rounded-r-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("img",{src:`https://images.hive.blog/u/${k.author}/avatar`,alt:k.author,className:"w-6 h-6 rounded-full object-cover border border-border",onError:w=>{w.target.src=`https://ui-avatars.com/api/?name=${k.author}&background=random`}}),e.jsxs("span",{className:"font-medium text-card-foreground text-sm",children:["@",k.author]}),k.created&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Ge.formatDistanceToNow(new Date(k.created),{addSuffix:!0})})]}),e.jsx("div",{className:"text-sm text-card-foreground leading-relaxed",children:k.body||"No content"}),k.net_votes&&k.net_votes>0&&e.jsx("div",{className:"flex items-center gap-1 mt-2",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[k.net_votes," votes"]})})]})},`${k.author}-${k.permlink}`)};return e.jsx(Me,{isOpen:!0,onClose:a,title:`Comments (${o.length})`,maxWidth:"max-w-2xl",children:e.jsxs("div",{className:"p-6",children:[t&&e.jsx("div",{className:"mb-6 p-4 bg-muted/50 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${t}/avatar`,alt:t,className:"w-8 h-8 rounded-full object-cover border border-border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("textarea",{value:m,onChange:k=>x(k.target.value),placeholder:"Write a comment...",className:"w-full p-3 bg-background border border-border rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-primary",rows:3}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsxs("button",{onClick:g,disabled:!m.trim()||v,className:"inline-flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[v?e.jsx(j.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(j.Send,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:v?"Posting...":"Post Comment"})]})})]})]})}),l?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(j.Loader2,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading comments..."})]}):c?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-error",children:c})}):o.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(j.MessageCircle,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No comments yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Be the first to share your thoughts!"})]}):e.jsx("div",{className:"space-y-4",children:o.map(C)})]})})},pt=({author:r,permlink:s,onClose:t})=>{const[a,o]=d.useState([]),[i,l]=d.useState(!0),[u,c]=d.useState(null);d.useEffect(()=>{(async()=>{try{l(!0);const v=(await se.getActiveVotes(r,s)).sort((y,g)=>g.rshares-y.rshares);o(v)}catch(x){c(x instanceof Error?x.message:"Failed to load votes")}finally{l(!1)}})()},[r,s]);const h=m=>m>=1e9?`${(m/1e9).toFixed(1)}B`:m>=1e6?`${(m/1e6).toFixed(1)}M`:m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString();return e.jsx(Me,{isOpen:!0,onClose:t,title:`Votes (${a.length})`,maxWidth:"max-w-md",children:e.jsx("div",{className:"p-6",children:i?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(j.Loader2,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading votes..."})]}):u?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-error",children:u})}):a.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(j.ThumbsUp,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No votes yet"})]}):e.jsx("div",{className:"space-y-3",children:a.map((m,x)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${m.voter}/avatar`,alt:m.voter,className:"w-8 h-8 rounded-full object-cover border border-border",onError:v=>{v.target.src=`https://ui-avatars.com/api/?name=${m.voter}&background=random`}}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-card-foreground",children:["@",m.voter]}),m.time&&e.jsx("div",{className:"text-sm text-muted-foreground",children:new Date(m.time).toLocaleDateString()})]})]}),e.jsxs("div",{className:"text-right",children:[m.percent&&e.jsxs("div",{className:"text-sm font-medium text-primary",children:[(m.percent/100).toFixed(1),"%"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[h(m.rshares)," rshares"]})]})]},`${m.voter}-${x}`))})})})},bt=({author:r,permlink:s,content:t,onClose:a})=>e.jsx(Me,{isOpen:!0,onClose:a,title:"Video Description",maxWidth:"max-w-2xl",children:e.jsxs("div",{className:"p-6",children:[t?e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-card-foreground font-sans leading-relaxed",children:t})})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(j.FileText,{className:"w-12 h-12 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No description available"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video doesn't have a description yet."})]}),e.jsx("div",{className:"mt-6 pt-4 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["By @",r]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["/",s]})]})})]})}),Kt=({username:r,permlink:s,onAuthorClick:t,onVideoClick:a,onTagClick:o,onBack:i,onCommentsModal:l,onUpvotesModal:u,onDescriptionModal:c,onVideoInfo:h,onShare:m,onBookmark:x}={})=>{const v=r,y=s,[g,C]=d.useState(null),[k,S]=d.useState(!0),[w,I]=d.useState(null),[_,M]=d.useState(!1),[D,$]=d.useState(null),[f,V]=d.useState(!1),[L,P]=d.useState(!1),[T,E]=d.useState(!1),[J,re]=d.useState(!1),B=d.useRef(null),z=d.useRef(null),ae=d.useRef(null);d.useEffect(()=>{(async()=>{if(!(!v||!y))try{S(!0),I(null);const Z=await se.getVideoDetails(v,y);C(Z),M(!1),$(null)}catch(Z){I(Z instanceof Error?Z.message:"Failed to load video")}finally{S(!1)}})()},[v,y]);const p=q=>q?q.startsWith("ipfs://")?`https://ipfs-3speak.b-cdn.net/ipfs/${q.replace("ipfs://","").split("/")[0]}/manifest.m3u8`:q:"";d.useEffect(()=>((async()=>{const Z=g==null?void 0:g.video_v2;if(!_||!Z||!B.current)return;const Y=B.current,ge=p(Z);z.current&&(z.current.destroy(),z.current=null),Y.src="",Y.load();try{let oe=!1;const ce=()=>{oe||(oe=!0,Y.play().then(()=>$(null)).catch(G=>$(`Playback failed: ${G.message}`)))};if(ke.isSupported()){const G=new ke({debug:!1,enableWorker:!1,lowLatencyMode:!1,backBufferLength:90,maxLoadingDelay:4,maxBufferLength:30,maxMaxBufferLength:600,startLevel:-1});z.current=G,G.on(ke.Events.MANIFEST_PARSED,()=>{}),G.on(ke.Events.ERROR,(le,de)=>{if(de.fatal)switch(de.type){case ke.ErrorTypes.NETWORK_ERROR:$("Network error, retrying..."),setTimeout(()=>G.startLoad(),1e3);break;case ke.ErrorTypes.MEDIA_ERROR:$("Media error, retrying..."),setTimeout(()=>G.recoverMediaError(),1e3);break;default:$(`Fatal error: ${de.details}`),G.destroy(),z.current=null;break}}),G.attachMedia(Y),G.loadSource(ge)}else if(Y.canPlayType("application/vnd.apple.mpegurl"))Y.src=ge;else{const G=ge.replace("/manifest.m3u8","/480p/index.m3u8");Y.src=G}const be=()=>V(!0),Be=()=>{V(!1),ce()},Oe=G=>{var de;const le=G.target;$(`Video error: ${((de=le.error)==null?void 0:de.message)||"Unknown error"}`),V(!1)},ze=()=>V(!1);Y.addEventListener("loadstart",be),Y.addEventListener("canplay",Be),Y.addEventListener("error",Oe),Y.addEventListener("loadeddata",ze);const qe=async()=>{var le,de,je,we;const G=!!document.fullscreenElement;try{G?"orientation"in screen&&await(((de=(le=screen.orientation)==null?void 0:le.lock)==null?void 0:de.call(le,"landscape"))??Promise.resolve()):"orientation"in screen&&((we=(je=screen.orientation)==null?void 0:je.unlock)==null||we.call(je))}catch{}};return document.addEventListener("fullscreenchange",qe),ae.current=()=>{document.removeEventListener("fullscreenchange",qe)},()=>{Y.removeEventListener("loadstart",be),Y.removeEventListener("canplay",Be),Y.removeEventListener("error",Oe),Y.removeEventListener("loadeddata",ze),ae.current&&ae.current()}}catch(oe){$(`Setup error: ${oe instanceof Error?oe.message:"Unknown"}`)}})(),()=>{z.current&&(z.current.destroy(),z.current=null)}),[_,g==null?void 0:g.video_v2]);const te=()=>{if(!(g==null?void 0:g.video_v2)){$("No video source available");return}M(!0),$(null),V(!0)},R=q=>{a&&a(q)},ye=q=>{t&&t(q)},he=q=>{if(!q)return"00:00";const Z=Math.floor(q),Y=Math.floor(Z/3600),ge=Math.floor(Z%3600/60),oe=Z%60,ce=be=>be.toString().padStart(2,"0");return Z<60?`00:${ce(oe)}`:Y===0?`${ce(ge)}:${ce(oe)}`:`${ce(Y)}:${ce(ge)}:${ce(oe)}`};return k?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"sticky top-0 z-50 w-full bg-background border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsx("div",{className:"h-8 w-24 bg-muted rounded-full animate-pulse"})})}),e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:e.jsxs("div",{className:"animate-pulse space-y-6",children:[e.jsx("div",{className:"aspect-video bg-muted rounded-xl"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})]})})]}):w||!g?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-card-foreground mb-2",children:"Failed to Load Video"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:w||"Video not found"}),e.jsxs("button",{onClick:()=>{i&&i()},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:[e.jsx(j.ArrowLeft,{className:"w-4 h-4"}),"Go Back"]})]})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"sticky top-0 z-50 w-full bg-background/95 backdrop-blur-sm border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsxs("button",{onClick:()=>{i&&i()},className:"inline-flex items-center gap-2 text-muted-foreground hover:text-card-foreground transition-colors",children:[e.jsx(j.ArrowLeft,{className:"w-4 h-4"}),"Back"]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx("div",{className:"w-full aspect-video bg-black rounded-xl overflow-hidden relative shadow-card",children:_?e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("video",{ref:B,controls:!0,poster:ve(g.thumbnail),className:"w-full h-full object-contain bg-black",onDoubleClick:async q=>{const Z=q.currentTarget;try{document.fullscreenElement?await document.exitFullscreen():await Z.requestFullscreen()}catch{}}}),f&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),D&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("p",{className:"mb-4",children:D}),e.jsx("button",{onClick:()=>{M(!1),$(null)},className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover transition-colors",children:"Try Again"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:ve(g.thumbnail)||`https://images.hive.blog/u/${g.owner}/avatar`,alt:g.title,className:"w-full h-full object-cover",onError:q=>{q.target.src=`https://images.hive.blog/u/${g.owner}/avatar`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-overlay opacity-30"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("button",{onClick:te,className:"bg-primary hover:bg-primary-hover rounded-full p-6 transform hover:scale-110 transition-all duration-300 shadow-lg",children:e.jsx(j.Play,{className:"w-8 h-8 text-primary-foreground ml-1",fill:"currentColor"})})}),g.duration&&e.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:[e.jsx(j.Clock,{className:"w-3 h-3"}),he(g.duration)]}),g.views&&e.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:[e.jsx(j.Eye,{className:"w-3 h-3"}),g.views.toLocaleString()," views"]})]})}),e.jsx(xt,{title:g.title||"",author:g.owner||"",permlink:g.permlink||"",createdAt:g.created,description:g.description||"",video:{title:g.title||"",author:g.owner||"",permlink:g.permlink||"",created:g.created||new Date,category:g.category||"",numOfUpvotes:void 0,numOfComments:void 0,hiveValue:void 0,duration:g.duration,thumbnail:g.thumbnail,views:g.views},onTapComment:()=>{l?l(v,y):P(!0)},onTapUpvote:()=>{u?u(v,y):E(!0)},onTapInfo:()=>{c?c(v,y,g.description||""):re(!0)},onTapAuthor:()=>{t&&t(g.owner)},onTapShare:()=>{m&&m(v,y)},onTapBookmark:()=>{x&&x(v,y)}}),g.tags&&e.jsx("div",{className:"flex flex-wrap gap-2",children:g.tags.split(",").map((q,Z)=>e.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:()=>{o&&o(q.trim())},children:["#",q.trim()]},Z))})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 sticky top-24",children:[e.jsx("h3",{className:"font-semibold text-card-foreground mb-4 text-lg",children:"Related Videos"}),e.jsx("div",{className:"space-y-4",children:e.jsx(Pe,{feedType:ee.RELATED,username:g.owner,onVideoClick:R,onAuthorClick:ye})})]})]})}),L&&v&&y&&e.jsx(ft,{author:v,permlink:y,onClose:()=>P(!1)}),T&&v&&y&&e.jsx(pt,{author:v,permlink:y,onClose:()=>E(!1)}),J&&v&&y&&e.jsx(bt,{author:v,permlink:y,content:g.description||"",onClose:()=>re(!1)})]})};var yt={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},vt=d.createContext&&d.createContext(yt),Qt=["attr","size","title"];function Rt(r,s){if(r==null)return{};var t=Xt(r,s),a,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(o=0;o<i.length;o++)a=i[o],!(s.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(r,a)&&(t[a]=r[a])}return t}function Xt(r,s){if(r==null)return{};var t={};for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a)){if(s.indexOf(a)>=0)continue;t[a]=r[a]}return t}function Ae(){return Ae=Object.assign?Object.assign.bind():function(r){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Ae.apply(this,arguments)}function jt(r,s){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);s&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,a)}return t}function De(r){for(var s=1;s<arguments.length;s++){var t=arguments[s]!=null?arguments[s]:{};s%2?jt(Object(t),!0).forEach(function(a){Zt(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):jt(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}function Zt(r,s,t){return s=er(s),s in r?Object.defineProperty(r,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[s]=t,r}function er(r){var s=tr(r,"string");return typeof s=="symbol"?s:s+""}function tr(r,s){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var a=t.call(r,s);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(r)}function wt(r){return r&&r.map((s,t)=>d.createElement(s.tag,De({key:t},s.attr),wt(s.child)))}function _e(r){return s=>d.createElement(rr,Ae({attr:De({},r.attr)},s),wt(r.child))}function rr(r){var s=t=>{var{attr:a,size:o,title:i}=r,l=Rt(r,Qt),u=o||t.size||"1em",c;return t.className&&(c=t.className),r.className&&(c=(c?c+" ":"")+r.className),d.createElement("svg",Ae({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,a,l,{className:c,style:De(De({color:r.color||t.color},t.style),r.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),i&&d.createElement("title",null,i),r.children)};return vt!==void 0?d.createElement(vt.Consumer,null,t=>s(t)):s(yt)}function sr(r){return _e({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:[]}]})(r)}function ar(r){return _e({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:[]}]})(r)}function nr(r){return _e({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:[]}]})(r)}function or(r){return _e({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:[]}]})(r)}function ir(r){return _e({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:[]}]})(r)}function lr(r){return _e({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:[]}]})(r)}const Re=new qt.Client(["https://api.hive.blog"]),cr=async r=>{try{const s=await Re.database.getAccounts([r]);if(!s||s.length===0)throw new Error("Account not found");return s[0]}catch(s){return console.error("Error in getWalletDataDetail:",s),{error:s instanceof Error?s.message:"Unknown error"}}},dr=async r=>{try{const s=await Re.database.getDynamicGlobalProperties(),t=parseFloat(r.split(" ")[0]),a=parseFloat(String(s.total_vesting_shares).split(" ")[0]),o=parseFloat(String(s.total_vesting_fund_hive).split(" ")[0]);return(t*o/a).toFixed(3)}catch(s){return console.error("Error in convertVestingSharesToHiveData:",s),"0"}},ur=async r=>{try{const t=(await Re.database.call("get_feed_history",[])).current_median_history,a=parseFloat(t.base.split(" ")[0]),o=typeof r=="string"?parseFloat(r):r;return(a*o).toFixed(2)}catch(s){return console.error("Error in convertHivetoUSDData:",s),"0"}},Nt=lt.create(r=>({walletData:null,isLoading:!1,error:null,setWalletData:s=>r({walletData:s}),clearWalletData:()=>r({walletData:null,error:null}),fetchWalletData:async s=>{r({isLoading:!0,error:null});try{const t=await cr(s),a=C=>"error"in C;if(!t||a(t))throw new Error(a(t)?t.error:"Account not found");const o=typeof t.vesting_shares=="string"?t.vesting_shares:"0.000000 VESTS",i=typeof t.balance=="string"?t.balance:t.balance.toString(),l=typeof t.hbd_balance=="string"?t.hbd_balance:t.hbd_balance.toString(),u=typeof t.savings_balance=="string"?t.savings_balance:t.savings_balance.toString(),c=typeof t.savings_hbd_balance=="string"?t.savings_hbd_balance:t.savings_hbd_balance.toString(),h=await dr(o),m=parseFloat(i.split(" ")[0]||"0"),x=parseFloat(h),v=(m+x).toFixed(3),y=await ur(v),g={balance:i,hbd_balance:l,savings_balance:u,savings_hbd_balance:c,hive_power:`${h} HP`,estimated_value:`$${y}`};return r({walletData:g}),g}catch(t){const a=t instanceof Error?t.message:"Failed to fetch wallet data";console.error("Wallet fetch error:",a);const o={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:a};return r({walletData:o,error:a}),o}finally{r({isLoading:!1})}}})),mr=({username:r,className:s=""})=>{const{walletData:t,fetchWalletData:a,isLoading:o,error:i}=Nt();d.useEffect(()=>{r&&a(r)},[r,a]);const l=({label:u,value:c,icon:h,colorClass:m="bg-primary/10"})=>e.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:[e.jsxs("div",{className:"flex items-center gap-3",children:[h&&e.jsx("div",{className:`p-2 rounded-full flex items-center justify-center ${m} text-primary`,children:h}),e.jsx("span",{className:"font-semibold text-card-foreground",children:u})]}),e.jsx("span",{className:"font-medium text-muted-foreground",children:c??"-"})]});return e.jsx("div",{className:`min-h-screen bg-gradient-elegant p-4 transition-all duration-300 ${s}`,children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"flex flex-col items-center p-6 mb-6 rounded-xl bg-card border border-border shadow-elegant",children:[r&&e.jsx("img",{src:`https://images.hive.blog/u/${r}/avatar`,alt:`${r} avatar`,className:"w-20 h-20 rounded-full border-4 border-primary/20 mb-3 transition-transform hover:scale-105",onError:u=>{u.target.src=`https://ui-avatars.com/api/?name=${r}&background=random`}}),e.jsx("div",{className:"text-lg font-bold text-card-foreground",children:r}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Hive Wallet Overview"})]}),e.jsxs("div",{className:"text-center rounded-xl bg-gradient-primary shadow-glow p-6 mb-6 transition-all duration-300 hover:shadow-elegant",children:[e.jsx("div",{className:"text-sm font-semibold text-primary-foreground/80",children:"Estimated Value"}),e.jsx("div",{className:"text-3xl font-bold mt-2 text-primary-foreground",children:o?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"}),"Loading..."]}):(t==null?void 0:t.estimated_value)??"-"})]}),i&&e.jsxs("div",{className:"flex items-center p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive mb-4",children:[e.jsx(nr,{className:"mr-2"}),e.jsx("span",{children:i})]}),e.jsx(l,{label:"Balance",value:t==null?void 0:t.balance,icon:e.jsx(lr,{}),colorClass:"bg-blue-500/10"}),e.jsx(l,{label:"HBD Balance",value:t==null?void 0:t.hbd_balance,icon:e.jsx(or,{}),colorClass:"bg-green-500/10"}),e.jsx(l,{label:"Savings Balance",value:t==null?void 0:t.savings_balance,icon:e.jsx(ir,{}),colorClass:"bg-yellow-500/10"}),e.jsx(l,{label:"Savings HBD Balance",value:t==null?void 0:t.savings_hbd_balance,icon:e.jsx(ar,{}),colorClass:"bg-purple-500/10"}),e.jsx(l,{label:"Hive Power",value:t==null?void 0:t.hive_power,icon:e.jsx(sr,{}),colorClass:"bg-orange-500/10"})]})})},We=new Ke.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class hr{async getWitnessesByVote(s="",t=60){try{return await We.call("condenser_api","get_witnesses_by_vote",[s,t])}catch(a){throw console.error("Error fetching witnesses by vote:",a),a}}async getAccount(s){try{const t=await We.call("condenser_api","get_accounts",[[s]]);return t&&t.length>0?t[0]:null}catch(t){return console.error("Error fetching account:",t),null}}async getAccounts(s){try{return await We.call("condenser_api","get_accounts",[s])}catch(t){return console.error("Error fetching accounts:",t),[]}}async getWitnessVotes(s,t="",a=250){try{return await We.call("database_api","list_witness_votes",{start:[s,t],limit:a,order:"by_witness_account"})}catch(o){throw console.error("Error fetching witness votes:",o),o}}async getAllWitnessVotes(s){const t=[];let a="";try{for(;;){const i=await this.getWitnessVotes(s,a,250);if(t.push(...i.votes),i.votes.length<250)break;a=i.votes[i.votes.length-1].account}return t}catch(i){return console.error("Error fetching all witness votes:",i),[]}}async hasUserVotedForWitness(s,t){try{const a=await this.getAccount(s);return!a||!a.witness_votes?!1:a.witness_votes.includes(t)}catch(a){return console.error("Error checking witness vote:",a),!1}}async getUserWitnessVotes(s){try{const t=await this.getAccount(s);return(t==null?void 0:t.witness_votes)||[]}catch(t){return console.error("Error fetching user witness votes:",t),[]}}formatVotesToMHP(s){return`${(parseFloat(s)/1e6).toFixed(1)}m`}calculateAPR(s){return s/100}getVersionStatus(s,t){const a=this.parseVersion(s),o=this.parseVersion(t);return this.compareVersions(a,o)>=0?"green":this.compareVersions(a,o)<0?"red":"grey"}parseVersion(s){return s.split(".").map(t=>parseInt(t,10))}compareVersions(s,t){const a=Math.max(s.length,t.length);for(let o=0;o<a;o++){const i=s[o]||0,l=t[o]||0;if(i>l)return 1;if(i<l)return-1}return 0}getWitnessDescription(s){var t,a;try{let o;if(s.json_metadata&&s.json_metadata!=="{}"){o=JSON.parse(s.json_metadata);const i=(t=o.profile)==null?void 0:t.witness_description;if(i)return i}return s.posting_json_metadata&&s.posting_json_metadata!=="{}"?(o=JSON.parse(s.posting_json_metadata),((a=o.profile)==null?void 0:a.about)||""):""}catch(o){return console.error("Error parsing witness description:",o),""}}formatTimeAgo(s){const t=new Date(s),o=Math.floor((new Date().getTime()-t.getTime())/1e3);if(o<60)return`${o} second${o>1?"s":""} ago`;if(o<3600){const i=Math.floor(o/60);return`${i} minute${i>1?"s":""} ago`}else if(o<86400){const i=Math.floor(o/3600);return`${i} hour${i>1?"s":""} ago`}else if(o<604800){const i=Math.floor(o/86400);return`${i} day${i>1?"s":""} ago`}else if(o<2592e3){const i=Math.floor(o/604800);return`${i} week${i>1?"s":""} ago`}else if(o<31536e3){const i=Math.floor(o/2592e3);return`${i} month${i>1?"s":""} ago`}else{const i=Math.floor(o/31536e3);return`${i} year${i>1?"s":""} ago`}}}const me=new hr,Q=lt.create((r,s)=>({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(t="",a=50)=>{const{witnesses:o}=s();if(o.length>=500){r({hasMoreWitnesses:!1});return}r(t!==""?{loadingMoreWitnesses:!0}:{loadingWitnesses:!0,error:null});try{const l=await me.getWitnessesByVote(t,a);r(c=>{const h=new Set(c.witnesses.map(x=>x.owner)),m=l.filter(x=>!h.has(x.owner));return{witnesses:[...c.witnesses,...m],nextWitnessStart:l.length>0?l[l.length-1].owner:"",hasMoreWitnesses:l.length===a}});const u=l.filter(c=>!s().witnessDetails.has(c.owner)).map(c=>c.owner);u.length>0&&s().loadWitnessDetails(u)}catch(l){console.error("Error loading witnesses:",l),r({error:"Failed to load witnesses data"})}finally{r({loadingWitnesses:!1,loadingMoreWitnesses:!1})}},loadMoreWitnesses:async()=>{const{nextWitnessStart:t,hasMoreWitnesses:a,loadingMoreWitnesses:o}=s();!a||o||!t||await s().loadWitnesses(t,50)},loadWitnessVotes:async t=>{r({loadingVotes:!0,witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:t});try{const a=await me.getWitnessVotes(t,"",250);r({witnessVotes:a.votes,nextVotesStart:a.votes.length>0?a.votes[a.votes.length-1].account:"",hasMoreVotes:a.votes.length===250,loadingVotes:!1})}catch(a){console.error("Error loading witness votes:",a),r({error:"Failed to load witness votes",loadingVotes:!1})}},loadMoreVotes:async()=>{const{hasMoreVotes:t,loadingMoreVotes:a,nextVotesStart:o,selectedWitness:i,witnessVotes:l}=s();if(!t||a||!o||l.length>=1e3){l.length>=1e3&&r({hasMoreVotes:!1});return}r({loadingMoreVotes:!0});try{const u=await me.getWitnessVotes(i||"",o,250);r(c=>{const m=[...c.witnessVotes,...u.votes].filter((v,y,g)=>g.findIndex(C=>C.account===v.account)===y),x=u.votes.filter((v,y,g)=>g.findIndex(C=>C.account===v.account)===y);return{witnessVotes:m,nextVotesStart:x.length>0?x[x.length-1].account:"",hasMoreVotes:u.votes.length===250}})}catch(u){console.error("Error loading more witness votes:",u)}finally{r({loadingMoreVotes:!1})}},loadUserWitnessVotes:async t=>{if(t){r({loadingUserVotes:!0});try{const a=await me.getUserWitnessVotes(t);r({userWitnessVotes:a})}catch(a){console.error("Error loading user witness votes:",a)}finally{r({loadingUserVotes:!1})}}},loadWitnessDetails:async t=>{try{const a=await me.getAccounts(t);r(o=>{const i=new Map(o.witnessDetails),l=new Map(o.witnessAccounts);return a.forEach(u=>{const c=me.getWitnessDescription(u);c&&i.set(u.name,c),l.set(u.name,u)}),{witnessDetails:i,witnessAccounts:l}})}catch(a){console.error("Error loading witness details:",a)}},setFilters:t=>r({filters:t}),setSelectedWitness:t=>r({selectedWitness:t}),clearVotes:()=>r({witnessVotes:[],nextVotesStart:"",hasMoreVotes:!1,selectedWitness:null})})),gr=({filters:r,onFiltersChange:s})=>{const t=i=>{s({...r,status:i})},a=i=>{s({...r,name:i})},o=i=>{s({...r,version:i})};return e.jsxs("div",{className:"bg-gray-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"FILTERS"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"WITNESS"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.status==="active",onChange:()=>t("active"),className:"w-4 h-4 text-blue-600 bg-gray-700 border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx("span",{className:"text-white",children:"Active"})]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.status==="disabled",onChange:()=>t("disabled"),className:"w-4 h-4 text-blue-600 bg-gray-700 border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx("span",{className:"text-white",children:"Disabled/Stale"})]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.status==="approved",onChange:()=>t("approved"),className:"w-4 h-4 text-blue-600 bg-gray-700 border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx("span",{className:"text-white",children:"Approved"})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"NAME"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",placeholder:"Search",value:r.name,onChange:i=>a(i.target.value),className:"w-full pl-10 pr-4 py-2 bg-gray-700 border-b border-gray-600 text-white placeholder-gray-400 focus:outline-none focus:border-blue-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"VERSION"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",placeholder:"Version",value:r.version,onChange:i=>o(i.target.value),className:"w-full pl-10 pr-4 py-2 bg-gray-700 border-b border-gray-600 text-white placeholder-gray-400 focus:outline-none focus:border-blue-500"})]})]})]})},xr=({isOpen:r,onClose:s,witness:t,votes:a,loadingMore:o,hasMore:i,loadingInitial:l,scrollContainerRef:u,sentinelRef:c,loadMoreVotes:h})=>{const m=d.useCallback(x=>{x[0].isIntersecting&&i&&!o&&h()},[i,o,h]);return d.useEffect(()=>{const x=new IntersectionObserver(m,{threshold:.1,root:u.current});return c.current&&x.observe(c.current),()=>{c.current&&x.unobserve(c.current)}},[m,u,c]),r?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-gray-900 rounded-lg max-w-2xl w-full max-h-[80vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[e.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Votes for @",t," (showing ",a.length,")"]}),e.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white text-xl font-bold",children:"×"})]}),e.jsxs("div",{ref:u,className:"p-4 overflow-y-auto max-h-[60vh]",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:a.map((x,v)=>e.jsxs("div",{className:"flex items-center space-x-3 p-3 bg-gray-800 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-600 rounded-full flex items-center justify-center text-white text-sm font-medium",children:e.jsx("img",{className:"w-8 h-8 rounded-full",src:`https://images.hive.blog/u/${x.account}/avatar`,alt:x.account,onError:y=>{y.target.src="https://images.hive.blog/u/null/avatar"}})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-white font-medium",children:x.account}),e.jsxs("div",{className:"text-gray-400 text-sm",children:["Vote #",v+1]})]}),e.jsx("div",{className:"text-gray-400 text-sm",children:"25"})]},x.account))}),a.length===0&&!l&&e.jsx("div",{className:"text-center text-gray-400 py-8",children:"No votes found for this witness."}),o&&e.jsx("div",{className:"text-center text-gray-400 py-4",children:"Loading more votes..."}),i&&!o&&e.jsx("div",{className:"text-center py-4",children:e.jsx("button",{onClick:h,className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded",children:"Load More Votes"})}),i&&e.jsx("div",{ref:c,className:"h-4"})]})]})}):null},fr=({username:r,filters:s={status:"all",name:"",version:""},onWitnessVoteClick:t,onWitnessStatsClick:a,onWitnessUrlClick:o})=>{const i=Q(p=>p.witnesses),l=Q(p=>p.userWitnessVotes),u=Q(p=>p.loadingWitnesses),c=Q(p=>p.error),h=Q(p=>p.selectedWitness),m=Q(p=>p.witnessVotes),x=Q(p=>p.hasMoreVotes),v=Q(p=>p.loadingMoreVotes),y=Q(p=>p.loadingVotes),g=Q(p=>p.filters),C=Q(p=>p.hasMoreWitnesses),k=Q(p=>p.loadingWitnesses),S=Q(p=>p.witnessDetails);Q(p=>p.witnessAccounts);const w=Q(p=>p.loadWitnesses),I=Q(p=>p.loadMoreWitnesses),_=Q(p=>p.loadWitnessVotes),M=Q(p=>p.loadMoreVotes),D=Q(p=>p.loadUserWitnessVotes),$=Q(p=>p.setFilters),[f,V]=d.useState(!1),L=d.useRef(null),P=d.useRef(null),T=d.useRef(null),E=d.useCallback(p=>{p[0].isIntersecting&&C&&!k&&I()},[C,k,I]);d.useEffect(()=>{const p=new IntersectionObserver(E,{threshold:.1});return T.current&&p.observe(T.current),()=>{T.current&&p.unobserve(T.current)}},[E]),d.useEffect(()=>{w()},[w]),d.useEffect(()=>{r&&D(r)},[r,D]),d.useEffect(()=>{$(s)},[]);const J=d.useMemo(()=>i.filter(p=>{if(g.status!=="all"){if(g.status==="active"){const te=new Date;if(te.setFullYear(te.getFullYear()-1),new Date(p.last_hbd_exchange_update+"Z")<=te)return!1}else if(g.status==="disabled"){const te=new Date;if(te.setFullYear(te.getFullYear()-1),new Date(p.last_hbd_exchange_update+"Z")>te)return!1}else if(g.status==="approved"&&!l.includes(p.owner))return!1}return!(g.name&&!p.owner.toLowerCase().includes(g.name.toLowerCase())||g.version&&!p.running_version.includes(g.version))}),[i,g,l]),re=async p=>{t?t(p):(await _(p),V(!0))},B=p=>{a?a(p):window.open(`https://hivehub.dev/witnesses/@${p}`,"_blank")},z=p=>{o?o(p):window.open(p,"_blank")},ae=p=>r?l.includes(p):!1;return u?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):c?e.jsx("div",{className:"text-center p-8 text-red-400",children:c}):e.jsxs("div",{className:"w-full",children:[e.jsx(xr,{isOpen:f,onClose:()=>V(!1),witness:h||"",votes:m,loadingMore:v,hasMore:x,loadingInitial:y,scrollContainerRef:P,sentinelRef:L,loadMoreVotes:M}),e.jsx(gr,{filters:g,onFiltersChange:$}),e.jsxs("div",{className:"overflow-auto max-h-[70vh]",children:[e.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[e.jsx("thead",{className:"text-xs text-gray-400 uppercase bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Rank"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Witness"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Version"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Votes (MHP)"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Last Block"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Miss"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Price Feed"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"APR (%)"}),e.jsx("th",{scope:"col",className:"px-4 py-3",children:"Vote"})]})}),e.jsx("tbody",{children:J.map((p,te)=>{const R=me.getVersionStatus(p.running_version,p.hardfork_version_vote),ye=ae(p.owner);return e.jsxs("tr",{className:"border-b border-gray-700 hover:bg-gray-800",children:[e.jsx("td",{className:"px-4 py-4 font-medium text-white",children:i.findIndex(he=>he.owner===p.owner)+1}),e.jsx("td",{className:"px-4 py-4",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("img",{className:"w-8 h-8 rounded-full",src:`https://images.hive.blog/u/${p.owner}/avatar`,alt:p.owner,onError:he=>{he.target.src="https://images.hive.blog/u/null/avatar"}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-white font-medium",children:p.owner}),e.jsxs("div",{className:"text-gray-400 text-xs",children:["Witness since ",new Date(p.created).getFullYear()]}),S.get(p.owner)&&e.jsx("div",{className:"text-gray-400 text-xs mt-1 line-clamp-2",children:S.get(p.owner)})]}),e.jsxs("div",{className:"flex space-x-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>z(p.url),className:"text-gray-400 hover:text-white",title:"Visit witness URL",children:"🔗"}),e.jsx("button",{onClick:()=>B(p.owner),className:"text-gray-400 hover:text-white",title:"View witness stats",children:"📊"})]})]})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${R==="green"?"bg-green-900 text-green-300":R==="red"?"bg-red-900 text-red-300":"bg-gray-700 text-gray-300"}`,children:p.running_version})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("button",{onClick:()=>re(p.owner),className:"text-blue-400 hover:text-blue-300 cursor-pointer",disabled:y,children:y&&h===p.owner?"Loading...":me.formatVotesToMHP(p.votes)})}),e.jsxs("td",{className:"px-4 py-4 text-right",children:[e.jsx("div",{className:"text-white",children:p.last_confirmed_block_num.toLocaleString()}),e.jsx("div",{className:"text-gray-400 text-xs",children:"NA"})]}),e.jsx("td",{className:"px-4 py-4 text-right text-white",children:p.total_missed.toLocaleString()}),e.jsxs("td",{className:"px-4 py-4 text-right",children:[e.jsx("div",{className:"text-white",children:p.hbd_exchange_rate.base}),e.jsx("div",{className:"text-gray-400 text-xs",children:me.formatTimeAgo(p.last_hbd_exchange_update+"Z")})]}),e.jsxs("td",{className:"px-4 py-4 text-right text-white",children:[me.calculateAPR(p.props.hbd_interest_rate),"%"]}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("svg",{className:`w-5 h-5 ${ye?"text-green-500":"text-gray-500"}`,fill:"currentColor",viewBox:"0 0 20 20",children:e.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"})})})})]},p.owner)})})]}),k&&e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-2 text-gray-400",children:"Loading more witnesses..."})]}),C&&e.jsx("div",{ref:T,className:"h-1"})]})]})},Xe="_communityLocalKey",Ie={getBookmarkedCommunities:()=>{const r=localStorage.getItem(Xe);return r?JSON.parse(r):[]},isUserPresentLocally:r=>{const s=localStorage.getItem(Xe);return s?JSON.parse(s).includes(r):!1},storeLikedCommunityLocally:(r,s=!1)=>{let t=Ie.getBookmarkedCommunities();return t.includes(r)?t=t.filter(a=>a!==r):s||t.push(r),localStorage.setItem(Xe,JSON.stringify(t)),t}},Ze=({id:r,toastType:s,isLiked:t,onAdd:a,onRemove:o,onFavourite:i})=>{const[l,u]=d.useState(t??Ie.isUserPresentLocally(r));d.useEffect(()=>{t!==void 0&&u(t)},[t]);const c=()=>{i&&i(),l?(o?o(r,"remove_bookmark"):Ie.storeLikedCommunityLocally(r,!0),h(!1)):(a?a(r,"add_bookmark"):Ie.storeLikedCommunityLocally(r),h(!0)),u(!l)},h=m=>{alert(`The ${s} is ${m?"added to":"removed from"} your bookmarks`)};return e.jsx("button",{onClick:c,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:l?e.jsx(j.BookmarkCheck,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}):e.jsx(j.Bookmark,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})};class pr{constructor(){Ye(this,"HIVE_API_URL","https://api.hive.blog")}async getListOfCommunities(s,t=20,a){const o={limit:t};a&&a.trim()!==""&&(o.last=a),s&&s.trim()!==""&&(o.query=s);const i={jsonrpc:"2.0",method:"bridge.list_communities",params:o,id:1};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).result||[]}catch(l){throw console.error("Error fetching communities:",l),l}}async getCommunityDetails(s){const t={jsonrpc:"2.0",method:"bridge.get_community",params:{name:s},id:1};try{const a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return await a.json()}catch(a){throw console.error("Error fetching community details:",a),a}}async getCommunitySubscribers(s,t=100,a){const o={community:s,limit:t};a&&a.trim()!==""&&(o.last=a);const i={jsonrpc:"2.0",method:"bridge.list_community_roles",params:o,id:1};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return((await l.json()).result||[]).map(c=>({username:c[0],role:c[1],extra:c[2],subscribedAt:c[3]}))}catch(l){throw console.error("Error fetching community subscribers:",l),l}}async getCommunitySubscribersList(s,t=100,a){const o={community:s,limit:t};a&&a.trim()!==""&&(o.last=a);const i={jsonrpc:"2.0",method:"bridge.list_subscribers",params:o,id:2};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return((await l.json()).result||[]).map(c=>({username:c[0],role:c[1],extra:c[2],subscribedAt:c[3]}))}catch(l){throw console.error("Error fetching community subscribers list:",l),l}}async getCommunityAccounts(s){const t={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[[s]],id:2};try{const a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(await a.json()).result||[]}catch(a){throw console.error("Error fetching community accounts:",a),a}}async getRankedPosts(s,t="created",a=20,o,i){const l={tag:s,sort:t,limit:a};o&&i&&(l.start_author=o,l.start_permlink=i);const u={jsonrpc:"2.0",method:"bridge.get_ranked_posts",params:l,id:3};try{const c=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return(await c.json()).result||[]}catch(c){throw console.error("Error fetching ranked posts:",c),c}}communityIcon(s){return`https://images.hive.blog/u/${s}/avatar?size=icon`}userOwnerThumb(s){return`https://images.hive.blog/u/${s}/avatar`}async getCommunityActivities(s,t=100,a){const o={account:s,limit:t};a&&(o.last_id=a);const i={jsonrpc:"2.0",method:"bridge.account_notifications",params:o,id:19};try{const l=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).result||[]}catch(l){throw console.error("Error fetching community activities:",l),l}}}const fe=new pr,br=({onSelectCommunity:r})=>{const[s,t]=d.useState([]),[a,o]=d.useState(""),[i,l]=d.useState(!0),[u,c]=d.useState(!1),[h,m]=d.useState(!0),[x,v]=d.useState(null),[y,g]=d.useState(null),C=20,k=d.useRef(null),S=d.useCallback(async(_=!1)=>{if(!(!_&&(u||!h)))try{_?(l(!0),g(null),t([]),v(null),m(!0)):c(!0);const M=a.trim(),D=await fe.getListOfCommunities(M.length>=3?M:void 0,C,_?void 0:x||void 0);t($=>_?D:[...$,...D]),D.length<C||D.length>0&&D[D.length-1].name===x?m(!1):D.length>0&&v(D[D.length-1].name||null)}catch(M){g(M instanceof Error?M.message:"Failed to load communities"),m(!1)}finally{l(!1),c(!1)}},[a,u,h,x]);d.useEffect(()=>{const _=setTimeout(()=>{S(!0)},a.length>=3||a.length===0?0:500);return()=>clearTimeout(_)},[a]),d.useEffect(()=>{var _;(_=k.current)==null||_.focus()},[a,i,y]),d.useEffect(()=>{const _=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!u&&!i&&h&&S()};return window.addEventListener("scroll",_),()=>window.removeEventListener("scroll",_)},[S,u,i,h]);const w=()=>{S(!0)},I=()=>e.jsx("div",{className:"space-y-4",children:Array.from({length:6}).map((_,M)=>e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 animate-pulse",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-1/2"})]}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-16"})]})},M))});return i&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(j.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:a,onChange:_=>o(_.target.value),ref:k,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
89
89
  rounded-xl text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400
90
- focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),e.jsx(I,{})]}):y&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(b.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:n,onChange:k=>o(k.target.value),ref:N,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
90
+ focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),e.jsx(I,{})]}):y&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(j.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:a,onChange:_=>o(_.target.value),ref:k,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
91
91
  rounded-xl text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400
92
- focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load communities"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:y}),e.jsxs("button",{onClick:j,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:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"",children:e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"Communities"})}),e.jsxs("div",{className:"relative flex justify-between items-center",children:[e.jsx(b.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:n,onChange:k=>o(k.target.value),ref:N,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
92
+ focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load communities"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:y}),e.jsxs("button",{onClick:w,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"",children:e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"Communities"})}),e.jsxs("div",{className:"relative flex justify-between items-center",children:[e.jsx(j.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search communities...",value:a,onChange:_=>o(_.target.value),ref:k,autoFocus:!0,className:`w-full pl-10 pr-4 py-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
93
93
  rounded-xl text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400
94
- focus:outline-none focus:ring-2 focus:ring-blue-500`}),e.jsx("button",{onClick:j,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:e.jsx(b.RefreshCw,{className:"w-4 h-4"})})]}),s.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"No communities found"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:n?"Try adjusting your search terms":"Check back later for new communities"})]})}):e.jsxs("div",{className:"space-y-4",children:[s.map(k=>e.jsx("div",{className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
94
+ focus:outline-none focus:ring-2 focus:ring-blue-500`}),e.jsx("button",{onClick:w,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:e.jsx(j.RefreshCw,{className:"w-4 h-4"})})]}),s.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"No communities found"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:a?"Try adjusting your search terms":"Check back later for new communities"})]})}):e.jsxs("div",{className:"space-y-4",children:[s.map(_=>e.jsx("div",{className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
95
95
  rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700
96
- transition-colors cursor-pointer`,onClick:()=>r(k.name||""),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:me.communityIcon(k.name||""),alt:k.title,className:"w-12 h-12 rounded-full object-cover",onError:D=>{D.target.src=`https://ui-avatars.com/api/?name=${k.title}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:k.title}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 line-clamp-2",children:k.about})]}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[(k.subscribers||0).toLocaleString()," members"]})})]})},k.id)),m&&e.jsx("div",{className:"flex justify-center pt-4",children:g?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more communities..."]}):e.jsx("button",{onClick:()=>S(),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:"Load More Communities"})})]})]})},vr=({communityId:r})=>{var p,v,y;const[s,t]=i.useState(null),[n,o]=i.useState(!0),[u,l]=i.useState(null),g=async()=>{try{o(!0),l(null);const f=await me.getCommunityDetails(r);t(f)}catch(f){l(f instanceof Error?f.message:"Failed to load community details")}finally{o(!1)}};i.useEffect(()=>{g()},[r]);const d=f=>{try{return new Date(f).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return f}},m=f=>f.replace(/<[^>]*>/g,"");if(n)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading community details..."]})});if(u)return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load community details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:u}),e.jsxs("button",{onClick:g,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:[e.jsx(b.RefreshCw,{className:"w-4 h-4"}),"Try Again"]})]})});if(!(s!=null&&s.result))return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No community details available"})});const c=s.result;return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[c.about&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"About"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:m(c.about)})]}),c.description&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Information"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:m(c.description)})]}),c.flag_text&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Community Rules"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:m(c.flag_text)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Total Authors"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((p=c.num_authors)==null?void 0:p.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Subscribers"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((v=c.subscribers)==null?void 0:v.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.created_at?d(c.created_at):"Unknown"})]}),c.lang&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Language"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.lang.toUpperCase()})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Pending Posts"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:((y=c.num_pending)==null?void 0:y.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Type"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.is_nsfw?"NSFW":"Safe"})]})]})]})})},jr=({communityId:r,onSelectTeamMember:s})=>{var c;const[t,n]=i.useState(null),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const p=await me.getCommunityDetails(r);n(p)}catch(p){g(p instanceof Error?p.message:"Failed to load team details")}finally{u(!1)}};i.useEffect(()=>{d()},[r]);const m=((c=t==null?void 0:t.result)==null?void 0:c.team)||[];return o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading team members..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load team details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.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:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):m.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No team members found"})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:m.map((p,v)=>{const y=p[0],f=p.length>1?p[1]:"";return e.jsx("div",{onClick:()=>s&&s(y),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
96
+ transition-colors cursor-pointer`,onClick:()=>r(_.name||""),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:fe.communityIcon(_.name||""),alt:_.title,className:"w-12 h-12 rounded-full object-cover",onError:M=>{M.target.src=`https://ui-avatars.com/api/?name=${_.title}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:_.title}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 line-clamp-2",children:_.about})]}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[(_.subscribers||0).toLocaleString()," members"]})})]})},_.id)),h&&e.jsx("div",{className:"flex justify-center pt-4",children:u?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more communities..."]}):e.jsx("button",{onClick:()=>S(),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:"Load More Communities"})})]})]})},kt=({communityId:r})=>{var x,v,y;const[s,t]=d.useState(null),[a,o]=d.useState(!0),[i,l]=d.useState(null),u=async()=>{try{o(!0),l(null);const g=await fe.getCommunityDetails(r);t(g)}catch(g){l(g instanceof Error?g.message:"Failed to load community details")}finally{o(!1)}};d.useEffect(()=>{u()},[r]);const c=g=>{try{return new Date(g).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return g}},h=g=>g.replace(/<[^>]*>/g,"");if(a)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading community details..."]})});if(i)return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load community details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:i}),e.jsxs("button",{onClick:u,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4"}),"Try Again"]})]})});if(!(s!=null&&s.result))return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No community details available"})});const m=s.result;return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[m.about&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"About"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:h(m.about)})]}),m.description&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Information"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:h(m.description)})]}),m.flag_text&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"Community Rules"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:h(m.flag_text)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Total Authors"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((x=m.num_authors)==null?void 0:x.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Subscribers"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((v=m.subscribers)==null?void 0:v.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m.created_at?c(m.created_at):"Unknown"})]}),m.lang&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Language"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m.lang.toUpperCase()})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Pending Posts"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:((y=m.num_pending)==null?void 0:y.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Type"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m.is_nsfw?"NSFW":"Safe"})]})]})]})})},_t=({communityId:r,onSelectTeamMember:s})=>{var m;const[t,a]=d.useState(null),[o,i]=d.useState(!0),[l,u]=d.useState(null),c=async()=>{try{i(!0),u(null);const x=await fe.getCommunityDetails(r);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to load team details")}finally{i(!1)}};d.useEffect(()=>{c()},[r]);const h=((m=t==null?void 0:t.result)==null?void 0:m.team)||[];return o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading team members..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load team details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.jsxs("button",{onClick:c,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):h.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No team members found"})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:h.map((x,v)=>{const y=x[0],g=x.length>1?x[1]:"";return e.jsx("div",{onClick:()=>s&&s(y),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
97
97
  rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700
98
- transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:me.userOwnerThumb(y),alt:y,className:"w-12 h-12 rounded-full object-cover",onError:L=>{L.target.src=`https://ui-avatars.com/api/?name=${y}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",y]}),f&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:f})]})]})},`${y}-${v}`)})})})},wr=({communityId:r,onSelectCommunityMember:s})=>{const[t,n]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(!1),[d,m]=i.useState(!0),[c,p]=i.useState(null),[v,y]=i.useState(null),f=100,L=i.useCallback(async(N=!1)=>{if(!(l&&!N))try{N?(u(!0),y(null),n([]),p(null),m(!0)):g(!0);const S=await me.getCommunitySubscribers(r,f,N?void 0:c||void 0);S.length===0?m(!1):(n(j=>{if(N)return S;const I=new Set(j.map(D=>D.username)),k=S.filter(D=>!I.has(D.username));return[...j,...k]}),S.length>0&&p(S[S.length-1].username),m(S.length===f))}catch(S){y(S instanceof Error?S.message:"Failed to load members")}finally{u(!1),g(!1)}},[r,l,c]);return i.useEffect(()=>{L(!0)},[r]),i.useEffect(()=>{const N=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!l&&!o&&d&&L()};return window.addEventListener("scroll",N),()=>window.removeEventListener("scroll",N)},[L,l,o,d]),o&&t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading members..."]})}):v&&t.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load members"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:v}),e.jsxs("button",{onClick:()=>L(!0),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:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No community members found"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((N,S)=>e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors cursor-pointer",onClick:()=>s==null?void 0:s(N.username),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:me.userOwnerThumb(N.username),alt:N.username,className:"w-12 h-12 rounded-full object-cover",onError:j=>{j.target.src=`https://ui-avatars.com/api/?name=${N.username}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",N.username]}),N.role&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:N.role})]})]})},`${N.username}-${S}`))}),d&&e.jsx("div",{className:"flex justify-center pt-4",children:l?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more members..."]}):e.jsx("button",{onClick:()=>L(),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:"Load More Members"})})]})},mt=({communityId:r,onVideoClick:s,onAuthorClick:t,onBack:n,onclickAboutTab:o,onclickTeamTab:u,onclickMemberTab:l,onShare:g,onFavourite:d,onRss:m,onMoreVertical:c,showMoreVertical:p=!0})=>{const v=nr.useNavigate(),[y,f]=i.useState("videos"),[L,N]=i.useState(null),[S,j]=i.useState(!1),[I,k]=i.useState(!0);i.useEffect(()=>{(async()=>{try{k(!0);const O=await me.getCommunityDetails(r);N(O)}catch(O){console.error("Failed to fetch community details:",O)}finally{k(!1)}})()},[r]);const D=()=>{var O;const T=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:((O=L==null?void 0:L.result)==null?void 0:O.title)||r,url:T}):navigator.clipboard.writeText(T)},U=()=>{window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},F=T=>{v(`/user/${T}`)};if(I)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-32 mb-6"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-48"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"})]})]}),e.jsx("div",{className:"flex gap-2",children:Array.from({length:4}).map((T,O)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},O))})]})]})});const h=L==null?void 0:L.result;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:n,className:"flex items-center justify-center mr-4 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(b.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[e.jsx("img",{src:me.userOwnerThumb(r),alt:(h==null?void 0:h.title)||r,className:"w-16 h-16 rounded-full object-cover",onError:T=>{T.target.src=`https://images.hive.blog/u/${(h==null?void 0:h.title)||r}/avatar`}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:(h==null?void 0:h.title)||r}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:(h==null?void 0:h.about)||"Community description"}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[((h==null?void 0:h.subscribers)||0).toLocaleString()," members"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Calendar,{className:"w-4 h-4"}),e.jsxs("span",{children:["Created"," ",h!=null&&h.created_at?new Date(h.created_at).getFullYear():"Unknown"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{id:r,toastType:"community",onAdd:(T,O)=>console.log("Added:",T,O),onRemove:(T,O)=>console.log("Removed:",T,O),onFavourite:d}),e.jsx("button",{onClick:m||U,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:e.jsx(b.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:g||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:e.jsx(b.Share2,{className:"w-4 h-4"})}),p&&e.jsx("button",{onClick:c||(()=>{}),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:e.jsx(b.MoreVertical,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-4 w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[e.jsx("button",{onClick:()=>f("videos"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="videos"?"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:"Videos"}),e.jsx("button",{onClick:()=>o?o():f("about"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="about"?"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:"About"}),e.jsx("button",{onClick:()=>u?u():f("team"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="team"?"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:"Team"}),e.jsx("button",{onClick:()=>l?l():f("members"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="members"?"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:"Members"})]}),e.jsxs("div",{className:"mt-6",children:[y==="videos"&&e.jsx($e,{feedType:X.COMMUNITY,communityId:r,onVideoClick:s,onAuthorClick:t}),y==="about"&&!o&&e.jsx(vr,{communityId:r}),y==="team"&&!u&&e.jsx(jr,{communityId:r,onSelectTeamMember:F}),y==="members"&&!l&&e.jsx(wr,{communityId:r,onSelectCommunityMember:F})]})]})]})},gt=({currentUser:r,onTabChanged:s,onPublish:t,onViewMyVideo:n,onMoreOptions:o,onTapBackButton:u,shouldShowBackButton:l=!0,shouldShowPublishButton:g=!1,shouldShowMoreOptionsButton:d=!1})=>{const m=nr.useNavigate(),[c,p]=i.useState(0),[v,y]=i.useState([]),[f,L]=i.useState(!0),[N,S]=i.useState(null),j=v.filter(P=>["encoding","uploaded","encoding_queued","encoding_preparing","ipfs_pinning","ipfs_pinning_failed","encoding_failed","encoding_ipfs"].includes(P.status||"")),I=v.filter(P=>P.status==="publish_manual"),k=v.filter(P=>P.status==="published");i.useEffect(()=>{r!=null&&r.token&&D()},[r]);const D=async()=>{if(!(r!=null&&r.token)){S("No authentication token provided"),L(!1);return}L(!0),S(null);try{const P=await Z.getMyVideos(r.token);y(P)}catch(P){console.error("Error fetching videos:",P),S(`Failed to load videos: ${P instanceof Error?P.message:"Unknown error"}`)}finally{L(!1)}},U=P=>{p(P),s==null||s(P)},F=P=>{P.owner&&P.permlink&&m(`/video/${P.owner}/${P.permlink}`)},h=P=>{switch(P.toLowerCase()){case"published":return"bg-green-500";case"encoding":case"encoding_queued":return"bg-orange-500";case"uploaded":return"bg-blue-500";case"publish_manual":return"bg-purple-500";default:return"bg-gray-500"}},T=["ipfs_pinning","ipfs_pinning_failed","encoding","encoding_failed","encoding_ipfs"],O=(P,$)=>{if(P.length===0){let E="";switch($){case"publishNow":E="No videos ready to publish.";break;case"myVideos":E="No published videos found.";break;case"encoding":E="No videos currently encoding.";break}return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(b.Video,{className:"w-16 h-16 text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-center",children:E})]})}return e.jsx("div",{className:"space-y-3 w-full",children:P.map((E,G)=>{const R=E.thumbnail||"",B=E.title||"No Title",z=E.permlink||"",se=E.owner||(r==null?void 0:r.username)||"",ee=E.id||"",he=T.includes(E.status||"");return e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-3 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("img",{src:xe(R)||`https://images.hive.blog/u/${r==null?void 0:r.username}/avatar`,alt:B,className:"w-24 h-16 rounded-lg object-cover",onError:re=>{re.target.src=`https://images.hive.blog/u/${r==null?void 0:r.username}/avatar`}}),T.includes(E.status||"")?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 rounded-lg",children:e.jsx(b.Ban,{className:"w-6 h-6 text-red-500"})}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20 opacity-0 hover:opacity-100 transition-opacity cursor-pointer rounded-lg",onClick:()=>F(E),children:e.jsx(b.Play,{className:"w-6 h-6 text-white"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-sm cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>F(E),style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:B}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 text-xs mt-1",children:["By ",se]}),E.status&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:`inline-block px-2 py-1 rounded-full text-xs font-semibold text-white ${h(E.status)}`,children:E.status.toUpperCase()})})]}),he?e.jsx("div",{className:"flex-shrink-0 pl-2",children:e.jsx(b.Ban,{className:"w-5 h-5 text-red-500"})}):e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[$==="publishNow"&&g&&e.jsx("button",{onClick:()=>t==null?void 0:t(se,z),className:"bg-green-600 hover:bg-green-700 text-white text-xs px-3 py-1 rounded-md transition-colors",children:"Publish"}),$==="myVideos"&&e.jsx("button",{onClick:()=>n?n(se,z):F(E),className:"bg-blue-600 hover:bg-blue-700 text-white text-xs px-3 py-1 rounded-md transition-colors",children:"View"}),d&&e.jsx("button",{onClick:()=>o==null?void 0:o(ee),className:"p-1 h-6 w-6 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(b.MoreVertical,{className:"w-4 h-4"})})]})]})},`${ee}-${G}`)})})};return r?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[l&&e.jsxs("button",{onClick:u,className:"flex items-center justify-center mr-4 my-2 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(b.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${r.username}/avatar`,alt:r.username,className:"w-12 h-12 md:w-16 md:h-16 rounded-full object-cover border-2 border-gray-200 dark:border-gray-700",onError:P=>{P.target.src=`https://ui-avatars.com/api/?name=${r.username}&background=random&size=64`}}),e.jsx("div",{children:e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white",children:r.username})})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:D,className:"p-2 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(b.RefreshCw,{className:"w-5 h-5"})})})]}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-hide",children:[e.jsxs("button",{onClick:()=>U(0),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${c===0?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(b.Upload,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Publish Now"}),e.jsx("span",{className:"sm:hidden",children:"Publish"}),I.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:I.length})]}),e.jsxs("button",{onClick:()=>U(1),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${c===1?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(b.Video,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"My Videos"}),e.jsx("span",{className:"sm:hidden",children:"Videos"}),k.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:k.length})]}),e.jsxs("button",{onClick:()=>U(2),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${c===2?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(b.Hourglass,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Encoding"}),e.jsx("span",{className:"sm:hidden",children:"Encoding"}),j.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:j.length})]})]})})]}),e.jsx("div",{className:"py-4 md:py-6 w-full",children:f?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):N?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center mb-4",children:e.jsx(b.Info,{className:"w-8 h-8 text-red-600 dark:text-red-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load videos"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:N}),e.jsx("button",{onClick:D,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition-colors",children:"Retry"})]}):e.jsxs("div",{className:"space-y-6",children:[c===0&&O(I,"publishNow"),c===1&&O(k,"myVideos"),c===2&&O(j,"encoding")]})})]}):e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please login to view your account"})})};class ht{constructor(){Be(this,"HIVE_API_URL","https://api.hive.blog")}async getProfile(s){const t={jsonrpc:"2.0",method:"bridge.get_profile",params:{account:s},id:1},n=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}async getFollowers(s){const t={jsonrpc:"2.0",method:"condenser_api.get_followers",params:[s,null,"blog"],id:1},n=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return(await n.json()).result}async getFollowing(s){const t={jsonrpc:"2.0",method:"condenser_api.get_following",params:[s,null,"blog"],id:1},n=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return(await n.json()).result}userAvatar(s){return`https://images.hive.blog/u/${s}/avatar`}}const ge=new ht,Nr=({username:r,onSelectUser:s})=>{const[t,n]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const m=await ge.getFollowers(r);n(m)}catch(m){g(m instanceof Error?m.message:"Failed to load followers")}finally{u(!1)}};return i.useEffect(()=>{d()},[r]),o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading followers..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load followers"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.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:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user has no followers."})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((m,c)=>e.jsx("div",{onClick:()=>s&&s(m.follower),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
98
+ transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:fe.userOwnerThumb(y),alt:y,className:"w-12 h-12 rounded-full object-cover",onError:C=>{C.target.src=`https://ui-avatars.com/api/?name=${y}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",y]}),g&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:g})]})]})},`${y}-${v}`)})})})},St=({communityId:r,onSelectCommunityMember:s})=>{const[t,a]=d.useState([]),[o,i]=d.useState(!0),[l,u]=d.useState(!1),[c,h]=d.useState(!0),[m,x]=d.useState(null),[v,y]=d.useState(null),g=100,C=d.useCallback(async(k=!1)=>{if(!(l&&!k))try{k?(i(!0),y(null),a([]),x(null),h(!0)):u(!0);const S=await fe.getCommunitySubscribers(r,g,k?void 0:m||void 0);S.length===0?h(!1):(a(w=>{if(k)return S;const I=new Set(w.map(M=>M.username)),_=S.filter(M=>!I.has(M.username));return[...w,..._]}),S.length>0&&x(S[S.length-1].username),h(S.length===g))}catch(S){y(S instanceof Error?S.message:"Failed to load members")}finally{i(!1),u(!1)}},[r,l,m]);return d.useEffect(()=>{C(!0)},[r]),d.useEffect(()=>{const k=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!l&&!o&&c&&C()};return window.addEventListener("scroll",k),()=>window.removeEventListener("scroll",k)},[C,l,o,c]),o&&t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading members..."]})}):v&&t.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load members"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:v}),e.jsxs("button",{onClick:()=>C(!0),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:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No community members found"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((k,S)=>e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors cursor-pointer",onClick:()=>s==null?void 0:s(k.username),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:fe.userOwnerThumb(k.username),alt:k.username,className:"w-12 h-12 rounded-full object-cover",onError:w=>{w.target.src=`https://ui-avatars.com/api/?name=${k.username}&background=random`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",k.username]}),k.role&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:k.role})]})]})},`${k.username}-${S}`))}),c&&e.jsx("div",{className:"flex justify-center pt-4",children:l?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more members..."]}):e.jsx("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:"Load More Members"})})]})},yr=({communityId:r,onVideoClick:s,onAuthorClick:t,onBack:a,onclickAboutTab:o,onclickTeamTab:i,onclickMemberTab:l,onShare:u,onFavourite:c,onRss:h,onMoreVertical:m,showMoreVertical:x=!0})=>{const v=ct.useNavigate(),[y,g]=d.useState("videos"),[C,k]=d.useState(null),[S,w]=d.useState(!1),[I,_]=d.useState(!0);d.useEffect(()=>{(async()=>{try{_(!0);const L=await fe.getCommunityDetails(r);k(L)}catch(L){console.error("Failed to fetch community details:",L)}finally{_(!1)}})()},[r]);const M=()=>{var L;const V=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:((L=C==null?void 0:C.result)==null?void 0:L.title)||r,url:V}):navigator.clipboard.writeText(V)},D=()=>{window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},$=V=>{v(`/user/${V}`)};if(I)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-32 mb-6"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-48"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"})]})]}),e.jsx("div",{className:"flex gap-2",children:Array.from({length:4}).map((V,L)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},L))})]})]})});const f=C==null?void 0:C.result;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:a,className:"flex items-center justify-center mr-4 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(j.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[e.jsx("img",{src:fe.userOwnerThumb(r),alt:(f==null?void 0:f.title)||r,className:"w-16 h-16 rounded-full object-cover",onError:V=>{V.target.src=`https://images.hive.blog/u/${(f==null?void 0:f.title)||r}/avatar`}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:(f==null?void 0:f.title)||r}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:(f==null?void 0:f.about)||"Community description"}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[((f==null?void 0:f.subscribers)||0).toLocaleString()," members"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Calendar,{className:"w-4 h-4"}),e.jsxs("span",{children:["Created"," ",f!=null&&f.created_at?new Date(f.created_at).getFullYear():"Unknown"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{id:r,toastType:"community",onAdd:(V,L)=>console.log("Added:",V,L),onRemove:(V,L)=>console.log("Removed:",V,L),onFavourite:c}),e.jsx("button",{onClick:h||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:e.jsx(j.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:u||M,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:e.jsx(j.Share2,{className:"w-4 h-4"})}),x&&e.jsx("button",{onClick:m||(()=>{}),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:e.jsx(j.MoreVertical,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-4 w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[e.jsx("button",{onClick:()=>g("videos"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="videos"?"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:"Videos"}),e.jsx("button",{onClick:()=>o?o():g("about"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="about"?"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:"About"}),e.jsx("button",{onClick:()=>i?i():g("team"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="team"?"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:"Team"}),e.jsx("button",{onClick:()=>l?l():g("members"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${y==="members"?"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:"Members"})]}),e.jsxs("div",{className:"mt-6",children:[y==="videos"&&e.jsx(Pe,{feedType:ee.COMMUNITY,communityId:r,onVideoClick:s,onAuthorClick:t}),y==="about"&&!o&&e.jsx(kt,{communityId:r}),y==="team"&&!i&&e.jsx(_t,{communityId:r,onSelectTeamMember:$}),y==="members"&&!l&&e.jsx(St,{communityId:r,onSelectCommunityMember:$})]})]})]})},vr=({currentUser:r,onTabChanged:s,onPublish:t,onViewMyVideo:a,onMoreOptions:o,onTapBackButton:i,shouldShowBackButton:l=!0,shouldShowPublishButton:u=!1,shouldShowMoreOptionsButton:c=!1})=>{const h=ct.useNavigate(),[m,x]=d.useState(0),[v,y]=d.useState([]),[g,C]=d.useState(!0),[k,S]=d.useState(null),w=v.filter(P=>["encoding","uploaded","encoding_queued","encoding_preparing","ipfs_pinning","ipfs_pinning_failed","encoding_failed","encoding_ipfs"].includes(P.status||"")),I=v.filter(P=>P.status==="publish_manual"),_=v.filter(P=>P.status==="published");d.useEffect(()=>{r!=null&&r.token&&M()},[r]);const M=async()=>{if(!(r!=null&&r.token)){S("No authentication token provided"),C(!1);return}C(!0),S(null);try{const P=await se.getMyVideos(r.token);y(P)}catch(P){console.error("Error fetching videos:",P),S(`Failed to load videos: ${P instanceof Error?P.message:"Unknown error"}`)}finally{C(!1)}},D=P=>{x(P),s==null||s(P)},$=P=>{P.owner&&P.permlink&&h(`/video/${P.owner}/${P.permlink}`)},f=P=>{switch(P.toLowerCase()){case"published":return"bg-green-500";case"encoding":case"encoding_queued":return"bg-orange-500";case"uploaded":return"bg-blue-500";case"publish_manual":return"bg-purple-500";default:return"bg-gray-500"}},V=["ipfs_pinning","ipfs_pinning_failed","encoding","encoding_failed","encoding_ipfs"],L=(P,T)=>{if(P.length===0){let E="";switch(T){case"publishNow":E="No videos ready to publish.";break;case"myVideos":E="No published videos found.";break;case"encoding":E="No videos currently encoding.";break}return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(j.Video,{className:"w-16 h-16 text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-center",children:E})]})}return e.jsx("div",{className:"space-y-3 w-full",children:P.map((E,J)=>{const re=E.thumbnail||"",B=E.title||"No Title",z=E.permlink||"",ae=E.owner||(r==null?void 0:r.username)||"",p=E.id||"",te=V.includes(E.status||"");return e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-3 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("img",{src:ve(re)||`https://images.hive.blog/u/${r==null?void 0:r.username}/avatar`,alt:B,className:"w-24 h-16 rounded-lg object-cover",onError:R=>{R.target.src=`https://images.hive.blog/u/${r==null?void 0:r.username}/avatar`}}),V.includes(E.status||"")?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 rounded-lg",children:e.jsx(j.Ban,{className:"w-6 h-6 text-red-500"})}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20 opacity-0 hover:opacity-100 transition-opacity cursor-pointer rounded-lg",onClick:()=>$(E),children:e.jsx(j.Play,{className:"w-6 h-6 text-white"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-sm cursor-pointer hover:text-blue-600 dark:hover:text-blue-400",onClick:()=>$(E),style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:B}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 text-xs mt-1",children:["By ",ae]}),E.status&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:`inline-block px-2 py-1 rounded-full text-xs font-semibold text-white ${f(E.status)}`,children:E.status.toUpperCase()})})]}),te?e.jsx("div",{className:"flex-shrink-0 pl-2",children:e.jsx(j.Ban,{className:"w-5 h-5 text-red-500"})}):e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[T==="publishNow"&&u&&e.jsx("button",{onClick:()=>t==null?void 0:t(ae,z),className:"bg-green-600 hover:bg-green-700 text-white text-xs px-3 py-1 rounded-md transition-colors",children:"Publish"}),T==="myVideos"&&e.jsx("button",{onClick:()=>a?a(ae,z):$(E),className:"bg-blue-600 hover:bg-blue-700 text-white text-xs px-3 py-1 rounded-md transition-colors",children:"View"}),c&&e.jsx("button",{onClick:()=>o==null?void 0:o(p),className:"p-1 h-6 w-6 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(j.MoreVertical,{className:"w-4 h-4"})})]})]})},`${p}-${J}`)})})};return r?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[l&&e.jsxs("button",{onClick:i,className:"flex items-center justify-center mr-4 my-2 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(j.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:`https://images.hive.blog/u/${r.username}/avatar`,alt:r.username,className:"w-12 h-12 md:w-16 md:h-16 rounded-full object-cover border-2 border-gray-200 dark:border-gray-700",onError:P=>{P.target.src=`https://ui-avatars.com/api/?name=${r.username}&background=random&size=64`}}),e.jsx("div",{children:e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white",children:r.username})})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:M,className:"p-2 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(j.RefreshCw,{className:"w-5 h-5"})})})]}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-hide",children:[e.jsxs("button",{onClick:()=>D(0),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${m===0?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(j.Upload,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Publish Now"}),e.jsx("span",{className:"sm:hidden",children:"Publish"}),I.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:I.length})]}),e.jsxs("button",{onClick:()=>D(1),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${m===1?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(j.Video,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"My Videos"}),e.jsx("span",{className:"sm:hidden",children:"Videos"}),_.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:_.length})]}),e.jsxs("button",{onClick:()=>D(2),className:`flex items-center gap-2 px-4 md:px-6 py-3 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex-shrink-0 ${m===2?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(j.Hourglass,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Encoding"}),e.jsx("span",{className:"sm:hidden",children:"Encoding"}),w.length>0&&e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs px-2 py-1 rounded-full",children:w.length})]})]})})]}),e.jsx("div",{className:"py-4 md:py-6 w-full",children:g?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):k?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center mb-4",children:e.jsx(j.Info,{className:"w-8 h-8 text-red-600 dark:text-red-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load videos"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:k}),e.jsx("button",{onClick:M,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition-colors",children:"Retry"})]}):e.jsxs("div",{className:"space-y-6",children:[m===0&&L(I,"publishNow"),m===1&&L(_,"myVideos"),m===2&&L(w,"encoding")]})})]}):e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please login to view your account"})})};class jr{constructor(){Ye(this,"HIVE_API_URL","https://api.hive.blog")}async getProfile(s){const t={jsonrpc:"2.0",method:"bridge.get_profile",params:{account:s},id:1},a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return await a.json()}async getFollowers(s){const t={jsonrpc:"2.0",method:"condenser_api.get_followers",params:[s,null,"blog"],id:1},a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(await a.json()).result}async getFollowing(s){const t={jsonrpc:"2.0",method:"condenser_api.get_following",params:[s,null,"blog"],id:1},a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(await a.json()).result}async getAccounts(s){const t={jsonrpc:"2.0",method:"condenser_api.get_accounts",params:[s],id:1},a=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(await a.json()).result}async getDynamicGlobalProperties(){const s={jsonrpc:"2.0",method:"condenser_api.get_dynamic_global_properties",params:[],id:1},t=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return(await t.json()).result}async convertVestingSharesToHive(s){try{const t=await this.getDynamicGlobalProperties(),a=parseFloat(s.split(" ")[0]),o=parseFloat(t.total_vesting_shares.split(" ")[0]),i=parseFloat(t.total_vesting_fund_hive.split(" ")[0]);return(a*i/o).toFixed(3)}catch(t){return console.error("Error converting vesting shares:",t),"0"}}async getFeedHistory(){const s={jsonrpc:"2.0",method:"condenser_api.get_feed_history",params:[],id:1},t=await fetch(this.HIVE_API_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return(await t.json()).result}async getVoteValue(s,t=1e4){try{const a=await this.getAccounts([s]);if(a.length===0)throw new Error("Account not found!");const o=a[0],i=await this.getDynamicGlobalProperties(),l=await this.getFeedHistory(),u=parseFloat(o.vesting_shares)+parseFloat(o.received_vesting_shares)-parseFloat(o.delegated_vesting_shares)-parseFloat(o.vesting_withdraw_rate),c=Math.floor(Date.now()/1e3)-o.voting_manabar.last_update_time,h=u*1e6/4;let m=parseFloat(o.voting_manabar.current_mana.toString())+c*h/(5*60*60*24);m>h&&(m=h);const x=m*100/h,v=o.vesting_shares||"0 VESTS",y=parseFloat(v.toString().split(" ")[0]),g=i.total_vesting_shares||"0 VESTS",C=parseFloat(g.toString().split(" ")[0]),k=t/1e4,S=x*k/100,w=i.vote_power_reserve_rate*(5*60*60*24)/(60*60*24),I=S*h/100,_=parseFloat(i.recent_claims||"0"),M=i.reward_balance||"0 HIVE",D=parseFloat(M.toString().split(" ")[0]),$=i.current_supply||"0 HIVE",f=parseFloat($.toString().split(" ")[0]),V=i.current_sbd_supply||"0 HBD",L=parseFloat(V.toString().split(" ")[0]),P=D/_*(y/C)*(I/h)*f,T=l==null?void 0:l.current_median_history;if(!T||!T.base)return"0.00";const E=parseFloat(T.base.toString().split(" ")[0]);return(P*E).toFixed(2)}catch(a){return console.error("Error calculating vote value:",a),"0.00"}}userAvatar(s){return`https://images.hive.blog/u/${s}/avatar`}}const pe=new jr,Et=({username:r,onSelectUser:s})=>{const[t,a]=d.useState([]),[o,i]=d.useState(!0),[l,u]=d.useState(null),c=async()=>{try{i(!0),u(null);const h=await pe.getFollowers(r);a(h)}catch(h){u(h instanceof Error?h.message:"Failed to load followers")}finally{i(!1)}};return d.useEffect(()=>{c()},[r]),o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading followers..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load followers"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.jsxs("button",{onClick:c,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user has no followers."})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((h,m)=>e.jsx("div",{onClick:()=>s&&s(h.follower),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
99
99
  rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700
100
- transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:ge.userAvatar(m.follower),alt:m.follower,className:"w-12 h-12 rounded-full object-cover",onError:p=>{p.target.src=`https://ui-avatars.com/api/?name=${m.follower}&background=random`}}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",m.follower]})})]})},`${m.follower}-${c}`))})})},kr=({username:r,onSelectUser:s})=>{const[t,n]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const m=await ge.getFollowing(r);n(m)}catch(m){g(m instanceof Error?m.message:"Failed to load following list")}finally{u(!1)}};return i.useEffect(()=>{d()},[r]),o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading following list..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load following list"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.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:[e.jsx(b.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user is not following anyone."})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((m,c)=>e.jsx("div",{onClick:()=>s&&s(m.following),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
100
+ transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:pe.userAvatar(h.follower),alt:h.follower,className:"w-12 h-12 rounded-full object-cover",onError:x=>{x.target.src=`https://ui-avatars.com/api/?name=${h.follower}&background=random`}}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",h.follower]})})]})},`${h.follower}-${m}`))})})},Ct=({username:r,onSelectUser:s})=>{const[t,a]=d.useState([]),[o,i]=d.useState(!0),[l,u]=d.useState(null),c=async()=>{try{i(!0),u(null);const h=await pe.getFollowing(r);a(h)}catch(h){u(h instanceof Error?h.message:"Failed to load following list")}finally{i(!1)}};return d.useEffect(()=>{c()},[r]),o?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading following list..."]})}):l?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load following list"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:l}),e.jsxs("button",{onClick:c,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})}):t.length===0?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"This user is not following anyone."})}):e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map((h,m)=>e.jsx("div",{onClick:()=>s&&s(h.following),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700
101
101
  rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700
102
- transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:ge.userAvatar(m.following),alt:m.following,className:"w-12 h-12 rounded-full object-cover",onError:p=>{p.target.src=`https://ui-avatars.com/api/?name=${m.following}&background=random`}}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",m.following]})})]})},`${m.following}-${c}`))})})},Sr=({username:r})=>{var v,y,f,L,N,S;const[s,t]=i.useState(null),[n,o]=i.useState(!0),[u,l]=i.useState(null),g=async()=>{try{o(!0),l(null);const j=await ge.getProfile(r);t(j)}catch(j){l(j instanceof Error?j.message:"Failed to load user details")}finally{o(!1)}};i.useEffect(()=>{g()},[r]);const d=j=>{try{return new Date(j).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return j}},m=j=>j.replace(/<[^>]*>/g,"");if(n)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading user details..."]})});if(u)return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load user details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:u}),e.jsxs("button",{onClick:g,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:[e.jsx(b.RefreshCw,{className:"w-4 h-4"}),"Try Again"]})]})});if(!(s!=null&&s.result))return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No user details available"})});const c=s.result,p=(v=c.metadata)==null?void 0:v.profile;return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[(p==null?void 0:p.about)&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"About"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:m(p.about)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Location"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:(p==null?void 0:p.location)||"Not specified"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Website"}),e.jsx("a",{href:p==null?void 0:p.website,target:"_blank",rel:"noopener noreferrer",className:"text-lg font-semibold text-blue-500 hover:underline",children:(p==null?void 0:p.website)||"Not specified"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Joined"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.created?d(c.created):"Unknown"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Followers"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((f=(y=c.stats)==null?void 0:y.followers)==null?void 0:f.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Following"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((N=(L=c.stats)==null?void 0:L.following)==null?void 0:N.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Post Count"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((S=c.post_count)==null?void 0:S.toLocaleString())||"0"})]})]})]})})},ft=({username:r,onVideoClick:s,onAuthorClick:t,onBack:n,onClickUserInfoTab:o,onClickFollowersTab:u,onClickFollowingTab:l,onBookmarkToggle:g,onRss:d,onShare:m,onMoreMenu:c,showMoreMenu:p=!1})=>{var T,O,P;const[v,y]=i.useState("videos"),[f,L]=i.useState(null),[N,S]=i.useState(!1),[j,I]=i.useState(!0);i.useEffect(()=>{(async()=>{try{I(!0);const E=await ge.getProfile(r);L(E)}catch(E){console.error("Failed to fetch user details:",E)}finally{I(!1)}})()},[r]);const k=()=>{var $;if(m)m(r);else{const E=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:(($=f==null?void 0:f.result)==null?void 0:$.name)||r,url:E}):navigator.clipboard.writeText(E)}},D=()=>{d?d(r):window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},U=$=>{t($)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-32 mb-6"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-48"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"})]})]}),e.jsx("div",{className:"flex gap-2",children:Array.from({length:4}).map(($,E)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},E))})]})]})});const F=f==null?void 0:f.result,h=(T=F==null?void 0:F.metadata)==null?void 0:T.profile;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:n,className:"flex items-center justify-center mr-4 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(b.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[e.jsx("img",{src:h.cover_image||ge.userAvatar(r),alt:"Cover",className:"w-full h-48 object-cover",onError:$=>{$.target.src=ge.userAvatar(r)}}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[e.jsx("img",{src:h==null?void 0:h.profile_image,alt:h==null?void 0:h.name,className:"w-24 h-24 rounded-full object-cover border-4 border-white dark:border-gray-800 -mt-16",onError:$=>{$.target.src=ge.userAvatar(r)}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:(h==null?void 0:h.name)||r}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:(h==null?void 0:h.about)||"No description available"}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((O=F==null?void 0:F.stats)==null?void 0:O.followers)||0).toLocaleString()," Followers"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((P=F==null?void 0:F.stats)==null?void 0:P.following)||0).toLocaleString()," Following"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(b.Calendar,{className:"w-4 h-4"}),e.jsxs("span",{children:["Joined"," ",F!=null&&F.created?new Date(F.created).getFullYear():"Unknown"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{id:r,toastType:"user",onAdd:($,E)=>{g?g($,!0):console.log("Added:",$,E)},onRemove:($,E)=>{g?g($,!1):console.log("Removed:",$,E)}}),e.jsx("button",{onClick:D,className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(b.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:k,className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(b.Share2,{className:"w-4 h-4"})}),p&&e.jsx("button",{onClick:()=>{c&&c(r)},className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(b.MoreVertical,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[{key:"videos",label:"Videos"},{key:"about",label:"User Info",callback:o},{key:"followers",label:"Followers",callback:u},{key:"following",label:"Following",callback:l}].map(($,E)=>e.jsx("button",{onClick:()=>{$.callback?$.callback():y($.key)},className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${v===$.key?"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:$.label},$.key))}),e.jsxs("div",{className:"mt-6",children:[v==="videos"&&e.jsx($e,{feedType:X.USER,username:r,onVideoClick:s,onAuthorClick:t}),v==="about"&&e.jsx(Sr,{username:r}),v==="followers"&&e.jsx(Nr,{username:r,onSelectUser:U}),v==="following"&&e.jsx(kr,{username:r,onSelectUser:U})]})]})]})},Qe=768;function xt(){const[r,s]=Oe.useState(void 0);return Oe.useEffect(()=>{const t=window.matchMedia(`(max-width: ${Qe-1}px)`),n=()=>{s(window.innerWidth<Qe)};return t.addEventListener("change",n),s(window.innerWidth<Qe),()=>t.removeEventListener("change",n)},[]),!!r}const pt=1,bt=1e6;let Xe=0;function yt(){return Xe=(Xe+1)%Number.MAX_SAFE_INTEGER,Xe.toString()}const Ze=new Map,Er=r=>{if(Ze.has(r))return;const s=setTimeout(()=>{Ze.delete(r),Ce({type:"REMOVE_TOAST",toastId:r})},bt);Ze.set(r,s)},_r=(r,s)=>{switch(s.type){case"ADD_TOAST":return{...r,toasts:[s.toast,...r.toasts].slice(0,pt)};case"UPDATE_TOAST":return{...r,toasts:r.toasts.map(t=>t.id===s.toast.id?{...t,...s.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=s;return t?Er(t):r.toasts.forEach(n=>{Er(n.id)}),{...r,toasts:r.toasts.map(n=>n.id===t||t===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...r,toasts:[]}:{...r,toasts:r.toasts.filter(t=>t.id!==s.toastId)}}},Ae=[];let Me={toasts:[]};function Ce(r){Me=_r(Me,r),Ae.forEach(s=>{s(Me)})}function Cr({...r}){const s=yt(),t=o=>Ce({type:"UPDATE_TOAST",toast:{...o,id:s}}),n=()=>Ce({type:"DISMISS_TOAST",toastId:s});return Ce({type:"ADD_TOAST",toast:{...r,id:s,open:!0,onOpenChange:o=>{o||n()}}}),{id:s,dismiss:n,update:t}}function vt(){const[r,s]=Oe.useState(Me);return Oe.useEffect(()=>(Ae.push(s),()=>{const t=Ae.indexOf(s);t>-1&&Ae.splice(t,1)}),[r]),{...r,toast:Cr,dismiss:t=>Ce({type:"DISMISS_TOAST",toastId:t})}}_.ApiVideoFeedType=X,_.CommentsModal=mr,_.CommunitiesList=ut,_.CommunityAbout=vr,_.CommunityDetail=mt,_.CommunityMembers=wr,_.CommunityTeam=jr,_.DescriptionModal=hr,_.FavouriteWidget=Ke,_.Modal=Fe,_.UpvoteListModal=gr,_.UserAccount=gt,_.UserFollowers=Nr,_.UserFollowing=kr,_.UserInfo=Sr,_.UserProfilePage=ft,_.VideoCard=cr,_.VideoDetail=Yr,_.VideoFeed=$e,_.VideoInfo=ur,_.Wallet=ct,_.apiService=Z,_.reducer=_r,_.server=ue,_.toast=Cr,_.useIsMobile=xt,_.useToast=vt,_.useWalletStore=yr,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
102
+ transition-colors cursor-pointer`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:pe.userAvatar(h.following),alt:h.following,className:"w-12 h-12 rounded-full object-cover",onError:x=>{x.target.src=`https://ui-avatars.com/api/?name=${h.following}&background=random`}}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:["@",h.following]})})]})},`${h.following}-${m}`))})})},Tt=({username:r})=>{var v,y,g,C,k,S;const[s,t]=d.useState(null),[a,o]=d.useState(!0),[i,l]=d.useState(null),u=async()=>{try{o(!0),l(null);const w=await pe.getProfile(r);t(w)}catch(w){l(w instanceof Error?w.message:"Failed to load user details")}finally{o(!1)}};d.useEffect(()=>{u()},[r]);const c=w=>{try{return new Date(w).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return w}},h=w=>w.replace(/<[^>]*>/g,"");if(a)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading user details..."]})});if(i)return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Failed to load user details"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:i}),e.jsxs("button",{onClick:u,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:[e.jsx(j.RefreshCw,{className:"w-4 h-4"}),"Try Again"]})]})});if(!(s!=null&&s.result))return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No user details available"})});const m=s.result,x=(v=m.metadata)==null?void 0:v.profile;return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[(x==null?void 0:x.about)&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-3",children:"About"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:h(x.about)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Location"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:(x==null?void 0:x.location)||"Not specified"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Website"}),e.jsx("a",{href:x==null?void 0:x.website,target:"_blank",rel:"noopener noreferrer",className:"text-lg font-semibold text-blue-500 hover:underline",children:(x==null?void 0:x.website)||"Not specified"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Joined"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m.created?c(m.created):"Unknown"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Followers"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((g=(y=m.stats)==null?void 0:y.followers)==null?void 0:g.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Following"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((k=(C=m.stats)==null?void 0:C.following)==null?void 0:k.toLocaleString())||"0"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Post Count"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:((S=m.post_count)==null?void 0:S.toLocaleString())||"0"})]})]})]})})},wr=({username:r,onVideoClick:s,onAuthorClick:t,onBack:a,onClickUserInfoTab:o,onClickFollowersTab:i,onClickFollowingTab:l,onBookmarkToggle:u,onRss:c,onShare:h,onMoreMenu:m,showMoreMenu:x=!1})=>{var V,L,P;const[v,y]=d.useState("videos"),[g,C]=d.useState(null),[k,S]=d.useState(!1),[w,I]=d.useState(!0);d.useEffect(()=>{(async()=>{try{I(!0);const E=await pe.getProfile(r);C(E)}catch(E){console.error("Failed to fetch user details:",E)}finally{I(!1)}})()},[r]);const _=()=>{var T;if(h)h(r);else{const E=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:((T=g==null?void 0:g.result)==null?void 0:T.name)||r,url:E}):navigator.clipboard.writeText(E)}},M=()=>{c?c(r):window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},D=T=>{t(T)};if(w)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-32 mb-6"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-48"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"})]})]}),e.jsx("div",{className:"flex gap-2",children:Array.from({length:4}).map((T,E)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},E))})]})]})});const $=g==null?void 0:g.result,f=(V=$==null?void 0:$.metadata)==null?void 0:V.profile;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:a,className:"flex items-center justify-center mr-4 px-2 text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-full",children:[e.jsx(j.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[e.jsx("img",{src:f.cover_image||pe.userAvatar(r),alt:"Cover",className:"w-full h-48 object-cover",onError:T=>{T.target.src=pe.userAvatar(r)}}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[e.jsx("img",{src:f==null?void 0:f.profile_image,alt:f==null?void 0:f.name,className:"w-24 h-24 rounded-full object-cover border-4 border-white dark:border-gray-800 -mt-16",onError:T=>{T.target.src=pe.userAvatar(r)}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:(f==null?void 0:f.name)||r}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:(f==null?void 0:f.about)||"No description available"}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((L=$==null?void 0:$.stats)==null?void 0:L.followers)||0).toLocaleString()," Followers"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((P=$==null?void 0:$.stats)==null?void 0:P.following)||0).toLocaleString()," Following"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(j.Calendar,{className:"w-4 h-4"}),e.jsxs("span",{children:["Joined"," ",$!=null&&$.created?new Date($.created).getFullYear():"Unknown"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{id:r,toastType:"user",onAdd:(T,E)=>{u?u(T,!0):console.log("Added:",T,E)},onRemove:(T,E)=>{u?u(T,!1):console.log("Removed:",T,E)}}),e.jsx("button",{onClick:M,className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(j.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(j.Share2,{className:"w-4 h-4"})}),x&&e.jsx("button",{onClick:()=>{m&&m(r)},className:"p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700",children:e.jsx(j.MoreVertical,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[{key:"videos",label:"Videos"},{key:"about",label:"User Info",callback:o},{key:"followers",label:"Followers",callback:i},{key:"following",label:"Following",callback:l}].map((T,E)=>e.jsx("button",{onClick:()=>{T.callback?T.callback():y(T.key)},className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${v===T.key?"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:T.label},T.key))}),e.jsxs("div",{className:"mt-6",children:[v==="videos"&&e.jsx(Pe,{feedType:ee.USER,username:r,onVideoClick:s,onAuthorClick:t}),v==="about"&&e.jsx(Tt,{username:r}),v==="followers"&&e.jsx(Et,{username:r,onSelectUser:D}),v==="following"&&e.jsx(Ct,{username:r,onSelectUser:D})]})]})]})},et=768;function Nr(){const[r,s]=Le.useState(void 0);return Le.useEffect(()=>{const t=window.matchMedia(`(max-width: ${et-1}px)`),a=()=>{s(window.innerWidth<et)};return t.addEventListener("change",a),s(window.innerWidth<et),()=>t.removeEventListener("change",a)},[]),!!r}const kr=1,_r=1e6;let tt=0;function Sr(){return tt=(tt+1)%Number.MAX_SAFE_INTEGER,tt.toString()}const rt=new Map,Vt=r=>{if(rt.has(r))return;const s=setTimeout(()=>{rt.delete(r),Ve({type:"REMOVE_TOAST",toastId:r})},_r);rt.set(r,s)},Ot=(r,s)=>{switch(s.type){case"ADD_TOAST":return{...r,toasts:[s.toast,...r.toasts].slice(0,kr)};case"UPDATE_TOAST":return{...r,toasts:r.toasts.map(t=>t.id===s.toast.id?{...t,...s.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=s;return t?Vt(t):r.toasts.forEach(a=>{Vt(a.id)}),{...r,toasts:r.toasts.map(a=>a.id===t||t===void 0?{...a,open:!1}:a)}}case"REMOVE_TOAST":return s.toastId===void 0?{...r,toasts:[]}:{...r,toasts:r.toasts.filter(t=>t.id!==s.toastId)}}},Ue=[];let He={toasts:[]};function Ve(r){He=Ot(He,r),Ue.forEach(s=>{s(He)})}function Lt({...r}){const s=Sr(),t=o=>Ve({type:"UPDATE_TOAST",toast:{...o,id:s}}),a=()=>Ve({type:"DISMISS_TOAST",toastId:s});return Ve({type:"ADD_TOAST",toast:{...r,id:s,open:!0,onOpenChange:o=>{o||a()}}}),{id:s,dismiss:a,update:t}}function Er(){const[r,s]=Le.useState(He);return Le.useEffect(()=>(Ue.push(s),()=>{const t=Ue.indexOf(s);t>-1&&Ue.splice(t,1)}),[r]),{...r,toast:Lt,dismiss:t=>Ve({type:"DISMISS_TOAST",toastId:t})}}O.ApiVideoFeedType=ee,O.CommentsModal=ft,O.CommunitiesList=br,O.CommunityAbout=kt,O.CommunityDetail=yr,O.CommunityMembers=St,O.CommunityTeam=_t,O.DescriptionModal=bt,O.FavouriteWidget=Ze,O.ListOfWitnesses=fr,O.Modal=Me,O.UpvoteListModal=pt,O.UserAccount=vr,O.UserFollowers=Et,O.UserFollowing=Ct,O.UserInfo=Tt,O.UserProfilePage=wr,O.VideoCard=ht,O.VideoDetail=Kt,O.VideoFeed=Pe,O.VideoInfo=xt,O.Wallet=mr,O.apiService=se,O.reducer=Ot,O.server=xe,O.toast=Lt,O.useIsMobile=Nr,O.useToast=Er,O.useWalletStore=Nt,O.witnessService=me,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});