import useAuth from '../../core/hooks/useAuth';
import { useUser } from './useUser';
import useSocialSettings from '../../core/hooks/useSocialSettings';
import { checkStoryPermission, isAdmin } from '../utils/permissions';
export function useStoryPermission(communityId) {
  var _socialSettings$story, _socialSettings$story2;
  const {
    client
  } = useAuth();
  const {
    socialSettings
  } = useSocialSettings();
  const user = useUser((client === null || client === void 0 ? void 0 : client.userId) || '');
  const isGlobalAdmin = isAdmin(user === null || user === void 0 ? void 0 : user.roles);
  const hasStoryPermission = !communityId ? socialSettings === null || socialSettings === void 0 || (_socialSettings$story = socialSettings.story) === null || _socialSettings$story === void 0 ? void 0 : _socialSettings$story.allowAllUserToCreateStory : (socialSettings === null || socialSettings === void 0 || (_socialSettings$story2 = socialSettings.story) === null || _socialSettings$story2 === void 0 ? void 0 : _socialSettings$story2.allowAllUserToCreateStory) || isGlobalAdmin || checkStoryPermission(client, communityId);
  return {
    hasStoryPermission
  };
}
//# sourceMappingURL=useStoryPermission.js.map