<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Directory Id="CommonAppDataFolder" Name="CommonAppData">
        <Directory Id="PortmasterDir" Name="Portmaster">
          <Directory Id="IntelDir" Name="intel" />
        </Directory>
      </Directory>
    </DirectoryRef>
  </Fragment>

  <Fragment>
    <Component Id="BinaryFiles" Directory="INSTALLDIR" Guid="850cdd31-424d-45f5-b8f0-95df950ebd0d">
      <File Id="PortmasterCoreDLL" Source="..\..\..\..\binary\portmaster-core.dll" />
      <File Id="PortmasterKextSys" Source="..\..\..\..\binary\portmaster-kext.sys" />
      <File Id="WebView2Loader" Source="..\..\..\..\binary\WebView2Loader.dll" />
      <File Id="PortmasterZip" Source="..\..\..\..\binary\portmaster.zip" />
      <File Id="AssetsZip" Source="..\..\..\..\binary\assets.zip" />
    </Component>

    <Component Id="IntelFiles" Directory="IntelDir" Guid="0bb439f1-2075-45b0-95bf-78ed3dffeb69">
      <File Id="IntelIndexJson" Source="..\..\..\..\intel\index.json" />
      <File Id="BaseDsdl" Source="..\..\..\..\intel\base.dsdl" />
      <File Id="Geoipv4Mmdb" Source="..\..\..\..\intel\geoipv4.mmdb" />
      <File Id="Geoipv6Mmdb" Source="..\..\..\..\intel\geoipv6.mmdb" />
      <File Id="IndexDsd" Source="..\..\..\..\intel\index.dsd" />
      <File Id="IntermediateDsdl" Source="..\..\..\..\intel\intermediate.dsdl" />
      <File Id="UrgentDsdl" Source="..\..\..\..\intel\urgent.dsdl" />
      <File Id="MainIntelYaml" Source="..\..\..\..\intel\main-intel.yaml" />
      <File Id="NotificationsYaml" Source="..\..\..\..\intel\notifications.yaml" />
      <File Id="NewsYaml" Source="..\..\..\..\intel\news.yaml" />
    </Component>

    <Component Id="PortmasterCoreService" Directory="INSTALLDIR" Guid="76ebd748-d620-484b-9035-5a64bbe2c26d">
      <File Id="PortmasterCoreExe" Source="..\..\..\..\binary\portmaster-core.exe" />
      <ServiceInstall
          Id="PortmasterServiceInstall"
          Type="ownProcess"
          Name="PortmasterCore"
          DisplayName="Portmaster Core"
          Description="Portmaster Application Firewall - Core Service"
          Start="auto"
          ErrorControl="normal"
          Vital="yes"
          Interactive="no"
          Arguments="--log-dir=%PROGRAMDATA%\Portmaster\logs"
          Account="LocalSystem" />

      <ServiceControl
          Id="PortmasterServiceDeleteExisting"
          Name="PortmasterCore"
          Remove="uninstall"
          Stop="both"
          Wait="yes"
          />
    </Component>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="BinaryAndIntelFiles">
      <ComponentRef Id="BinaryFiles" />
      <ComponentRef Id="IntelFiles" />
      <ComponentRef Id="PortmasterCoreService" />
    </ComponentGroup>
  </Fragment>
</Wix>