<?xml version="1.0" encoding="UTF-8"?>
<!--
  WAPD Email Agent - Outlook add-in (add-in-only XML manifest; Mac/classic compatible).
  Milestone 1 task pane: SSO (getAccessToken) -> calls the WAPD Email Agent API.
  WebApplicationInfo.Id/Resource point at the SEPARATE API/add-in app registration
  (ff92e55d-...), NOT the app-only Graph machine identity.
-->
<OfficeApp
  xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">

  <Id>7f431852-ac0b-4423-a19b-6191500a2e07</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Workshop/APD</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="WAPD Email Agent" />
  <Description DefaultValue="Watch senders so important email gets surfaced (and optionally drafted) for you. Drafts land in your Drafts; nothing is sent." />
  <IconUrl DefaultValue="https://mailagent.workshopapd.com/assets/icon-64.png" />
  <HighResolutionIconUrl DefaultValue="https://mailagent.workshopapd.com/assets/icon-128.png" />
  <SupportUrl DefaultValue="https://mailagent.workshopapd.com/" />

  <!-- Domains Office must permit the task pane to reach (the API + AAD for SSO). -->
  <AppDomains>
    <AppDomain>https://wapd-email-agent.azurewebsites.net</AppDomain>
    <AppDomain>https://login.microsoftonline.com</AppDomain>
  </AppDomains>

  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>

  <Requirements>
    <Sets>
      <!-- 1.5 is the minimum for getAccessToken (SSO). -->
      <Set Name="Mailbox" MinVersion="1.5" />
    </Sets>
  </Requirements>

  <!-- Legacy read form (required in the base manifest even when using VersionOverrides). -->
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://mailagent.workshopapd.com/taskpane.html" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <!-- Reading the open message's sender only. -->
  <Permissions>ReadItem</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.5">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>

    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <FunctionFile resid="functionFile" />
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="wapdGroup">
                <Label resid="groupLabel" />
                <Control xsi:type="Button" id="openPaneButton">
                  <Label resid="buttonLabel" />
                  <Supertip>
                    <Title resid="buttonLabel" />
                    <Description resid="buttonTip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="taskpaneUrl" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://mailagent.workshopapd.com/assets/icon-16.png" />
        <bt:Image id="icon32" DefaultValue="https://mailagent.workshopapd.com/assets/icon-32.png" />
        <bt:Image id="icon80" DefaultValue="https://mailagent.workshopapd.com/assets/icon-80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="taskpaneUrl" DefaultValue="https://mailagent.workshopapd.com/taskpane.html" />
        <bt:Url id="functionFile" DefaultValue="https://mailagent.workshopapd.com/commands.html" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="groupLabel" DefaultValue="Email Agent" />
        <bt:String id="buttonLabel" DefaultValue="Email Agent" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="buttonTip" DefaultValue="Open the WAPD Email Agent pane to manage which senders you watch." />
      </bt:LongStrings>
    </Resources>

    <!-- SSO: WebApplicationInfo must live in a NESTED VersionOverrides v1.1 (the
         v1.0 mail VersionOverrides does not allow it directly). Token audience =
         the separate API/add-in app registration. -->
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <WebApplicationInfo>
        <Id>ff92e55d-7930-43c8-ae10-1fbf88f34182</Id>
        <Resource>api://ff92e55d-7930-43c8-ae10-1fbf88f34182</Resource>
        <Scopes>
          <Scope>access_as_user</Scope>
          <Scope>openid</Scope>
          <Scope>profile</Scope>
        </Scopes>
      </WebApplicationInfo>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>
