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CAAA,OAAA;AAAA,MACb,YAAY,GAAI,CAAA,cAAA;AAAA,MAChB,YAAY,GAAI,CAAA,cAAA;AAAA,MAChB,UAAU,GAAI,CAAA,YAAA,GAAe,OAAO,eAAgB,CAAA,GAAA,CAAI,YAAY,CAAI,GAAA;AAAA,KAE1E,GAAA,MAAA;AAAA,IACJ,cAAA,EACE,GAAI,CAAA,WAAA,IACJ,GAAI,CAAA,cAAA,IACJ,IAAI,YACJ,IAAA,GAAA,CAAI,UACJ,IAAA,GAAA,CAAI,YACA,GAAA;AAAA,MACE,aAAa,GAAI,CAAA,WAAA;AAAA,MACjB,gBAAgB,GAAI,CAAA,cAAA;AAAA,MACpB,cAAc,GAAI,CAAA,YAAA;AAAA,MAClB,YAAY,GAAI,CAAA,UAAA;AAAA,MAChB,YAAY,GAAI,CAAA,UAAA;AAAA,MAChB,cAAc,GAAI,CAAA;AAAA,KAEpB,GAAA,MAAA;AAAA,IACN,gBAAA,EAAkB,GAAI,CAAA,gBAAA,IAAoB;AAAC,GAC7C;AACF","file":"index.mjs","sourcesContent":["import * as window from '../window';\n\nimport { AppContext } from './app';\nimport { ChannelContext } from './channel';\nimport { ChatContext } from './chat';\nimport { MeetingContext } from './meeting';\nimport { PageContext } from './page';\nimport { SharePointSiteContext } from './share-point-site';\nimport { TeamContext } from './team';\nimport { UserContext } from './user';\n\n/**\n * Represents structure of the received context message.\n */\nexport interface Context {\n  /**\n   * Properties about the current session for your app\n   */\n  app: AppContext;\n\n  /**\n   * Info about the current page context hosting your app\n   */\n  page: PageContext;\n\n  /**\n   * Info about the currently logged in user running the app.\n   * If the current user is not logged in/authenticated (e.g. a meeting app running for an anonymously-joined partcipant) this will be `undefined`.\n   */\n  user?: UserContext;\n\n  /**\n   * When running in the context of a Teams channel, provides information about the channel, else `undefined`\n   */\n  channel?: ChannelContext;\n\n  /**\n   * When running in the context of a Teams chat, provides information about the chat, else `undefined`\n   */\n  chat?: ChatContext;\n\n  /**\n   * When running in the context of a Teams meeting, provides information about the meeting, else `undefined`\n   */\n  meeting?: MeetingContext;\n\n  /**\n   * When hosted in SharePoint, this is the [SharePoint PageContext](https://learn.microsoft.com/javascript/api/sp-page-context/pagecontext?view=sp-typescript-latest), else `undefined`\n   */\n  sharepoint?: any;\n\n  /**\n   * When running in Teams for an organization with a tenant, provides information about the SharePoint site associated with the team.\n   * Will be `undefined` when not running in Teams for an organization with a tenant.\n   */\n  sharePointSite?: SharePointSiteContext;\n\n  /**\n   * When running in Teams, provides information about the Team context in which your app is running.\n   * Will be `undefined` when not running in Teams.\n   */\n  team?: TeamContext;\n\n  /**\n   * When `processActionCommand` activates a dialog, this dialog should automatically fill in some fields with information. This information comes from M365 and is given to `processActionCommand` as `extractedParameters`.\n   * App developers need to use these `extractedParameters` in their dialog.\n   * They help pre-fill the dialog with necessary information (`dialogParameters`) along with other details.\n   * If there's no key/value pairs passed, the object will be empty in the case\n   */\n  dialogParameters: Record<string, string>;\n}\n\nexport function mapContext(ctx: window.Context): Context {\n  return {\n    app: {\n      id: ctx.appId,\n      locale: ctx.locale,\n      launchId: ctx.appLaunchId,\n      sessionId: ctx.appSessionId ? ctx.appSessionId : '',\n      theme: ctx.theme ? ctx.theme : 'default',\n      iconPositionVertical: ctx.appIconPosition,\n      osLocaleInfo: ctx.osLocaleInfo,\n      parentMessageId: ctx.parentMessageId,\n      userClickTime: ctx.userClickTime,\n      userClickTimeV2: ctx.userClickTimeV2,\n      userFileOpenPreference: ctx.userFileOpenPreference,\n      host: {\n        name: ctx.hostName ? ctx.hostName : 'Teams',\n        clientType: ctx.hostClientType ? ctx.hostClientType : 'web',\n        sessionId: ctx.sessionId ? ctx.sessionId : '',\n        ringId: ctx.ringId,\n      },\n      manifestVersion: ctx.manifestVersion,\n    },\n    page: {\n      id: ctx.entityId,\n      frameContext: ctx.frameContext || 'content',\n      subPageId: ctx.subEntityId,\n      isFullScreen: ctx.isFullScreen,\n      isMultiWindow: ctx.isMultiWindow,\n      isBackgroundLoad: ctx.isBackgroundLoad,\n      sourceOrigin: ctx.sourceOrigin,\n    },\n    user: {\n      id: ctx.userObjectId ?? '',\n      displayName: ctx.userDisplayName,\n      isCallingAllowed: ctx.isCallingAllowed,\n      isPSTNCallingAllowed: ctx.isPSTNCallingAllowed,\n      licenseType: ctx.userLicenseType,\n      loginHint: ctx.loginHint,\n      userPrincipalName: ctx.userPrincipalName,\n      tenant: ctx.tid\n        ? {\n            id: ctx.tid,\n            teamsSku: ctx.tenantSKU,\n          }\n        : undefined,\n    },\n    channel: ctx.channelId\n      ? {\n          id: ctx.channelId,\n          displayName: ctx.channelName,\n          relativeUrl: ctx.channelRelativeUrl,\n          membershipType: ctx.channelType,\n          defaultOneNoteSectionId: ctx.defaultOneNoteSectionId,\n          ownerGroupId: ctx.hostTeamGroupId,\n          ownerTenantId: ctx.hostTeamTenantId,\n        }\n      : undefined,\n    chat: ctx.chatId\n      ? {\n          id: ctx.chatId,\n        }\n      : undefined,\n    meeting: ctx.meetingId\n      ? {\n          id: ctx.meetingId,\n        }\n      : undefined,\n    sharepoint: ctx.sharepoint,\n    team: ctx.teamId\n      ? {\n          internalId: ctx.teamId,\n          displayName: ctx.teamName,\n          type: ctx.teamType ? window.mapTeamType(ctx.teamType) : undefined,\n          groupId: ctx.groupId,\n          templateId: ctx.teamTemplateId,\n          isArchived: ctx.isTeamArchived,\n          userRole: ctx.userTeamRole ? window.mapUserTeamRole(ctx.userTeamRole) : undefined,\n        }\n      : undefined,\n    sharePointSite:\n      ctx.teamSiteUrl ||\n      ctx.teamSiteDomain ||\n      ctx.teamSitePath ||\n      ctx.mySitePath ||\n      ctx.mySiteDomain\n        ? {\n            teamSiteUrl: ctx.teamSiteUrl,\n            teamSiteDomain: ctx.teamSiteDomain,\n            teamSitePath: ctx.teamSitePath,\n            teamSiteId: ctx.teamSiteId,\n            mySitePath: ctx.mySitePath,\n            mySiteDomain: ctx.mySiteDomain,\n          }\n        : undefined,\n    dialogParameters: ctx.dialogParameters || {},\n  };\n}\n"]}