PageSourceSearch

https://www.fearnothing.ai/assets/useCommunityMembership-DRaMPU7W.js

js fearnothing.ai collected 2026-10-05 15:22:32 UTC 11,351 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0fbbd29d-cce1-5e74-b1de-c2d0bd8dd7ef")}catch(e){}}();
3import{s as e,t}from"./jsx-runtime-D4ePz0Hl.js";import{t as n}from"./react-BXH-GOAS.js";import{f as r}from"./components-CDo3yjgw.js";import{A as i,D as a,E as o,F as s,M as c,N as l,O as u,P as d,b as f,d as p,f as m,k as h,n as g,u as _,w as v}from"./QueryClientProvider-Cdu2unP4.js";import{i as y}from"./nectarTrackingFields-BN5KBl15.js";import{t as b}from"./useGlobalModals-CJ1k8aJl.js";import{n as x}from"./query-wBbGv6-D.js";var S=class extends s{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=p(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),w(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return T(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return T(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof a(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!h(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&E(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||u(this.options.staleTime,this.#t)!==u(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return O(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(v)),t}#g(){this.#b();let e=u(this.options.staleTime,this.#t);if(m.isServer()||this.#r.isStale||!f(e))return;let t=c(this.#r.dataUpdatedAt,e)+1;this.#d=l.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(m.isServer()||a(this.options.enabled,this.#t)===!1||!f(this.#p)||this.#p===0)&&(this.#f=l.setInterval(()=>{(this.options.refetchIntervalInBackground||d.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(l.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(l.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,s=this.#i,c=this.#a,l=e===n?this.#n:e.state,{state:u}=e,d={...u},f=!1,m;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&w(e,t),o=i&&E(e,n,t,r);(a||o)&&(d={...d,...x(u.data,e.options)}),t._optimisticResults===`isRestoring`&&(d.fetchStatus=`idle`)}let{error:h,errorUpdatedAt:g,status:_}=d;m=d.data;let v=!1;if(t.placeholderData!==void 0&&m===void 0&&_===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=i.data,v=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(_=`success`,m=o(i?.data,e,t),f=!0)}if(t.select&&m!==void 0&&!v)if(i&&m===s?.data&&t.select===this.#c)m=this.#l;
3else try{this.#c=t.select,m=t.select(m),m=o(i?.data,m,t),this.#l=m,this.#s=null}catch(e){this.#s=e}this.#s&&(h=this.#s,m=this.#l,g=Date.now(),_=`error`);let y=d.fetchStatus===`fetching`,b=_===`pending`,S=_===`error`,C=b&&y,T=m!==void 0,O={status:_,fetchStatus:d.fetchStatus,isPending:b,isSuccess:_===`success`,isError:S,isInitialLoading:C,isLoading:C,data:m,dataUpdatedAt:d.dataUpdatedAt,error:h,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!b,isLoadingError:S&&!T,isPaused:d.fetchStatus===`paused`,isPlaceholderData:f,isRefetchError:S&&T,isStale:D(e,t),refetch:this.refetch,promise:this.#o,isEnabled:a(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=O.data!==void 0,r=O.status===`error`&&!t,i=e=>{r?e.reject(O.error):t&&e.resolve(O.data)},a=()=>{i(this.#o=O.promise=p())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||O.data!==o.value)&&a();break;case`rejected`:(!r||O.error!==o.reason)&&a();break}}return O}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!h(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){_.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function C(e,t){return a(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function w(e,t){return C(e,t)||e.state.data!==void 0&&T(e,t,t.refetchOnMount)}function T(e,t,n){if(a(t.enabled,e)!==!1&&u(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&D(e,t)}return!1}function E(e,t,n,r){return(e!==t||a(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&D(e,n)}function D(e,t){return a(t.enabled,e)!==!1&&e.isStaleByTime(u(t.staleTime,e))}function O(e,t){return!h(e.getCurrentResult(),t)}t();var k=e(n(),1),A=k.createContext(!1),j=()=>k.useContext(A);A.Provider;function M(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var N=k.createContext(M()),P=()=>k.useContext(N),F=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?i(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},I=e=>{k.useEffect(()=>{e.clearReset()},[e])},L=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||i(n,[e.error,r])),R=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},z=(e,t)=>e.isLoading&&e.isFetching&&!t,B=(e,t)=>e?.suspense&&t.isPending,V=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function H(e,t,n){let r=j(),i=P(),a=g(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,R(o),F(o,i,s),I(i);let c=!a.getQueryCache().get(o.queryHash),[l]=k.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(e=>{let t=d?l.subscribe(_.batchCalls(e)):v;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),k.useEffect(()=>{l.setOptions(o)},[o,l]),B(o,u))throw V(o,l,i);if(L({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!m.isServer()&&z(u,r)&&(c?V(o,l,i):s?.promise)?.catch(v).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}var U={manager:new Set([`canCreateSpace`,`canPinAnyPost`,`canMoveAnyPost`,`canHideAnyComments`,`canCloseAnyComments`,`canRemoveAnyPost`,`canRemoveAnyComment`,`canBanMember`]),moderator:new Set([`canCreateSpace`,`canPinAnyPost`,`canMoveAnyPost`,`canHideAnyComments`,`canCloseAnyComments`,`canRemoveAnyPost`,`canRemoveAnyComment`]),admin:new Set([`canCreateSpace`,`canPinAnyPost`,`canMoveAnyPost`,`canHideAnyComments`,`canCloseAnyComments`,`canRemoveAnyPost`,`canRemoveAnyComment`,`canBanMember`])},W=(e,t)=>t.includes(`admin`)||e&&t.includes(`manager`),G=(e,t)=>e&&(t.includes(`admin`)||t.includes(`manager`)),K=(e,{isCommunityAccessible:t=!0}={})=>{let n=e==null,r=e?.banned===!0,i=r,a=e?.roles??[],o=!n,s=!i&&a.includes(`moderator`),c=!i&&a.includes(`manager`),l=!i&&a.includes(`admin`),u=o&&!i&&t,d=e=>u&&a.some(t=>U[t]?.has(e)??!1);return{isGuest:n,isReadOnly:!1,isMember:o,isBanned:r,isRestricted:i,isModerator:s,isManager:c,isAdmin:l,canInteract:u,canCreatePost:u,canPostInSpace:e=>u?e?.read_only?l||s||c:!0:!1,canComment:u,canReact:u,canCreateSpace:d(`canCreateSpace`),canPinAnyPost:d(`canPinAnyPost`),canMoveAnyPost:d(`canMoveAnyPost`),canHideAnyComments:d(`canHideAnyComments`),canCloseAnyComments:d(`canCloseAnyComments`),canRemoveAnyPost:d(`canRemoveAnyPost`),canRemoveAnyComment:d(`canRemoveAnyComment`),
3canBanMember:d(`canBanMember`)}},q=e=>e==null||!e.tier_gated||e.community_accessible,J=()=>({isCommunityAccessible:q(r(`routes/community`)?.community)}),Y=(0,k.createContext)(null),X=()=>{let e=(0,k.useContext)(Y),t=r(`routes/community`),{handleOpenModal:n}=b(),{isCommunityAccessible:i}=J(),a=e?.currentMember??t?.currentMember??null,o=(0,k.useMemo)(()=>K(a,{isCommunityAccessible:i}),[a,i]),s=(0,k.useCallback)(e=>{n(`community_join`,void 0,e?{[y]:e}:void 0)},[n]),c=(0,k.useCallback)(()=>{n(`community_login`)},[n]);return{isMember:!!a,currentMember:a,permissions:o,openJoinModal:s,openSignInModal:c,isMessagesEnabled:!!t?.isMessagesEnabled}};export{G as a,W as i,X as n,H as o,J as r,S as s,Y as t};
4//# sourceMappingURL=useCommunityMembership-DRaMPU7W.js.map
5//# debugId=0fbbd29d-cce1-5e74-b1de-c2d0bd8dd7ef

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.