'use strict';
import { jsx } from 'react/jsx-runtime';
import { getUserId } from '../../../../meta/server/auth/users/current-user-id-provider.js';
import { initInternalResourceMetasCacheFromJson } from '../../../../meta/server/resources/init-internal-resource-metas-from-json.js';
import { getAllUserWorkspaces } from '../../infra/workspaces/workspace-db.js';
import { getUserVisibleWorkspaces } from '../../workspace/visible-workspaces.js';
import { getResources } from '../../../../meta/server/services/resource-provider.js';
import { buildUserPermissions } from '../../../../meta/server/permission/user-permissions-builder.js';
import { ClientRoot } from '../../../layout/client-root/ClientRoot.js';
import { getSidebarItems } from '../sidebar/sidebar-resources.js';
import { withUserIdProps } from '../../../../../fd-toolbox/types/with-user-id.js';
import { getODataFilterUuid } from '../../../../../fd-toolbox/odata/odata-builder-funcs.js';
import { baseResourceProps } from '../../../../../fd-toolbox/base-resource/props/base-resource-props.js';
import { oDataOrderByDirections } from '../../../../../fd-toolbox/enums/enums.js';
import { resourceNames } from '../../../../../fd-toolbox/resources/resource-names.js';
import { getSidebarResourceNames } from '../../../layout/sidebar/sidebar-resource-names-cache.js';
import { requirePageAuth } from '../../../../meta/server/auth/auth-guard.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
async function SignedInLayout({
  children
}) {
  await requirePageAuth();
  initInternalResourceMetasCacheFromJson();
  const userId = await getUserId();
  const notificationOdataConfig = getODataFilterUuid(withUserIdProps.userId, userId).orderBy(baseResourceProps.createdDate, oDataOrderByDirections.desc).build();
  const userSettings = getResources(resourceNames.userSetting, userId, getODataFilterUuid(withUserIdProps.userId, userId).build());
  const userPermissions = buildUserPermissions(userId);
  const sidebarItemsPromise = getSidebarItems(getSidebarResourceNames(), userId);
  const userWorkspacesPromise = getAllUserWorkspaces(userId);
  const userVisibleWorkspacesPromise = getUserVisibleWorkspaces();
  const notificationsPromise = getResources(resourceNames.notification, userId, notificationOdataConfig);
  return /* @__PURE__ */jsx(ClientRoot, {
    sidebarItems: sidebarItemsPromise,
    userPermissions,
    userSettings,
    userWorkspaces: userWorkspacesPromise,
    visibleWorkspaces: userVisibleWorkspacesPromise,
    notifications: notificationsPromise,
    children
  });
}
__name(SignedInLayout, "SignedInLayout");

export { SignedInLayout };
