<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
  Outlook add-in-only XML manifest (LOCK, PLAN.md §3.3 / §4).

  WHY XML (not the unified/JSON manifest): the unified manifest is GA for Outlook web +
  Windows but does NOT run on Outlook mobile or Mac. The XML manifest is the single
  artifact that covers web + new Outlook + (later) mobile via MobileFormFactor. We don't
  need the unified manifest's Teams packaging.

  Supported surfaces (MVP LOCK, PLAN.md §2): Outlook on the web + NEW Outlook for Windows.
  Mobile is a future read-only companion (see the commented MobileFormFactor block below).

  Permissions: ReadWriteItem maps to delegated Mail.ReadWrite (read + create-draft +
  update-draft). NO Mail.Send, NO *.Shared, NO app-wide perms (PLAN.md §3.1 / §6).

  REPLACE every https://gray-water-09b9d6403.7.azurestaticapps.net below with the real, HTTPS ADDIN_BASE_URL at build
  time. Office.js refuses to load add-ins over HTTP.
-->
<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">

  <!-- Stable add-in id (NOT the Entra client id — that lives in WebApplicationInfo below). -->
  <Id>99e71ba0-075b-42e8-92a6-ac8c1555d81b</Id>
  <Version>0.1.0.0</Version>
  <ProviderName>nuAura</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Outlook AI Assistant" />
  <Description DefaultValue="See what matters, understand it, and draft replies in your voice — without leaving the inbox. Never sends mail." />
  <IconUrl DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/assets/icon-64.png" />
  <HighResolutionIconUrl DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/assets/icon-128.png" />
  <SupportUrl DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/support" />

  <!-- AppDomains: every origin the add-in navigates to must be HTTPS and listed here. -->
  <AppDomains>
    <AppDomain>https://gray-water-09b9d6403.7.azurestaticapps.net</AppDomain>
    <!-- NAA/MSAL sign-in redirects (PLAN.md §3.3). -->
    <AppDomain>https://login.microsoftonline.com</AppDomain>
  </AppDomains>

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

  <Requirements>
    <Sets>
      <!-- Mailbox 1.5 is the floor that also satisfies the future mobile read companion. -->
      <Set Name="Mailbox" MinVersion="1.5" />
    </Sets>
  </Requirements>

  <!-- Base (legacy) activation. VersionOverrides below supersede this on modern hosts. -->
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/taskpane.html" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <!-- ReadWriteItem → delegated Mail.ReadWrite. NO Mail.Send (PLAN.md §3.1). -->
  <Permissions>ReadWriteItem</Permissions>

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

  <DisableEntityHighlighting>false</DisableEntityHighlighting>

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

      <Hosts>
        <!-- MailHost = desktop + web (new Outlook for Windows + Outlook on the web). -->
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <FunctionFile resid="Commands.Url" />

            <!-- Message Read surface: a button that opens the task pane. -->
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="oaaGroup">
                  <Label resid="Group.Label" />
                  <Control xsi:type="Button" id="oaaOpenTaskpane">
                    <Label resid="OpenPane.Label" />
                    <Supertip>
                      <Title resid="OpenPane.Title" />
                      <Description resid="OpenPane.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16" />
                      <bt:Image size="32" resid="Icon.32" />
                      <bt:Image size="80" resid="Icon.80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url" />
                      <!-- Pinnable pane: the user can pin it so it stays open while moving
                           between emails (Mailbox 1.5+). The pane re-reads the selection via
                           Office.EventType.ItemChanged (see App.tsx). -->
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
          </DesktopFormFactor>

          <!--
            ===== FUTURE: read-only mobile companion (PLAN.md §3.3, fast-follow) =====
            Mobile add-ins are effectively read-only: Message Read mode only, requirement
            sets <= 1.5, M365/Outlook.com accounts only, NO compose/draft, NO chat-authoring.
            This is why we use the XML manifest — the unified/JSON manifest does NOT support
            Outlook mobile. Uncomment when the read/triage/summarize companion ships.

          <MobileFormFactor>
            <FunctionFile resid="Commands.Url" />
            <ExtensionPoint xsi:type="MobileMessageReadCommandSurface">
              <Group id="oaaMobileGroup">
                <Label resid="Group.Label" />
                <Control xsi:type="MobileButton" id="oaaMobileOpenTaskpane">
                  <Label resid="OpenPane.Label" />
                  <Icon xsi:type="bt:MobileIconList">
                    <bt:Image size="25" scale="1" resid="Icon.16" />
                    <bt:Image size="25" scale="2" resid="Icon.32" />
                    <bt:Image size="25" scale="3" resid="Icon.80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url" />
                  </Action>
                </Control>
              </Group>
            </ExtensionPoint>
          </MobileFormFactor>
          -->
        </Host>
      </Hosts>

      <Resources>
        <bt:Images>
          <!-- TODO(PLAN §3.3): replace gray-water-09b9d6403.7.azurestaticapps.net with the real HTTPS ADDIN_BASE_URL. -->
          <bt:Image id="Icon.16" DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/assets/icon-16.png" />
          <bt:Image id="Icon.32" DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/assets/icon-32.png" />
          <bt:Image id="Icon.80" DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/assets/icon-80.png" />
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Taskpane.Url" DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/taskpane.html" />
          <bt:Url id="Commands.Url" DefaultValue="https://gray-water-09b9d6403.7.azurestaticapps.net/commands.html" />
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="Group.Label" DefaultValue="AI Assistant" />
          <bt:String id="OpenPane.Label" DefaultValue="Open Assistant" />
          <bt:String id="OpenPane.Title" DefaultValue="Open the AI Assistant" />
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="OpenPane.Tooltip" DefaultValue="Summarize this email and draft a reply in your voice (never sent)." />
        </bt:LongStrings>
      </Resources>

      <!--
        Entra app identity (PLAN.md §3.3). Id = the registered multi-tenant app (client) id.
        Resource MUST equal the app registration's Application ID URI — for local sideload
        the documented pattern is api://gray-water-09b9d6403.7.azurestaticapps.net/{clientId}. Scopes are the delegated
        set the host may pre-authorize for the legacy SSO fallback (NAA itself uses MSAL).
        NOTE: offline_access is intentionally absent — Office SSO does not support it here;
        MSAL/NAA requests it at token time (config.ts GRAPH_SCOPES).
      -->
      <WebApplicationInfo>
        <Id>512e6181-4292-4e34-b0f8-9ca18f6b759f</Id>
        <Resource>api://gray-water-09b9d6403.7.azurestaticapps.net/512e6181-4292-4e34-b0f8-9ca18f6b759f</Resource>
        <Scopes>
          <Scope>openid</Scope>
          <Scope>profile</Scope>
          <Scope>User.Read</Scope>
          <Scope>Mail.ReadWrite</Scope>
        </Scopes>
      </WebApplicationInfo>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>
