hive-react-kit 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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("react-router-dom"),require("hls.js"),require("zustand")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","date-fns","@hiveio/dhive","react-router-dom","hls.js","zustand"],i):(_=typeof globalThis<"u"?globalThis:_||self,i(_.HiveReactKit={},_.React,_.LucideReact,_.dateFns,_.Dhive,_.ReactRouterDOM,_.Hls,_.Zustand))})(this,function(_,i,p,Me,Ze,ve,fe,Dr){"use strict";var Ht=Object.defineProperty;var Bt=(_,i,p)=>i in _?Ht(_,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):_[i]=p;var De=(_,i,p)=>Bt(_,typeof i!="symbol"?i+"":i,p);function Re(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 Se=Re(i),Mr=Re(Ze);var Ue={exports:{}},je={};/**
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={};/**
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 er;function Ur(){if(er)return je;er=1;var r=i,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,u={key:!0,ref:!0,__self:!0,__source:!0};function l(g,d,m){var c,x={},j=null,N=null;m!==void 0&&(j=""+m),d.key!==void 0&&(j=""+d.key),d.ref!==void 0&&(N=d.ref);for(c in d)a.call(d,c)&&!u.hasOwnProperty(c)&&(x[c]=d[c]);if(g&&g.defaultProps)for(c in d=g.defaultProps,d)x[c]===void 0&&(x[c]=d[c]);return{$$typeof:s,type:g,key:j,ref:N,props:x,_owner:o.current}}return je.Fragment=t,je.jsx=l,je.jsxs=l,je}var we={};/**
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={};/**
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 rr;function Ir(){return rr||(rr=1,process.env.NODE_ENV!=="production"&&function(){var r=i,s=Symbol.for("react.element"),t=Symbol.for("react.portal"),a=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"),x=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),S=Symbol.iterator,L="@@iterator";function b(n){if(n===null||typeof n!="object")return null;var h=S&&n[S]||n[L];return typeof h=="function"?h:null}var w=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(n){{for(var h=arguments.length,v=new Array(h>1?h-1:0),O=1;O<h;O++)v[O-1]=arguments[O];W("error",n,v)}}function W(n,h,v){{var O=w.ReactDebugCurrentFrame,U=O.getStackAddendum();U!==""&&(h+="%s",v=v.concat([U]));var I=v.map(function(D){return String(D)});I.unshift("Warning: "+h),Function.prototype.apply.call(console[n],console,I)}}var E=!1,C=!1,T=!1,G=!1,f=!1,F;F=Symbol.for("react.module.reference");function $(n){return!!(typeof n=="string"||typeof n=="function"||n===a||n===u||f||n===o||n===m||n===c||G||n===N||E||C||T||typeof n=="object"&&n!==null&&(n.$$typeof===j||n.$$typeof===x||n.$$typeof===l||n.$$typeof===g||n.$$typeof===d||n.$$typeof===F||n.getModuleId!==void 0))}function P(n,h,v){var O=n.displayName;if(O)return O;var U=h.displayName||h.name||"";return U!==""?v+"("+U+")":v}function X(n){return n.displayName||"Context"}function k(n){if(n==null)return null;if(typeof n.tag=="number"&&y("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 u:return"Profiler";case o:return"StrictMode";case m:return"Suspense";case c:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case g:var h=n;return X(h)+".Consumer";case l:var v=n;return X(v._context)+".Provider";case d:return P(n,n.render,"ForwardRef");case x:var O=n.displayName||null;return O!==null?O:k(n.type)||"Memo";case j:{var U=n,I=U._payload,D=U._init;try{return k(D(I))}catch{return null}}}return null}var V=Object.assign,M=0,H,B,J,K,ae,R,ue;function me(){}me.__reactDisabledLog=!0;function q(){{if(M===0){H=console.log,B=console.info,J=console.warn,K=console.error,ae=console.group,R=console.groupCollapsed,ue=console.groupEnd;var n={configurable:!0,enumerable:!0,value:me,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}M++}}function le(){{if(M--,M===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},n,{value:H}),info:V({},n,{value:B}),warn:V({},n,{value:J}),error:V({},n,{value:K}),group:V({},n,{value:ae}),groupCollapsed:V({},n,{value:R}),groupEnd:V({},n,{value:ue})})}M<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var te=w.ReactCurrentDispatcher,ce;function ge(n,h,v){{if(ce===void 0)try{throw Error()}catch(U){var O=U.stack.trim().match(/\n( *(at )?)/);ce=O&&O[1]||""}return`
18
- `+ce+n}}var pe=!1,Pe;{var pt=typeof WeakMap=="function"?WeakMap:Map;Pe=new pt}function wr(n,h){if(!n||pe)return"";{var v=Pe.get(n);if(v!==void 0)return v}var O;pe=!0;var U=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var I;I=te.current,te.current=null,q();try{if(h){var D=function(){throw Error()};if(Object.defineProperty(D.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(D,[])}catch(re){O=re}Reflect.construct(n,[],D)}else{try{D.call()}catch(re){O=re}n.call(D.prototype)}}else{try{throw Error()}catch(re){O=re}n()}}catch(re){if(re&&O&&typeof re.stack=="string"){for(var A=re.stack.split(`
19
- `),ee=O.stack.split(`
20
- `),z=A.length-1,Y=ee.length-1;z>=1&&Y>=0&&A[z]!==ee[Y];)Y--;for(;z>=1&&Y>=0;z--,Y--)if(A[z]!==ee[Y]){if(z!==1||Y!==1)do if(z--,Y--,Y<0||A[z]!==ee[Y]){var se=`
21
- `+A[z].replace(" at new "," at ");return n.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",n.displayName)),typeof n=="function"&&Pe.set(n,se),se}while(z>=1&&Y>=0);break}}}finally{pe=!1,te.current=I,le(),Error.prepareStackTrace=U}var ye=n?n.displayName||n.name:"",he=ye?ge(ye):"";return typeof n=="function"&&Pe.set(n,he),he}function bt(n,h,v){return wr(n,!1)}function yt(n){var h=n.prototype;return!!(h&&h.isReactComponent)}function Ve(n,h,v){if(n==null)return"";if(typeof n=="function")return wr(n,yt(n));if(typeof n=="string")return ge(n);switch(n){case m:return ge("Suspense");case c:return ge("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case d:return bt(n.render);case x:return Ve(n.type,h,v);case j:{var O=n,U=O._payload,I=O._init;try{return Ve(I(U),h,v)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,Nr={},kr=w.ReactDebugCurrentFrame;function Ae(n){if(n){var h=n._owner,v=Ve(n.type,n._source,h?h.type:null);kr.setExtraStackFrame(v)}else kr.setExtraStackFrame(null)}function vt(n,h,v,O,U){{var I=Function.call.bind(ke);for(var D in n)if(I(n,D)){var A=void 0;try{if(typeof n[D]!="function"){var ee=Error((O||"React class")+": "+v+" type `"+D+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[D]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ee.name="Invariant Violation",ee}A=n[D](h,D,O,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(z){A=z}A&&!(A instanceof Error)&&(Ae(U),y("%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).",O||"React class",v,D,typeof A),Ae(null)),A instanceof Error&&!(A.message in Nr)&&(Nr[A.message]=!0,Ae(U),y("Failed %s type: %s",v,A.message),Ae(null))}}}var jt=Array.isArray;function Je(n){return jt(n)}function wt(n){{var h=typeof Symbol=="function"&&Symbol.toStringTag,v=h&&n[Symbol.toStringTag]||n.constructor.name||"Object";return v}}function Nt(n){try{return Sr(n),!1}catch{return!0}}function Sr(n){return""+n}function Er(n){if(Nt(n))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wt(n)),Sr(n)}var Cr=w.ReactCurrentOwner,kt={key:!0,ref:!0,__self:!0,__source:!0},_r,Tr;function St(n){if(ke.call(n,"ref")){var h=Object.getOwnPropertyDescriptor(n,"ref").get;if(h&&h.isReactWarning)return!1}return n.ref!==void 0}function Et(n){if(ke.call(n,"key")){var h=Object.getOwnPropertyDescriptor(n,"key").get;if(h&&h.isReactWarning)return!1}return n.key!==void 0}function Ct(n,h){typeof n.ref=="string"&&Cr.current}function _t(n,h){{var v=function(){_r||(_r=!0,y("%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)",h))};v.isReactWarning=!0,Object.defineProperty(n,"key",{get:v,configurable:!0})}}function Tt(n,h){{var v=function(){Tr||(Tr=!0,y("%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)",h))};v.isReactWarning=!0,Object.defineProperty(n,"ref",{get:v,configurable:!0})}}var Ot=function(n,h,v,O,U,I,D){var A={$$typeof:s,type:n,key:h,ref:v,props:D,_owner:I};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:O}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:U}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function Lt(n,h,v,O,U){{var I,D={},A=null,ee=null;v!==void 0&&(Er(v),A=""+v),Et(h)&&(Er(h.key),A=""+h.key),St(h)&&(ee=h.ref,Ct(h,U));for(I in h)ke.call(h,I)&&!kt.hasOwnProperty(I)&&(D[I]=h[I]);if(n&&n.defaultProps){var z=n.defaultProps;for(I in z)D[I]===void 0&&(D[I]=z[I])}if(A||ee){var Y=typeof n=="function"?n.displayName||n.name||"Unknown":n;A&&_t(D,Y),ee&&Tt(D,Y)}return Ot(n,A,ee,U,O,Cr.current,D)}}var Ge=w.ReactCurrentOwner,Or=w.ReactDebugCurrentFrame;function be(n){if(n){var h=n._owner,v=Ve(n.type,n._source,h?h.type:null);Or.setExtraStackFrame(v)}else Or.setExtraStackFrame(null)}var Ke;Ke=!1;function Qe(n){return typeof n=="object"&&n!==null&&n.$$typeof===s}function Lr(){{if(Ge.current){var n=k(Ge.current.type);if(n)return`
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`
22
22
 
23
- Check the render method of \``+n+"`."}return""}}function $t(n){return""}var $r={};function Ft(n){{var h=Lr();if(!h){var v=typeof n=="string"?n:n.displayName||n.name;v&&(h=`
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=`
24
24
 
25
- Check the top-level render call using <`+v+">.")}return h}}function Fr(n,h){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var v=Ft(h);if($r[v])return;$r[v]=!0;var O="";n&&n._owner&&n._owner!==Ge.current&&(O=" It was passed a child from "+k(n._owner.type)+"."),be(n),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,O),be(null)}}function Pr(n,h){{if(typeof n!="object")return;if(Je(n))for(var v=0;v<n.length;v++){var O=n[v];Qe(O)&&Fr(O,h)}else if(Qe(n))n._store&&(n._store.validated=!0);else if(n){var U=b(n);if(typeof U=="function"&&U!==n.entries)for(var I=U.call(n),D;!(D=I.next()).done;)Qe(D.value)&&Fr(D.value,h)}}}function Pt(n){{var h=n.type;if(h==null||typeof h=="string")return;var v;if(typeof h=="function")v=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===d||h.$$typeof===x))v=h.propTypes;else return;if(v){var O=k(h);vt(v,n.props,"prop",O,n)}else if(h.PropTypes!==void 0&&!Ke){Ke=!0;var U=k(h);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",U||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(n){{for(var h=Object.keys(n.props),v=0;v<h.length;v++){var O=h[v];if(O!=="children"&&O!=="key"){be(n),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",O),be(null);break}}n.ref!==null&&(be(n),y("Invalid attribute `ref` supplied to `React.Fragment`."),be(null))}}var Vr={};function Ar(n,h,v,O,U,I){{var D=$(n);if(!D){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 ee=$t();ee?A+=ee:A+=Lr();var z;n===null?z="null":Je(n)?z="array":n!==void 0&&n.$$typeof===s?(z="<"+(k(n.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):z=typeof n,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",z,A)}var Y=Lt(n,h,v,U,I);if(Y==null)return Y;if(D){var se=h.children;if(se!==void 0)if(O)if(Je(se)){for(var ye=0;ye<se.length;ye++)Pr(se[ye],n);Object.freeze&&Object.freeze(se)}else y("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 Pr(se,n)}if(ke.call(h,"key")){var he=k(n),re=Object.keys(h).filter(function(Wt){return Wt!=="key"}),Xe=re.length>0?"{key: someKey, "+re.join(": ..., ")+": ...}":"{key: someKey}";if(!Vr[he+Xe]){var It=re.length>0?"{"+re.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
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:
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} />`,Xe,he,It,he),Vr[he+Xe]=!0}}return n===a?Vt(Y):Pt(Y),Y}}function At(n,h,v){return Ar(n,h,v,!0)}function Dt(n,h,v){return Ar(n,h,v,!1)}var Mt=Dt,Ut=At;we.Fragment=a,we.jsx=Mt,we.jsxs=Ut}()),we}process.env.NODE_ENV==="production"?Ue.exports=Ur():Ue.exports=Ir();var e=Ue.exports;const ne={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"},Ie=new Ze.Client(["https://api.hive.blog","https://api.syncad.com","https://api.deathwing.me"]);class Wr{constructor(){De(this,"commonFields",`
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",`
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 a=`${ne.graphQLServerUrl}/api/v2/graphql`;try{const g=await fetch(a,{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=`${ne.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 u=`${ne.domain}/mobile/vote`,l=await fetch(u,{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 g=await l.json();throw new Error(g.error||"Unknown API error")}}async handleComment({author:s,permlink:t,body:a,authToken:o}){const u=`${ne.domain}/mobile/comment`,l=await fetch(u,{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 g=await l.json();throw new Error(g.error||"Unknown API error")}}async getVideoDetails(s,t){const a=`${ne.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,u={limit:50,skip:0}){const{limit:l=50,skip:g=0}=u,d=`
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=`
59
59
  query ${s} {
60
60
  ${t}(
61
- spkvideo: { ${a} }
61
+ spkvideo: { ${n} }
62
62
  feedOptions: ${o}
63
63
  pagination: { limit: ${l}, skip: ${g} }
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=`${ne.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}" } }`:"{}",u=`
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=`
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 a,o;const s=`${ne.graphQLServerUrl}/api/v2/graphql`,t=`
79
+ `,l=await this.getGQLFeed("SearchFeed",u);return this.convertGQLItemsToThreeSpeakVideos(l)}async getTrendingTags(){var n,o;const s=`${ue.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=(a=l.data)==null?void 0:a.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,x,j,N,S,L,b,w;let a=null;try{typeof t.spkvideo=="string"?a=JSON.parse(t.spkvideo):a=t.spkvideo}catch(y){console.error("Error parsing spkvideo JSON",y)}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)||((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:(a==null?void 0:a.thumbnail_url)||((j=(x=(c=(m=t.json_metadata)==null?void 0:m.raw)==null?void 0:c.video)==null?void 0:x.info)==null?void 0:j.thumbnail),numOfUpvotes:(N=t.stats)==null?void 0:N.num_votes,numOfComments:(S=t.stats)==null?void 0:S.num_comments,hiveValue:(L=t.stats)==null?void 0:L.total_hive_reward,active_votes:((w=(b=t.stats)==null?void 0:b.active_voters)==null?void 0:w.map(y=>({voter:y.voter,percent:y.percent,rshares:y.rshares,weight:y.weight})))||[]}})}async getContentStats(s,t){try{const a=await Ie.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 Ie.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 Ie.call("bridge","get_discussion",[s,t]);return(Array.isArray(a)?a:a&&typeof a=="object"?Object.values(a):[]).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(a){return console.error("Error fetching comments list:",a),[]}}async getMyVideos(s){const t=`${ne.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}`)}}const Z=new Wr,de=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",tr=({video:r,onVideoClick:s,onAuthorClick:t,isGrid:a=!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),x=Math.floor(m%3600/60),j=m%60,N=S=>S.toString().padStart(2,"0");return m<60?`00:${N(j)}`:c===0?`${N(x)}:${N(j)}`:`${N(c)}:${N(x)}:${N(j)}`},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:de(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(p.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(p.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:Me.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(p.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(p.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 Q=(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))(Q||{});const sr=new Map,ar=({title:r,author:s,permlink:t,createdAt:a,video:o,currentUser:u,isContentVoted:l=!1,description:g,onTapComment:d,onTapUpvote:m,onTapShare:c,onTapBookmark:x,onTapAuthor:j,onTapInfo:N})=>{const[S,L]=i.useState(o.numOfComments||0),[b,w]=i.useState(o.numOfUpvotes||0),[y,W]=i.useState(!1),[E,C]=i.useState(!1),[T,G]=i.useState(""),f=H=>{G(H),C(!0),setTimeout(()=>C(!1),3e3)},F=(H,B)=>`${H}:${B}`;i.useEffect(()=>{const H=F(s,t),B=sr.get(H);B?(L(B.comments),w(B.upvotes)):(async()=>{const K=await Z.getContentStats(s,t);w(K.numOfUpvotes),L(K.numOfComments),sr.set(F(s,t),{comments:K.numOfComments,upvotes:K.numOfUpvotes})})()},[s,t]);const $=()=>{d?d(s,t):f("Comments feature coming soon!")},P=()=>{m?m(s,t):f("Upvote feature requires authentication!")},X=()=>{if(c)c(s,t);else{const H=`https://3speak.tv/user/${s}/${t}`;navigator.share?navigator.share({title:r,url:H}):(navigator.clipboard.writeText(H),f("Link copied to clipboard!"))}},k=()=>{x?x(s,t):(W(!y),f(y?"Removed from bookmarks":"Added to bookmarks"))},V=()=>j==null?void 0:j(s,t),M=()=>{N?N(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:V,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:H=>{H.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:V,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(p.Eye,{className:"w-4 h-4"}),e.jsxs("span",{children:[o.views.toLocaleString()," views"]})]}),a&&e.jsx("span",{children:Me.formatDistanceToNow(a,{addSuffix:!0})})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:M,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(p.Info,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Info"})]}),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-primary/10 hover:text-primary transition-all duration-200","aria-label":"Show comments",children:[e.jsx(p.MessageCircle,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:S})]}),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(p.ThumbsUp,{className:`w-4 h-4 ${l?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:b})]}),e.jsxs("button",{type:"button",onClick:X,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(p.Share2,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Share"})]}),e.jsxs("button",{type:"button",onClick:k,className:`inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200 ${y?"bg-error/10 text-error":"bg-muted text-muted-foreground hover:bg-error/10 hover:text-error"}`,"aria-label":"Bookmark video",children:[e.jsx(p.Heart,{className:`w-4 h-4 ${y?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-medium",children:y?"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(p.Users,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground capitalize",children:o.category})]})]})]})]})]}),E&&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:T})})})]})},Ee=new Map,Ce=({feedType:r,username:s,communityId:t,tag:a,onVideoClick:o,onAuthorClick:u})=>{const[l,g]=i.useState([]),[d,m]=i.useState(!0),[c,x]=i.useState(!1),[j,N]=i.useState(null),[S,L]=i.useState(!0),[b,w]=i.useState(0),y=i.useMemo(()=>{switch(r){case Q.USER:return`user:${s||""}`;case Q.COMMUNITY:return`community:${t||""}`;case Q.TAG_FEED:return`tag:${a||""}`;default:return r}},[r,s,t,a]),W=i.useCallback(async f=>{var F,$,P,X,k,V,M,H,B,J,K,ae;if((F=f.author)!=null&&F.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 ue=de(R==null?void 0:R.thumbnail_url)||de((k=(X=(P=($=f.json_metadata)==null?void 0:$.raw)==null?void 0:P.video)==null?void 0:X.info)==null?void 0:k.thumbnail),me=(R==null?void 0:R.duration)||((B=(H=(M=(V=f.json_metadata)==null?void 0:V.raw)==null?void 0:M.video)==null?void 0:H.info)==null?void 0:B.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:me,thumbnail:ue,numOfUpvotes:((J=f.stats)==null?void 0:J.num_votes)||f.numOfUpvotes,numOfComments:((K=f.stats)==null?void 0:K.num_comments)||f.numOfComments,hiveValue:((ae=f.stats)==null?void 0:ae.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:de(f.thumbnail),numOfUpvotes:f.numOfUpvotes,numOfComments:f.numOfComments,hiveValue:f.hiveValue}:null},[]),E=i.useCallback(async(f,F=!1)=>{try{let $=[];switch(r){case Q.SEARCH:a&&($=await Z.getSearchFeed(a,f));break;case Q.TAG_FEED:a&&($=await Z.getTaggedVideos(a,f));break;case Q.HOME:$=await Z.getHomeVideos(f);break;case Q.TRENDING:$=await Z.getTrendingVideos(f);break;case Q.NEW_VIDEOS:$=await Z.getNewVideos(f);break;case Q.FIRST_UPLOADS:$=await Z.getFirstUploadsVideos(f);break;case Q.USER:s&&($=await Z.getUserVideos(s,f));break;case Q.COMMUNITY:t&&($=await Z.getCommunityVideos(t,f));break;case Q.RELATED:s&&($=await Z.getRelatedVideos(s,f));break}const X=(await Promise.all($.map(W))).filter(k=>k!==null);F?(g(X),Ee.set(y,X)):g(k=>{const V=[...k,...X];return Ee.set(y,V),V}),L($.length>=20),w(f+$.length),N(null)}catch($){N($ instanceof Error?$.message:"Failed to load videos")}},[r,s,t,a,y,W]);i.useEffect(()=>{(async()=>{m(!0),g([]),w(0);const F=Ee.get(y);F!=null&&F.length&&(g(F),m(!1)),await E(0,!0),m(!1)})()},[y,E]);const C=i.useCallback(async()=>{c||!S||(x(!0),await E(b),x(!1))},[c,S,b,E]),T=i.useCallback(async()=>{Ee.delete(y),m(!0),w(0),await E(0,!0),m(!1)},[y,E]);i.useEffect(()=>{const f=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-1e3&&C()};return window.addEventListener("scroll",f),()=>window.removeEventListener("scroll",f)},[C]);const G=()=>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,F)=>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"})]})]})]},F))});return d&&l.length===0?e.jsx(G,{}):j&&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:j}),e.jsxs("button",{onClick:T,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(p.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:T,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(p.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:T,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(p.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,F)=>e.jsx(tr,{video:f,onVideoClick:o,onAuthorClick:u,isGrid:!0},`${f.author}-${f.permlink}-${F}`))}),S&&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(p.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more videos..."]}):e.jsx("button",{onClick:C,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"})})]})},_e=({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(p.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,nr=({author:r,permlink:s,currentUser:t,onClose:a})=>{const[o,u]=i.useState([]),[l,g]=i.useState(!0),[d,m]=i.useState(null),[c,x]=i.useState(""),[j,N]=i.useState(!1);i.useEffect(()=>{(async()=>{try{g(!0);const y=(await Z.getCommentsList(r,s)).filter(W=>W.depth&&W.depth>0).sort((W,E)=>new Date(E.created||0).getTime()-new Date(W.created||0).getTime());u(y)}catch(w){m(w instanceof Error?w.message:"Failed to load comments")}finally{g(!1)}})()},[r,s]);const S=async()=>{if(!(!c.trim()||!t))try{N(!0),console.log("Would submit comment:",c),x("")}catch(b){console.error("Failed to submit comment:",b)}finally{N(!1)}},L=b=>{const w=Math.min(b.depth||0,5);return e.jsx("div",{className:`border-l-2 border-border ${w>0?`ml-${w*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/${b.author}/avatar`,alt:b.author,className:"w-6 h-6 rounded-full object-cover border border-border",onError:y=>{y.target.src=`https://ui-avatars.com/api/?name=${b.author}&background=random`}}),e.jsxs("span",{className:"font-medium text-card-foreground text-sm",children:["@",b.author]}),b.created&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Me.formatDistanceToNow(new Date(b.created),{addSuffix:!0})})]}),e.jsx("div",{className:"text-sm text-card-foreground leading-relaxed",children:b.body||"No content"}),b.net_votes&&b.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:[b.net_votes," votes"]})})]})},`${b.author}-${b.permlink}`)};return e.jsx(_e,{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:c,onChange:b=>x(b.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:S,disabled:!c.trim()||j,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:[j?e.jsx(p.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(p.Send,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:j?"Posting...":"Post Comment"})]})})]})]})}),l?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(p.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(p.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)})]})})},or=({author:r,permlink:s,onClose:t})=>{const[a,o]=i.useState([]),[u,l]=i.useState(!0),[g,d]=i.useState(null);i.useEffect(()=>{(async()=>{try{l(!0);const j=(await Z.getActiveVotes(r,s)).sort((N,S)=>S.rshares-N.rshares);o(j)}catch(x){d(x instanceof Error?x.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(_e,{isOpen:!0,onClose:t,title:`Votes (${a.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(p.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})}):a.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(p.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((c,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/${c.voter}/avatar`,alt:c.voter,className:"w-8 h-8 rounded-full object-cover border border-border",onError:j=>{j.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}-${x}`))})})})},ir=({author:r,permlink:s,content:t,onClose:a})=>e.jsx(_e,{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(p.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]})]})})]})}),Hr=()=>{const{author:r,permlink:s}=ve.useParams(),t=ve.useNavigate(),[a,o]=i.useState(null),[u,l]=i.useState(!0),[g,d]=i.useState(null),[m,c]=i.useState(!1),[x,j]=i.useState(null),[N,S]=i.useState(!1),[L,b]=i.useState(!1),[w,y]=i.useState(!1),[W,E]=i.useState(!1),C=i.useRef(null),T=i.useRef(null),G=i.useRef(null);i.useEffect(()=>{(async()=>{if(!(!r||!s))try{l(!0),d(null);const V=await Z.getVideoDetails(r,s);o(V),c(!1),j(null)}catch(V){d(V instanceof Error?V.message:"Failed to load video")}finally{l(!1)}})()},[r,s]);const f=k=>k?k.startsWith("ipfs://")?`https://ipfs-3speak.b-cdn.net/ipfs/${k.replace("ipfs://","").split("/")[0]}/manifest.m3u8`:k:"";i.useEffect(()=>((async()=>{const V=a==null?void 0:a.video_v2;if(!m||!V||!C.current)return;const M=C.current,H=f(V);T.current&&(T.current.destroy(),T.current=null),M.src="",M.load();try{let B=!1;const J=()=>{B||(B=!0,M.play().then(()=>j(null)).catch(q=>j(`Playback failed: ${q.message}`)))};if(fe.isSupported()){const q=new fe({debug:!1,enableWorker:!1,lowLatencyMode:!1,backBufferLength:90,maxLoadingDelay:4,maxBufferLength:30,maxMaxBufferLength:600,startLevel:-1});T.current=q,q.on(fe.Events.MANIFEST_PARSED,()=>{}),q.on(fe.Events.ERROR,(le,te)=>{if(te.fatal)switch(te.type){case fe.ErrorTypes.NETWORK_ERROR:j("Network error, retrying..."),setTimeout(()=>q.startLoad(),1e3);break;case fe.ErrorTypes.MEDIA_ERROR:j("Media error, retrying..."),setTimeout(()=>q.recoverMediaError(),1e3);break;default:j(`Fatal error: ${te.details}`),q.destroy(),T.current=null;break}}),q.attachMedia(M),q.loadSource(H)}else if(M.canPlayType("application/vnd.apple.mpegurl"))M.src=H;else{const q=H.replace("/manifest.m3u8","/480p/index.m3u8");M.src=q}const K=()=>S(!0),ae=()=>{S(!1),J()},R=q=>{var te;const le=q.target;j(`Video error: ${((te=le.error)==null?void 0:te.message)||"Unknown error"}`),S(!1)},ue=()=>S(!1);M.addEventListener("loadstart",K),M.addEventListener("canplay",ae),M.addEventListener("error",R),M.addEventListener("loadeddata",ue);const me=async()=>{var le,te,ce,ge;const q=!!document.fullscreenElement;try{q?"orientation"in screen&&await(((te=(le=screen.orientation)==null?void 0:le.lock)==null?void 0:te.call(le,"landscape"))??Promise.resolve()):"orientation"in screen&&((ge=(ce=screen.orientation)==null?void 0:ce.unlock)==null||ge.call(ce))}catch{}};return document.addEventListener("fullscreenchange",me),G.current=()=>{document.removeEventListener("fullscreenchange",me)},()=>{M.removeEventListener("loadstart",K),M.removeEventListener("canplay",ae),M.removeEventListener("error",R),M.removeEventListener("loadeddata",ue),G.current&&G.current()}}catch(B){j(`Setup error: ${B instanceof Error?B.message:"Unknown"}`)}})(),()=>{T.current&&(T.current.destroy(),T.current=null)}),[m,a==null?void 0:a.video_v2]);const F=()=>{if(!(a==null?void 0:a.video_v2)){j("No video source available");return}c(!0),j(null),S(!0)},$=k=>{t(`/video/${k.author}/${k.permlink}`)},P=k=>{t(`/user/${k}`)},X=k=>{if(!k)return"00:00";const V=Math.floor(k),M=Math.floor(V/3600),H=Math.floor(V%3600/60),B=V%60,J=K=>K.toString().padStart(2,"0");return V<60?`00:${J(B)}`:M===0?`${J(H)}:${J(B)}`:`${J(M)}:${J(H)}:${J(B)}`};return u?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"})]})]})})]}):g||!a?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:g||"Video not found"}),e.jsxs("button",{onClick:()=>t(-1),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(p.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:()=>t(-1),className:"inline-flex items-center gap-2 text-muted-foreground hover:text-card-foreground transition-colors",children:[e.jsx(p.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:m?e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("video",{ref:C,controls:!0,poster:de(a.thumbnail),className:"w-full h-full object-contain bg-black",onDoubleClick:async k=>{const V=k.currentTarget;try{document.fullscreenElement?await document.exitFullscreen():await V.requestFullscreen()}catch{}}}),N&&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"})}),x&&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:x}),e.jsx("button",{onClick:()=>{c(!1),j(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:de(a.thumbnail)||`https://images.hive.blog/u/${a.owner}/avatar`,alt:a.title,className:"w-full h-full object-cover",onError:k=>{k.target.src=`https://images.hive.blog/u/${a.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:F,className:"bg-primary hover:bg-primary-hover rounded-full p-6 transform hover:scale-110 transition-all duration-300 shadow-lg",children:e.jsx(p.Play,{className:"w-8 h-8 text-primary-foreground ml-1",fill:"currentColor"})})}),a.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(p.Clock,{className:"w-3 h-3"}),X(a.duration)]}),a.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(p.Eye,{className:"w-3 h-3"}),a.views.toLocaleString()," views"]})]})}),e.jsx(ar,{title:a.title||"",author:a.owner||"",permlink:a.permlink||"",createdAt:a.created,description:a.description||"",video:{title:a.title||"",author:a.owner||"",permlink:a.permlink||"",created:a.created||new Date,category:a.category||"",numOfUpvotes:void 0,numOfComments:void 0,hiveValue:void 0,duration:a.duration,thumbnail:a.thumbnail,views:a.views},onTapComment:()=>b(!0),onTapUpvote:()=>y(!0),onTapInfo:()=>E(!0),onTapAuthor:()=>t(`/user/${a.owner}`)}),a.tags&&e.jsx("div",{className:"flex flex-wrap gap-2",children:a.tags.split(",").map((k,V)=>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:()=>t(`/tag/${k.trim()}`),children:["#",k.trim()]},V))})]}),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(Ce,{feedType:Q.RELATED,username:a.owner,onVideoClick:$,onAuthorClick:P})})]})]})}),L&&r&&s&&e.jsx(nr,{author:r,permlink:s,onClose:()=>b(!1)}),w&&r&&s&&e.jsx(or,{author:r,permlink:s,onClose:()=>y(!1)}),W&&r&&s&&e.jsx(ir,{author:r,permlink:s,content:a.description||"",onClose:()=>E(!1)})]})};var lr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},cr=i.createContext&&i.createContext(lr),Br=["attr","size","title"];function zr(r,s){if(r==null)return{};var t=qr(r,s),a,o;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(r);for(o=0;o<u.length;o++)a=u[o],!(s.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(r,a)&&(t[a]=r[a])}return t}function qr(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 Te(){return Te=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},Te.apply(this,arguments)}function dr(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 Oe(r){for(var s=1;s<arguments.length;s++){var t=arguments[s]!=null?arguments[s]:{};s%2?dr(Object(t),!0).forEach(function(a){Yr(r,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):dr(Object(t)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(t,a))})}return r}function Yr(r,s,t){return s=Jr(s),s in r?Object.defineProperty(r,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[s]=t,r}function Jr(r){var s=Gr(r,"string");return typeof s=="symbol"?s:s+""}function Gr(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 ur(r){return r&&r.map((s,t)=>i.createElement(s.tag,Oe({key:t},s.attr),ur(s.child)))}function xe(r){return s=>i.createElement(Kr,Te({attr:Oe({},r.attr)},s),ur(r.child))}function Kr(r){var s=t=>{var{attr:a,size:o,title:u}=r,l=zr(r,Br),g=o||t.size||"1em",d;return t.className&&(d=t.className),r.className&&(d=(d?d+" ":"")+r.className),i.createElement("svg",Te({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,a,l,{className:d,style:Oe(Oe({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 cr!==void 0?i.createElement(cr.Consumer,null,t=>s(t)):s(lr)}function Qr(r){return xe({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 Xr(r){return xe({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 Zr(r){return xe({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 Rr(r){return xe({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 et(r){return xe({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 rt(r){return xe({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 We=new Mr.Client(["https://api.hive.blog"]),tt=async r=>{try{const s=await We.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"}}},st=async r=>{try{const s=await We.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"}},at=async r=>{try{const t=(await We.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"}},mr=Dr.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 tt(s),a=L=>"error"in L;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",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 st(o),c=parseFloat(u.split(" ")[0]||"0"),x=parseFloat(m),j=(c+x).toFixed(3),N=await at(j),S={balance:u,hbd_balance:l,savings_balance:g,savings_hbd_balance:d,hive_power:`${m} HP`,estimated_value:`$${N}`};return r({walletData:S}),S}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})}}})),nt=({username:r,className:s=""})=>{const{walletData:t,fetchWalletData:a,isLoading:o,error:u}=mr();i.useEffect(()=>{r&&a(r)},[r,a]);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(Zr,{className:"mr-2"}),e.jsx("span",{children:u})]}),e.jsx(l,{label:"Balance",value:t==null?void 0:t.balance,icon:e.jsx(rt,{}),colorClass:"bg-blue-500/10"}),e.jsx(l,{label:"HBD Balance",value:t==null?void 0:t.hbd_balance,icon:e.jsx(Rr,{}),colorClass:"bg-green-500/10"}),e.jsx(l,{label:"Savings Balance",value:t==null?void 0:t.savings_balance,icon:e.jsx(et,{}),colorClass:"bg-yellow-500/10"}),e.jsx(l,{label:"Savings HBD Balance",value:t==null?void 0:t.savings_hbd_balance,icon:e.jsx(Xr,{}),colorClass:"bg-purple-500/10"}),e.jsx(l,{label:"Hive Power",value:t==null?void 0:t.hive_power,icon:e.jsx(Qr,{}),colorClass:"bg-orange-500/10"})]})})},He="_communityLocalKey",Le={getBookmarkedCommunities:()=>{const r=localStorage.getItem(He);return r?JSON.parse(r):[]},isUserPresentLocally:r=>{const s=localStorage.getItem(He);return s?JSON.parse(s).includes(r):!1},storeLikedCommunityLocally:(r,s=!1)=>{let t=Le.getBookmarkedCommunities();return t.includes(r)?t=t.filter(a=>a!==r):s||t.push(r),localStorage.setItem(He,JSON.stringify(t)),t}},Be=({id:r,toastType:s,isLiked:t,onAdd:a,onRemove:o,onFavourite:u})=>{const[l,g]=i.useState(t??Le.isUserPresentLocally(r));i.useEffect(()=>{t!==void 0&&g(t)},[t]);const d=()=>{u&&u(),l?(o?o(r,"remove_bookmark"):Le.storeLikedCommunityLocally(r,!0),m(!1)):(a?a(r,"add_bookmark"):Le.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(p.BookmarkCheck,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}):e.jsx(p.Bookmark,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})};class ot{constructor(){De(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 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 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 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 oe=new ot,it=({onSelectCommunity:r})=>{const[s,t]=i.useState([]),[a,o]=i.useState(""),[u,l]=i.useState(!0),[g,d]=i.useState(!1),[m,c]=i.useState(!0),[x,j]=i.useState(null),[N,S]=i.useState(null),L=20,b=i.useRef(null),w=i.useCallback(async(E=!1)=>{if(!(!E&&(g||!m)))try{E?(l(!0),S(null),t([]),j(null),c(!0)):d(!0);const C=a.trim(),T=await oe.getListOfCommunities(C.length>=3?C:void 0,L,E?void 0:x||void 0);t(G=>E?T:[...G,...T]),T.length<L||T.length>0&&T[T.length-1].name===x?c(!1):T.length>0&&j(T[T.length-1].name||null)}catch(C){S(C instanceof Error?C.message:"Failed to load communities"),c(!1)}finally{l(!1),d(!1)}},[a,g,m,x]);i.useEffect(()=>{const E=setTimeout(()=>{w(!0)},a.length>=3||a.length===0?0:500);return()=>clearTimeout(E)},[a]),i.useEffect(()=>{var E;(E=b.current)==null||E.focus()},[a,u,N]),i.useEffect(()=>{const E=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!g&&!u&&m&&w()};return window.addEventListener("scroll",E),()=>window.removeEventListener("scroll",E)},[w,g,u,m]);const y=()=>{w(!0)},W=()=>e.jsx("div",{className:"space-y-4",children:Array.from({length:6}).map((E,C)=>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"})]})},C))});return u&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(p.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:E=>o(E.target.value),ref:b,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 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
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(W,{})]}):N&&s.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(p.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:E=>o(E.target.value),ref:b,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(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
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:N}),e.jsxs("button",{onClick:y,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(p.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(p.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:E=>o(E.target.value),ref:b,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: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
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:y,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(p.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=>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: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
95
95
  rounded-xl p-4 hover:bg-gray-300 dark:hover:bg-gray-700
96
- transition-colors cursor-pointer`,onClick:()=>r(E.name||""),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:oe.communityIcon(E.name||""),alt:E.title,className:"w-12 h-12 rounded-full object-cover",onError:C=>{C.target.src=`https://ui-avatars.com/api/?name=${E.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:E.title}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 line-clamp-2",children:E.about})]}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[(E.subscribers||0).toLocaleString()," members"]})})]})},E.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(p.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading more communities..."]}):e.jsx("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:"Load More Communities"})})]})]})},gr=({communityId:r})=>{var x,j,N;const[s,t]=i.useState(null),[a,o]=i.useState(!0),[u,l]=i.useState(null),g=async()=>{try{o(!0),l(null);const S=await oe.getCommunityDetails(r);t(S)}catch(S){l(S instanceof Error?S.message:"Failed to load community details")}finally{o(!1)}};i.useEffect(()=>{g()},[r]);const d=S=>{try{return new Date(S).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return S}},m=S=>S.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(p.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(p.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:((x=c.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:((j=c.subscribers)==null?void 0:j.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:((N=c.num_pending)==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:"Type"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.is_nsfw?"NSFW":"Safe"})]})]})]})})},hr=({communityId:r,onSelectTeamMember:s})=>{var c;const[t,a]=i.useState(null),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const x=await oe.getCommunityDetails(r);a(x)}catch(x){g(x instanceof Error?x.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(p.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(p.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((x,j)=>{const N=x[0],S=x.length>1?x[1]:"";return e.jsx("div",{onClick:()=>s&&s(N),className:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-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
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:oe.userOwnerThumb(N),alt:N,className:"w-12 h-12 rounded-full object-cover",onError:L=>{L.target.src=`https://ui-avatars.com/api/?name=${N}&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]}),S&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:S})]})]})},`${N}-${j}`)})})})},fr=({communityId:r,onSelectCommunityMember:s})=>{const[t,a]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(!1),[d,m]=i.useState(!0),[c,x]=i.useState(null),[j,N]=i.useState(null),S=100,L=i.useCallback(async(b=!1)=>{if(!(l&&!b))try{b?(u(!0),N(null),a([]),x(null),m(!0)):g(!0);const w=await oe.getCommunitySubscribers(r,S,b?void 0:c||void 0);w.length===0?m(!1):(a(y=>{if(b)return w;const W=new Set(y.map(C=>C.username)),E=w.filter(C=>!W.has(C.username));return[...y,...E]}),w.length>0&&x(w[w.length-1].username),m(w.length===S))}catch(w){N(w instanceof Error?w.message:"Failed to load members")}finally{u(!1),g(!1)}},[r,l,c]);return i.useEffect(()=>{L(!0)},[r]),i.useEffect(()=>{const b=()=>{window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&!l&&!o&&d&&L()};return window.addEventListener("scroll",b),()=>window.removeEventListener("scroll",b)},[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(p.Loader2,{className:"w-5 h-5 animate-spin"}),"Loading members..."]})}):j&&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:j}),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(p.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((b,w)=>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(b.username),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:oe.userOwnerThumb(b.username),alt:b.username,className:"w-12 h-12 rounded-full object-cover",onError:y=>{y.target.src=`https://ui-avatars.com/api/?name=${b.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:["@",b.username]}),b.role&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 capitalize truncate",children:b.role})]})]})},`${b.username}-${w}`))}),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(p.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"})})]})},lt=({communityId:r,onVideoClick:s,onAuthorClick:t,onBack:a,onclickAboutTab:o,onclickTeamTab:u,onclickMemberTab:l,onShare:g,onFavourite:d,onRss:m,onMoreVertical:c,showMoreVertical:x=!0})=>{const j=ve.useNavigate(),[N,S]=i.useState("videos"),[L,b]=i.useState(null),[w,y]=i.useState(!1),[W,E]=i.useState(!0);i.useEffect(()=>{(async()=>{try{E(!0);const $=await oe.getCommunityDetails(r);b($)}catch($){console.error("Failed to fetch community details:",$)}finally{E(!1)}})()},[r]);const C=()=>{var $;const F=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:(($=L==null?void 0:L.result)==null?void 0:$.title)||r,url:F}):navigator.clipboard.writeText(F)},T=()=>{window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},G=F=>{j(`/user/${F}`)};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((F,$)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},$))})]})]})});const f=L==null?void 0:L.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(p.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:oe.userOwnerThumb(r),alt:(f==null?void 0:f.title)||r,className:"w-16 h-16 rounded-full object-cover",onError:F=>{F.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(p.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(p.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(Be,{id:r,toastType:"community",onAdd:(F,$)=>console.log("Added:",F,$),onRemove:(F,$)=>console.log("Removed:",F,$),onFavourite:d}),e.jsx("button",{onClick:m||T,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(p.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:g||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(p.Share2,{className:"w-4 h-4"})}),x&&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(p.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:()=>S("videos"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="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():S("about"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="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():S("team"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="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():S("members"),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${N==="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:[N==="videos"&&e.jsx(Ce,{feedType:Q.COMMUNITY,communityId:r,onVideoClick:s,onAuthorClick:t}),N==="about"&&!o&&e.jsx(gr,{communityId:r}),N==="team"&&!u&&e.jsx(hr,{communityId:r,onSelectTeamMember:G}),N==="members"&&!l&&e.jsx(fr,{communityId:r,onSelectCommunityMember:G})]})]})]})},ct=({currentUser:r,onTabChanged:s,onPublish:t,onViewMyVideo:a,onMoreOptions:o,onTapBackButton:u,shouldShowBackButton:l=!0,shouldShowPublishButton:g=!1,shouldShowMoreOptionsButton:d=!1})=>{const m=ve.useNavigate(),[c,x]=i.useState(0),[j,N]=i.useState([]),[S,L]=i.useState(!0),[b,w]=i.useState(null),y=j.filter(P=>["encoding","uploaded","encoding_queued","encoding_preparing","ipfs_pinning","ipfs_pinning_failed","encoding_failed","encoding_ipfs"].includes(P.status||"")),W=j.filter(P=>P.status==="publish_manual"),E=j.filter(P=>P.status==="published");i.useEffect(()=>{r!=null&&r.token&&C()},[r]);const C=async()=>{if(!(r!=null&&r.token)){w("No authentication token provided"),L(!1);return}L(!0),w(null);try{const P=await Z.getMyVideos(r.token);N(P)}catch(P){console.error("Error fetching videos:",P),w(`Failed to load videos: ${P instanceof Error?P.message:"Unknown error"}`)}finally{L(!1)}},T=P=>{x(P),s==null||s(P)},G=P=>{P.owner&&P.permlink&&m(`/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"}},F=["ipfs_pinning","ipfs_pinning_failed","encoding","encoding_failed","encoding_ipfs"],$=(P,X)=>{if(P.length===0){let k="";switch(X){case"publishNow":k="No videos ready to publish.";break;case"myVideos":k="No published videos found.";break;case"encoding":k="No videos currently encoding.";break}return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(p.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:k})]})}return e.jsx("div",{className:"space-y-3 w-full",children:P.map((k,V)=>{const M=k.thumbnail||"",H=k.title||"No Title",B=k.permlink||"",J=k.owner||(r==null?void 0:r.username)||"",K=k.id||"",ae=F.includes(k.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:de(M)||`https://images.hive.blog/u/${r==null?void 0:r.username}/avatar`,alt:H,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`}}),F.includes(k.status||"")?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 rounded-lg",children:e.jsx(p.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:()=>G(k),children:e.jsx(p.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:()=>G(k),style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:H}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 text-xs mt-1",children:["By ",J]}),k.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(k.status)}`,children:k.status.toUpperCase()})})]}),ae?e.jsx("div",{className:"flex-shrink-0 pl-2",children:e.jsx(p.Ban,{className:"w-5 h-5 text-red-500"})}):e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[X==="publishNow"&&g&&e.jsx("button",{onClick:()=>t==null?void 0:t(J,B),className:"bg-green-600 hover:bg-green-700 text-white text-xs px-3 py-1 rounded-md transition-colors",children:"Publish"}),X==="myVideos"&&e.jsx("button",{onClick:()=>a?a(J,B):G(k),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(K),className:"p-1 h-6 w-6 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(p.MoreVertical,{className:"w-4 h-4"})})]})]})},`${K}-${V}`)})})};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(p.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:C,className:"p-2 rounded-md hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",children:e.jsx(p.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:()=>T(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(p.Upload,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Publish Now"}),e.jsx("span",{className:"sm:hidden",children:"Publish"}),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.jsxs("button",{onClick:()=>T(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(p.Video,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"My Videos"}),e.jsx("span",{className:"sm:hidden",children:"Videos"}),E.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:E.length})]}),e.jsxs("button",{onClick:()=>T(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(p.Hourglass,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Encoding"}),e.jsx("span",{className:"sm:hidden",children:"Encoding"}),y.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:y.length})]})]})})]}),e.jsx("div",{className:"py-4 md:py-6 w-full",children:S?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"})}):b?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(p.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:b}),e.jsx("button",{onClick:C,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&&$(W,"publishNow"),c===1&&$(E,"myVideos"),c===2&&$(y,"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 dt{constructor(){De(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}userAvatar(s){return`https://images.hive.blog/u/${s}/avatar`}}const ie=new dt,xr=({username:r,onSelectUser:s})=>{const[t,a]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const m=await ie.getFollowers(r);a(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(p.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(p.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: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
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:ie.userAvatar(m.follower),alt:m.follower,className:"w-12 h-12 rounded-full object-cover",onError:x=>{x.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}`))})})},pr=({username:r,onSelectUser:s})=>{const[t,a]=i.useState([]),[o,u]=i.useState(!0),[l,g]=i.useState(null),d=async()=>{try{u(!0),g(null);const m=await ie.getFollowing(r);a(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(p.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(p.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: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
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:ie.userAvatar(m.following),alt:m.following,className:"w-12 h-12 rounded-full object-cover",onError:x=>{x.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}`))})})},br=({username:r})=>{var j,N,S,L,b,w;const[s,t]=i.useState(null),[a,o]=i.useState(!0),[u,l]=i.useState(null),g=async()=>{try{o(!0),l(null);const y=await ie.getProfile(r);t(y)}catch(y){l(y instanceof Error?y.message:"Failed to load user details")}finally{o(!1)}};i.useEffect(()=>{g()},[r]);const d=y=>{try{return new Date(y).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return y}},m=y=>y.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(p.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(p.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,x=(j=c.metadata)==null?void 0:j.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:m(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: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:((S=(N=c.stats)==null?void 0:N.followers)==null?void 0:S.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:((b=(L=c.stats)==null?void 0:L.following)==null?void 0:b.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:((w=c.post_count)==null?void 0:w.toLocaleString())||"0"})]})]})]})})},ut=({username:r,onVideoClick:s,onAuthorClick:t,onBack:a})=>{var y,W,E;const o=ve.useNavigate(),[u,l]=i.useState("videos"),[g,d]=i.useState(null),[m,c]=i.useState(!1),[x,j]=i.useState(!0);i.useEffect(()=>{(async()=>{try{j(!0);const T=await ie.getProfile(r);d(T)}catch(T){console.error("Failed to fetch user details:",T)}finally{j(!1)}})()},[r]);const N=()=>{var T;const C=`https://3speak.tv/user/${r}`;navigator.share?navigator.share({title:((T=g==null?void 0:g.result)==null?void 0:T.name)||r,url:C}):navigator.clipboard.writeText(C)},S=()=>{window.open(`https://3speak.tv/rss/${r}.xml`,"_blank")},L=C=>{o(`/user/${C}`)};if(x)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((C,T)=>e.jsx("div",{className:"h-10 bg-gray-200 dark:bg-gray-700 rounded w-20"},T))})]})]})});const b=g==null?void 0:g.result,w=(y=b==null?void 0:b.metadata)==null?void 0:y.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(p.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:w.cover_image||ie.userAvatar(r),alt:"Cover",className:"w-full h-48 object-cover",onError:C=>{C.target.src=ie.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:w==null?void 0:w.profile_image,alt:w==null?void 0:w.name,className:"w-24 h-24 rounded-full object-cover border-4 border-white dark:border-gray-800 -mt-16",onError:C=>{C.target.src=ie.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:(w==null?void 0:w.name)||r}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:(w==null?void 0:w.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(p.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((W=b==null?void 0:b.stats)==null?void 0:W.followers)||0).toLocaleString()," Followers"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(p.Users,{className:"w-4 h-4"}),e.jsxs("span",{children:[(((E=b==null?void 0:b.stats)==null?void 0:E.following)||0).toLocaleString()," Following"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(p.Calendar,{className:"w-4 h-4"}),e.jsxs("span",{children:["Joined"," ",b!=null&&b.created?new Date(b.created).getFullYear():"Unknown"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{id:r,toastType:"user",onAdd:(C,T)=>console.log("Added:",C,T),onRemove:(C,T)=>console.log("Removed:",C,T)}),e.jsx("button",{onClick:S,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(p.Rss,{className:"w-4 h-4"})}),e.jsx("button",{onClick:N,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(p.Share2,{className:"w-4 h-4"})}),e.jsx("button",{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(p.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"},{key:"followers",label:"Followers"},{key:"following",label:"Following"}].map((C,T)=>e.jsx("button",{onClick:()=>l(C.key),className:`px-4 py-2 text-xs sm:text-sm font-medium transition-colors ${u===C.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:C.label},C.key))}),e.jsxs("div",{className:"mt-6",children:[u==="videos"&&e.jsx(Ce,{feedType:Q.USER,username:r,onVideoClick:s,onAuthorClick:t}),u==="about"&&e.jsx(br,{username:r}),u==="followers"&&e.jsx(xr,{username:r,onSelectUser:L}),u==="following"&&e.jsx(pr,{username:r,onSelectUser:L})]})]})]})},ze=768;function mt(){const[r,s]=Se.useState(void 0);return Se.useEffect(()=>{const t=window.matchMedia(`(max-width: ${ze-1}px)`),a=()=>{s(window.innerWidth<ze)};return t.addEventListener("change",a),s(window.innerWidth<ze),()=>t.removeEventListener("change",a)},[]),!!r}const gt=1,ht=1e6;let qe=0;function ft(){return qe=(qe+1)%Number.MAX_SAFE_INTEGER,qe.toString()}const Ye=new Map,yr=r=>{if(Ye.has(r))return;const s=setTimeout(()=>{Ye.delete(r),Ne({type:"REMOVE_TOAST",toastId:r})},ht);Ye.set(r,s)},vr=(r,s)=>{switch(s.type){case"ADD_TOAST":return{...r,toasts:[s.toast,...r.toasts].slice(0,gt)};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?yr(t):r.toasts.forEach(a=>{yr(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)}}},$e=[];let Fe={toasts:[]};function Ne(r){Fe=vr(Fe,r),$e.forEach(s=>{s(Fe)})}function jr({...r}){const s=ft(),t=o=>Ne({type:"UPDATE_TOAST",toast:{...o,id:s}}),a=()=>Ne({type:"DISMISS_TOAST",toastId:s});return Ne({type:"ADD_TOAST",toast:{...r,id:s,open:!0,onOpenChange:o=>{o||a()}}}),{id:s,dismiss:a,update:t}}function xt(){const[r,s]=Se.useState(Fe);return Se.useEffect(()=>($e.push(s),()=>{const t=$e.indexOf(s);t>-1&&$e.splice(t,1)}),[r]),{...r,toast:jr,dismiss:t=>Ne({type:"DISMISS_TOAST",toastId:t})}}_.ApiVideoFeedType=Q,_.CommentsModal=nr,_.CommunitiesList=it,_.CommunityAbout=gr,_.CommunityDetail=lt,_.CommunityMembers=fr,_.CommunityTeam=hr,_.DescriptionModal=ir,_.FavouriteWidget=Be,_.Modal=_e,_.UpvoteListModal=or,_.UserAccount=ct,_.UserFollowers=xr,_.UserFollowing=pr,_.UserInfo=br,_.UserProfilePage=ut,_.VideoCard=tr,_.VideoDetail=Hr,_.VideoFeed=Ce,_.VideoInfo=ar,_.Wallet=nt,_.apiService=Z,_.reducer=vr,_.server=ne,_.toast=jr,_.useIsMobile=mt,_.useToast=xt,_.useWalletStore=mr,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: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"})});